Agentic AI with Java: Live Cohort
LinuxLinux Users, Permissions & Ownership

Linux Numeric Permissions

What Is Numeric Mode?

Linux allows you to change file and directory permissions using either symbolic mode (u+x, g-w) or numeric mode (755, 644).

Numeric mode uses numbers to represent permissions for the owner, group, and others. It is especially useful when you want to set all three permission categories in a single chmod command.

Permission Values

Each permission has a numeric value:

PermissionSymbolValue
Readr4
Writew2
Executex1

To calculate a permission value, add the numbers for the permissions you want.

For example:

  • Read only: 4
  • Write only: 2
  • Execute only: 1
  • Read + write: 4 + 2 = 6
  • Read + execute: 4 + 1 = 5
  • Write + execute: 2 + 1 = 3
  • Read + write + execute: 4 + 2 + 1 = 7
  • No permissions: 0

This gives us the following reference table:

Numeric ValueSymbolic PermissionMeaning
0---No permissions
1--xExecute only
2-w-Write only
3-wxWrite and execute
4r--Read only
5r-xRead and execute
6rw-Read and write
7rwxRead, write, and execute

Understanding the Three-Digit Format

The general syntax is:

chmod [owner][group][others] filename

Each digit represents the permissions for one category.

PositionCategoryExample
First digitOwner7
Second digitGroup5
Third digitOthers5

For example, chmod 755 script.sh sets the permissions as follows:

  • Owner: 7 → read, write, and execute (rwx)
  • Group: 5 → read and execute (r-x)
  • Others: 5 → read and execute (r-x)

The resulting permission string is:

-rwxr-xr-x

The leading - indicates that the entry is a regular file.


Practical Examples

Example 1: chmod 745 devops.txt

chmod 745 devops.txt

Break down each digit:

DigitCategoryCalculationPermission
7Owner4 + 2 + 1rwx
4Group4r--
5Others4 + 1r-x

Result:

-rwxr--r-x

The owner can read, modify, and execute the file. Group members can read it, while others can read and execute it.

Note: The .txt extension does not make a file executable. Execute permission only allows execution when the file is a suitable executable or script.

Example 2: chmod 744 devops.txt

chmod 744 devops.txt
DigitCategoryPermission
7Ownerrwx
4Groupr--
4Othersr--

Result:

-rwxr--r--

The owner has all three permissions, while the group and others have read permission only.

Example 3: chmod 644 file.txt

chmod 644 file.txt

Result:

-rw-r--r--

The owner can read and modify the file. Group members and others can read it but cannot modify it through their assigned permissions.

This is a common permission setting for regular files that need to be readable by other users.


Common Permission Combinations

CommandPermission StringTypical Use
chmod 400 file.pemr--------Restrict a private key file to owner read access
chmod 444 file.txtr--r--r--Read-only access for all categories
chmod 644 file.txtrw-r--r--Regular files readable by others
chmod 755 script.shrwxr-xr-xScripts or executables accessible to others
chmod 700 private.shrwx------Owner-only access to a file
chmod 777 file.txtrwxrwxrwxRead, write, and execute permissions for everyone

Security tip: Avoid 777 unless there is a specific, justified need. It grants all three permission types to everyone, which can expose files to unwanted modification or execution.

For SSH private keys, 400 is one possible restrictive setting. The required permissions depend on the SSH client and its security checks.


Applying Numeric Permissions to Directories

Numeric mode also works with directories.

chmod 766 linux

If linux is a directory, its permissions become:

drwxrw-rw-

Here:

  • d indicates a directory.
  • Owner permissions 7 (rwx) allow listing entries, creating or removing entries, and traversing the directory.
  • Group permissions 6 (rw-) allow listing entries where permitted, but without execute permission, users generally cannot access entries by name.
  • Others have the same rw- permissions as the group.

Important: Directory permissions behave differently from file permissions. Without execute (x) permission on a directory, read or write permission alone is generally insufficient to access entries inside it. The example above is therefore usually not a useful directory permission setting.

Verifying Permissions

After changing permissions, use ls -l to check the result.

chmod 755 script.sh
ls -l script.sh

Example output:

-rwxr-xr-x 1 ubuntu ubuntu 120 Oct 11 10:30 script.sh

The permission string confirms that the owner has rwx, while the group and others have r-x.


Summary

  • Numeric mode uses values from 0 to 7 to represent permission combinations.
  • Read = 4, write = 2, and execute = 1.
  • A three-digit mode represents permissions for the owner, group, and others, in that order.
  • chmod 644 file.txt and chmod 755 script.sh are common examples for regular files and executable scripts.
  • Use ls -l to verify permissions after making changes.
  • Choose permissions according to the access users actually need, especially when working with sensitive files or directories.

Remember: Symbolic mode is useful for changing specific permissions, while numeric mode is convenient for setting the complete permission set in one command.

Written By: Muskan Garg

How is this guide?

Last updated on