chmod 500 r-x------

chmod 500 (r-x------): the owner can read and execute; group and others can do nothing. Typical use: private read-only scripts. Commands and umask.

Octal
500 (also written 0500)
Symbolic
r-x------
ls -l shows
-r-x------ for a file, dr-x------ for a directory
chmod letters
u=rx,g=,o=

Who can do what

ClassDigitBitsOn a fileOn a directory
Owner (u)5r-xRead the contents and run it as a programList the names inside and enter it and open files by name
Group (g)0---NothingNothing
Others (o)0---NothingNothing

Each digit adds read (4), write (2) and execute (1). Deleting or renaming a file depends on write and execute on the directory that holds it, not on the file's own mode. Root bypasses read and write checks.

Typical uses

The owner can read and run the file, or list and enter the directory; nobody else has any access, and even the owner cannot write without changing the mode first. It suits a private script or folder that should not be edited by accident.

Security notes

  • Nobody but the owner (and root) has any access, the safest setting for secrets.

Commands

  • Numeric
    chmod 500 file
  • Symbolic
    chmod u=rx,g=,o= file
  • Check the result
    stat -c '%a %A %n' file
  • Directories only, recursively
    find /path -type d -exec chmod 500 {} +

Avoid chmod -R 500 on a tree that holds files as well as folders: it makes every file executable. Use the find command above for directories and a file mode such as 400 for the files.

The umask that gives 500

  • umask 277: new directories are created as 500 (and files as 400)

Programs create files with 666 and directories with 777, and the umask removes bits from those. A umask never adds execute to a new file, and it cannot set setuid, setgid or the sticky bit.

Its file counterpart is chmod 400 (r--------).

Other common modes

Work out any other mode in the chmod calculator