Linux/Unix File & Folder Permissions
Tuesday, December 2, 2008 18:04File and Folder permissions on *unix like systems.
ls -l ;show details
Type:
d – directory, - file, l – symbolic link, p – pipe, c – character device, b – block device
rwx – read write execute
r(4) w(2) x(1)
Permissions applied to files:
r – read file content
w – change file content (does not mean you can remove the file!)
x – execute program if shell script or binary
Permissions applied to Folders:
r – read folder content, simple ‘ls’ permitted
w – change directory content (adding & deleting)
x – searching the directory, positioning in it (cd), dislplay full info (ls -l)
!! For a directory to be useful you need to set RX permissions
!! W for a file does not mean you can delete it. To delete a file you need W on the parent directory.
Default Permissions
Files: 666 – umask
Folders: 777 – umask
ie: umask 023, default permissions – owner all permissions, no write to group, no write & execute to others
Special Bits
SUID / SGID
chmod u+s myfile; chmod g+s myfile
- replaces x with s for user or group. If assigned program executed with permissions of file’s owner/group
Sticky Bit (t)
In 777 folders all users can write and delete all files. This is not good in shared /tmp folders. Setting the “t” sticky bit allows only owners to delete and change their own files in a 777 folder
chmod +t myfolder; chmod 1777 myfolder