LinuxShellSite
CommandDescriptionSyntax/UsageExampleNotes
chmodChanges the access rights of files and directories.chmod [options] mode fileCHMOD 755 script.shMode can be numeric or symbolic.
ChownChanges the owner and/or group of files.chown [options] [owner][:group] filechown root:users data.txtOften requires root privileges.
chgrpChanges the group membership of files.chgrp [Options] Group Filechgrp developers project/Can be used by users who are members of the group.
umaskSets the default rights for newly created files.umask [Options] [Mask]umask 022Set in shells or scripts.
ls -lLists files with detailed information, including permissions.ls -l [Options] [File/Directory]ls -l /var/www/Useful for checking permissions.
statDisplays detailed status information about files.stat [Options] Filestat index.htmlDisplays permissions and owners, among other things.
getfaclDisplays the Access Control Lists (ACLs) of files.getfacl [Options] Filegetfacl /home/userACLs allow finer permissions.
SetfaclSets or modifies the ACLs of files.setfacl [Options] ACL Filesetfacl -m u:username:rwx /sharedMay need to be installed.
sudoExecutes commands with the privileges of another user (root by default).sudo [command]sudo chmod 644 /etc/passwdUser must be entered in the sudoers file.
suSwitch to a different user account.su [Options] [Username]su – rootWithout an argument, it switches to root.
findSearches for files and can perform actions on them.find [path] [criteria] [action]find /var/www -type f -exec chmod 644 {} \;Useful for bulk changes.
  • Numeric vs. symbolic mode specifications in chmod:
    • Numeric: Use numbers to set permissions.
      • Example: chmod 755 file sets permissions to rwxr-xr-x.
    • Symbolic: Use icons to change specific permissions.
      • Example: chmod u+rwx,g+rx,o+rx file.
  • umask values:
    • The umask value is subtracted from the maximum permissions.
    • Example: umask 022 causes new files to receive permission 755 (777 – 022).
  • ACLs (getfacl and setfacl):
    • Allow permissions to be assigned to individual users or groups.
    • Not enabled by default on all file systems.

Platform-specific differences:

  • Some distributions require getfacl and setfacl to be installed via the acl package.
    • Ubuntu/Debian: sudo apt-get install acl
    • RHEL/CentOS: sudo yum install acl
  • The use of sudo can be configured differently depending on the distribution.
    • Ubuntu: sudo is enabled by default, root account is disabled.
    • RHEL/CentOS: Root account is activated, sudo may need to be configured.