Linux File Permissions Explained [Needs Table]

Brett Terpstra
Brett TerpstraPrincipal Developer, Oracle
Published: February 1, 2024

File permissions are "bits" set on any file in a Unix system. Here is a reference sheet of some of the most common permissions bits:

PermissionsNumericMeaning
drwxr-xr-x755Directory, accessible by everyone but only writable by the owner
-rw-r--r--644File, readable by everyone but can only be modified by the owner
-rwxrwxrwx777File is readable (and executable) by anybody
-rw-------600File can only be accessed by the owner, inaccessible to everyone else

A file's permissions define what the owner can do, what the owner's group can do, and what the rest of the world can do to a file --- read, write, or execute it. For \nix purposes, a directory is also a file, and you can't

cd into a directory that doesn't have the executable permission set for your user.

To check permissions of all the files in a directory, you can run ls -l to perform a long format listing. This shows the permissions for each file and directory in the first column. These are shown as -ooogggwww, where o is "owner," g is "group," and w is "world."

In the case of a directory, the first single indicator will be d. Each one of the other types gets three positions: read, write, and execute. If a r, w, or x is present in its respective position, then that user has access to that permission, otherwise you'll see a dash (-). So a file that was readable and writable by its owner but inaccessible to other users would look like -rw-------.

Understanding file permissions as numbers

-rw------- can be represented numerically as 600. The 6 translates as rw for the user and the 0s translate as "no access" for group and world, respectively.

When using numeric representation, the numbers can be three or four digits. In the case of a four-digit number, the first digit is used to set setuid, setgid, or sticky bit. The last three digits represent a combination of read, write, and execute added together.

  • 4 = r (read)
  • 2 = w (write)
  • 1 = x (execute)

For each group, you add the three numbers together to create a single-digit representation of the permissions for that group. For example:

  • 0 means no permissions
  • 4 means read only (4)
  • 5 means read and execute (4 + 1)
  • 6 means read and write (4 + 2)
  • 7 means all permissions (read, write, and execute, or 4 + 2 + 1)

A file that is executable by the owner and read-only for everyone else would be -rwxr--r--, represented as 0744, with 7 (4 + 2 + 1) for the user and 4 for group and world.

Standard permissions for files and directories

The standard permissions for a regular file are -rw-r--r--, or, numerically, 644, which gives the file owner permission to read and write, and the group and world permission to read only.

The standard permissions for a directory are drwx-r-xr-x, or 755. This gives the owner permission to write, and the owner, group, and world  permission to read and "execute" them, or in this case cd into them.

An executable file, such as an executable shell script with proper shebang or a binary, gets the x bit set for the appropriate user. In most cases this is everybody, which translates as -rwxr-xr-x, or 755. To make a file \fully\ readable, writeable and executable to \everybody\, you would want -rwxrwxrwx, or 777 file permissions. This is generally ill-advised, as you don't want the entire \world\ to have write access to any file.

Setting and modifying file permissions is done using the chmod command, which we discuss further in another post.

Written by
Brett Terpstra
Brett TerpstraPrincipal Developer, Oracle
Filed under

Related articles


Bash Comments

Comments will help make your scripts more readable

Reading User Input

Via command line arguments and prompting users for input

Curl Post Request

Use cURL to send data to a server

Upload Files With curl

Learn how to upload a file to FTP, SFTP servers, Artifactory, and AWS S3 using the curl command.

How To Copy A Directory In Linux

Learn how to copy directories and their content in Linux using the cp command with options like -r for recursive copying, -i for interactive mode, and -a for preserving attributes.

Create Groups In Linux

Learn how to manually and automatically create and list groups in Linux.

How to Check the Size of Folders in Linux

Learn how to output the size of directories and subdirectories in a human-readable format in Linux and macOS using the du command.

Count Files in Linux

Learn how to count files and folders contained in directories and subdirectories in Linux using the ls, find, and wc commands.

List Open Ports in Linux

Learn how to output the list of open TCP and UDP ports in Linux, as well as their IP addresses and ports using the netstat command.

Format Command Output In Linux

Learn how to filter and format the content of files and the output of commands in Linux using the awk command.

Create Directories Recursively With mkdir

Learn how to recursively create nested directories using the mkdir command, Bash scripts, and Python scripts.

Remover Users in Linux

Learn how to remove local and remote user accounts and associated groups and files in Linux using the userdel and deluser commands.