1 / 12

Advanced UNIX

Advanced UNIX. CIS 218 Advanced UNIX. File s again. Users and Ownership. File ownership is based on your user-id integer (uid) in the 3rd field of /etc/passwd : ad:x: 42497 :100:... Group-id is 4th field; also stored in /etc/group

declan-hahn
Download Presentation

Advanced UNIX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced UNIX CIS 218 Advanced UNIX Files again..

  2. Users and Ownership • File ownership is based on your user-id integer (uid)in the 3rd field of /etc/passwd: ad:x:42497:100:... • Group-id is 4th field; also stored in/etc/group • chmod() can only be used by the current file owner or root (the superuser). • chown() can only be used by the current file owner or the superuser.An incorrect change may make the file inaccessible to you! • chgrp()is used by the current file owner to assign groups to the 2nd group of file permossions

  3. Real uids • The uid of the user who started the program is used as its real uid. • The real uid affects what the program can do (e.g. create, delete files). continued

  4. Effective uids • Programs can change to use the effective uid • the uid of the program owner • e.g. the passwd program changes to use its effective uid (root) so that it can edit the /etc/passwd file • The loginprogram changes to use its effective uid (root) so that it can read the /etc/shadow file • This feature is used by many system tools, such as login programs.

  5. Real and Effective Group-ids • There are also real and effective group-ids. • Usually a program uses the real group-id(i.e. the group-id of the user). • Sometimes useful to use effective group-id(i.e. group-id of program owner): • e.g. software shared across teams

  6. Extra File Permissions • Octal Value Meaning04000 Set user-id on execution. Symbolic: --s --- ---02000 Set group-id on execution. Symbolic: --- --s --- • These specify that a program should use the effective user/group id during execution. continued

  7. Extra File Permissions • Example: • chmod 4755 ~/myscript $ ls -al ~/myscript-rwsr-xr-x 1 usergroup • chmod 2755 ~/myscript $ ls -al ~/myscript-rwxr-sr-x 1 usergroup

  8. Sticky Bit • Octal Meaning01000 Save text image on execution. Symbolic: --- --- --t • This specifies that the program code should stay resident in memory after termination. • this makes the start-up of the next execution faster • Example:chmod 1755 ~/myscript $ ls -al ~/myscript-rwxr-xr-t 1 usergroup • Obsolete function due to virtual memory.

  9. File Creation Mask • The file creation mask specifies permission bits to always turn off whenever a file is created. • At UNIX level, use umask: • umask 022 switch off group & others write; • umask 066 switch off group & others read and write; • umask read current setting.

  10. Device numbers:ls -l • In /dev major and minor device numbers can be displayed with ls -l: $ ls -l /dev/ttyp0crw--w---- 1 ad tty 4, 192 Aug 13 10:19 /dev/ttyp0 file type major devicenumber minor devicenumber

  11. I-node number • Each file has a unique i-node number (index number) within a filesystem. Listed by ls –i <file> • Display filesysteminodes: df –I • i-node number is used to look up a file’s information (i-node) in the (i-list) table. • A file’s i-node contains: • user and group ids of its owner • permission bitsetc.

  12. File Types – first column - Regular File (text/binary) d Directory File c Character Special File e.g. I/O peripherals, such as /dev/ttyp0 b Block Special File e.g. cdrom, such as /dev/mcd F FIFO (named pipes) S Sockets l Symbolic Links

More Related