Skip to content

Instantly share code, notes, and snippets.

@ThinhPhan
Created February 9, 2023 09:51
Show Gist options
  • Save ThinhPhan/e4ebd033b4db252a55405cb73d2d7b33 to your computer and use it in GitHub Desktop.
Save ThinhPhan/e4ebd033b4db252a55405cb73d2d7b33 to your computer and use it in GitHub Desktop.
Permissions on Linux
Number Octal Permission Representation Ref
0 No permission ---
1 Execute permission --x
2 Write permission -w-
3 Execute and write permission: 1 (execute) + 2 (write) = 3 -wx
4 Read permission r--
5 Read and execute permission: 4 (read) + 1 (execute) = 5 r-x
6 Read and write permission: 4 (read) + 2 (write) = 6 rw-
7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx

Example

$ chmod 755 testfile
$ls -l testfile
-rwxr-xr-x  1 amrood   users 1024  Nov 2 00:10  testfile
$chmod 743 testfile
$ls -l testfile
-rwxr---wx  1 amrood   users 1024  Nov 2 00:10  testfile
$chmod 043 testfile
$ls -l testfile
----r---wx  1 amrood   users 1024  Nov 2 00:10  testfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment