Linux Permissions

File permissions and ownership

View Permissions

ls -l # show permissions
# -rwxr-xr-- (file type + owner + group + others)
# r=read(4), w=write(2), x=execute(1)

Change Permissions

chmod 755 file # rwxr-xr-x
chmod 644 file # rw-r--r--
chmod 777 file # rwxrwxrwx (all permissions)

Symbolic Mode

chmod u+x file # add execute for user
chmod g-w file # remove write for group
chmod o=r file # set read-only for others
chmod a+x file # add execute for all

Recursive Permissions

chmod -R 755 directory # apply to all files/subdirs

Change Owner

chown user file # change owner
chown user:group file # change owner and group
chown -R user directory # recursive ownership

Change Group

chgrp group file # change group
chgrp -R group directory # recursive group change

Special Permissions

chmod u+s file # setuid
chmod g+s directory # setgid
chmod +t directory # sticky bit