Unix File Permissions

Code : $ ls -ld /usr/bin /usr/bin/cat drwxrwxr-x 3 root bin 8704 Sep 23 2004 /usr/bin -r-xr-xr-x 1 bin bin 9388 Jul 16 1997 /usr/bin/cat $



Code : |------file mode------| | | | | |----full-----| | |-type| | |--basic--| | | | | | oo0 000 000 000 000 000 ... ... ... ... ... ... | | | | | | | | | |---- rwx for other | | | | | | | |-------- rwx for group | | | | | |------------ rwx for user | | | |---------------- set uid, set gid, sticky bit | |---------------------- file type: regular (-) directory (d) character special (c) block special (b) fifo (p) symbolic link (l) socket (s)



Code : 421 rwx



Code : --- = 0 --x = 1 -w- = 2 -wx = 3 r-- = 4 r-x = 5 rw- = 6 rwx = 7



Which Set of Bits Applies to You?

Code : ----rwxrwx 1 joe users 29 Mar 22 19:39 somefile



What do r w and x really mean for a file?

What do r w and x really mean for a directory?

Symbolic Links Are Special

Code : $ ls -l /etc/passwd /etc/shadow /usr/bin/passwd -r--r--r-- 1 root sys 14006 Jan 14 11:17 /etc/passwd -r-------- 1 root sys 8281 Jan 14 11:18 /etc/shadow -r-sr-sr-x 3 root sys 96244 Sep 5 2001 /usr/bin/passwd



Code : drwxrwxrwt 5 root root 1024 Feb 11 20:43 /tmp



Code : The who part can be: u (user) g (group) o (other) a (all) (whatever is allowed by umask (subset of all)) The operator can be = or - or + = (set bits to bitlist) - (subtract bitlist from current bit + (add bitllist to current bits) The bitlist can be one of the following letters: r (read permission) w (write permission) x (execute permision) X (conditional execute permision) u (current permissions for user) g (current permissions for group) o (current permissions for others) s (set uid or set gid) t (sticky bit)

