Every file has an owner and a group. It has three sets of permissions:
- one for the owner
- one for the group
- one for others (everyone else)
Each set adds up three numbers: read (4), write (2) and execute (1). Each digit in 755 is one of these sums, written in octal (base 8).
The three common values:
755isrwxr-xr-x. The owner can read, write and execute. Everyone else can read and execute. Use it for scripts, binaries and directories.644isrw-r--r--. The owner can read and write. Everyone else can only read. Use it for config files and static assets.600isrw-------. Only the owner can read or write. Use it for secrets like SSH private keys and.envfiles.sshrefuses to use a private key that other users can read.
On a directory, the letters mean different things:
rlets you list the names inside.wlets you create and delete entries.xlets you enter the directory and reach the files inside.
Use chmod to change permissions. Use chown user:group file to change who owns the file.
- There are three permission sets: owner, group and others. Read is 4, write is 2 and execute is 1.
755(rwxr-xr-x) is for scripts and directories.644(rw-r--r--) is for regular files and config files.600(rw-------) is for secrets such as SSH keys.- On a directory,
xmeans you can enter it and pass through it.