List, set, and change standard ugo/rwx permissions

Context: RHCSA certification

List, set, and change standard ugo/rwx permissions

To manage file permissions on a Linux system, including the standard user/group/other (ugo) permissions, you can use commands like ls, chmod, and chown. Here's how you can list, set, and change standard ugo/rwx permissions:

  1. List Permissions: To view the permissions of a file or directory, you can use the ls -l command. It displays the permissions in the long format, showing the user, group, and other permissions along with other file details.


    ls -l myfile.txt

    The output will look something like this:

    -rw-r--r-- 1 user group 4096 Jun 1 10:23 myfile.txt

    The permission string -rw-r--r-- represents the user, group, and other permissions, respectively.

  2. Set Permissions: To set the permissions explicitly using the chmod command, you can use the following format:

    chmod <permissions> <file>

    The <permissions> part can be represented using three digits or symbols:

    • Numeric representation: Each digit represents the permissions for user, group, and other respectively, with the values:
      • 4: Read (r)
      • 2: Write (w)
      • 1: Execute (x)
      • 0: No permission (-)


    chmod 644 myfile.txt

    This command sets the permissions of myfile.txt to read and write for the owner (user) and read-only for the group and others.

  3. Change Permissions: To change permissions using symbolic representation, you can use the following format:

    chmod <symbolic_permissions> <file>

    The <symbolic_permissions> part uses symbols to represent permissions:

    • u: User
    • g: Group
    • o: Other
    • a: All (user, group, and other)

    The symbols + and - are used to add or remove permissions, respectively. The permissions are represented using the symbols r (read), w (write), and x (execute).


    chmod u+x myfile.txt

    This command adds executable permission to the user for myfile.txt.

Remember that changing file permissions should be done carefully, considering the security requirements and best practices for your system.

You should also read:

granular permissions

What GNU/Linux commands can be used to change permissions granularly? In GNU/Linux, there are several commands and utilities that can be used to…