Notifications
Clear all

Linux Commands Cheat Sheet - Permissions


(@abhijeet)
Script Novice
Joined: 9 months ago
Posts: 36
Topic starter  

Here are the commands dedicated to managing file and directory permissions.

Command Description
ls -l List files and directories with detailed information, including permissions.
chmod mode file Change the permissions of file to mode, which can be specified in symbolic (e.g., rwx) or numeric (e.g., 755) format.
chmod -R mode directory Recursively change the permissions of directory and its contents to mode.
chown user file Change the owner of file to user. Only the superuser can change the owner of a file.
chown user:group file Change both the owner and the group of file to user and group, respectively.
chown -R user:group directory Recursively change the owner and group of directory and its contents to user and group.
chgrp group file Change the group ownership of file to group.
chgrp -R group directory Recursively change the group ownership of directory and its contents to group.
umask Display or set the file mode creation mask, which determines the default permissions for newly created files and directories.
setfacl -m u:user:rwx file Set file access control lists (ACLs) to give user read, write, and execute permissions on file.
getfacl file Display the access control lists (ACLs) of a file or directory.
chmod +x file Add execute permission for the file owner, group, and others.
chmod o-w file Remove write permission from others.
chmod g+s directory Set the setgid bit on directory to make new files inherit the same group as the directory.
chmod u+s file Set the setuid bit on file to make users execute the file with the file owner’s permissions.
chmod 644 file Set read and write permissions for the owner, and read-only permissions for the group and others.
chmod 755 file Set read, write, and execute permissions for the owner, and read and execute permissions for the group and others (common for executables and directories).
chmod 700 file Set read, write, and execute permissions for the owner, and no permissions for the group and others (private file).

   
Quote
Share: