Tolz.me

Chmod Calculator

Convert file permissions between octal, symbolic, and ls -l forms, including setuid, setgid, and the sticky bit.

Permissions

ClassReadWriteExecute
OwnerThe user who owns the file
GroupUsers in the file's group
OthersEvery other user on the system
Special bits

Result

600 is rw-------. Owner: read, write. Group: no access. Others: no access.

chmod 600 file
chmod u=rw,g=,o= file

Common modes

rw-r--r--Owner can read and write, everyone else can only read.Fine for public web files. Wrong for private keys or secrets.
rwxr-xr-xOwner has full control, everyone else can read and execute.Common for directories, scripts, and most program files.
rw-------Only the owner can read and write. Nobody else has access.The usual choice for SSH keys, tokens, and config files.
rwx------Only the owner can read, write, and enter the directory.Common for private directories such as ~/.ssh.
rw-r-----Owner can read and write, the group can read, others have no access.
rwxr-x---Owner has full control, the group can read and execute, others have none.
rwxrwxrwxEvery user on the system can read, write, and execute.Avoid this on servers. Anyone can replace the contents of your files.
rw-rw-rw-Every user on the system can read and write.Any local user can change the file, including scripts.
rwsr-xr-xSetuid plus 755: the program runs with the privileges of the file owner.Only sensible for trusted system binaries. A setuid script is ignored by most systems.
rwxrwxrwtSticky bit plus 777: users can create files, but only the owner can delete them.

Modes that give "others" write access are the ones to watch. A 777 or 666 file lets every account on the machine change its contents.

chmod is ignored on Windows and has no effect on some network filesystems. On Linux, a directory needs the execute bit to be entered at all.

About this tool

A chmod calculator converts file permissions between the octal number, the symbolic string, and the letters you see in an ls -l listing. Tick the owner, group, and others boxes for read, write, and execute, or paste a mode you already have. Setuid, setgid, and the sticky bit are included, and the tool outputs a chmod command you can paste into a terminal.

Browse more developer tools or explore all Tolz.me tools.

Try other relevant tools

Related articles

Frequently asked questions

What does chmod 755 mean?+

In octal, 7 is read plus write plus execute for the owner, 5 is read plus execute for the group, and the last 5 is read plus execute for everyone else. The symbolic form is rwxr-xr-x.

What is the difference between 644 and 755?+

644 is rw-r--r--, so everyone can read the file but only the owner can change it. 755 is rwxr-xr-x, so everyone can also run it. Directories need the execute bit for people to enter them, which is why 755 is the usual directory mode.

What does the sticky bit do?+

On a directory, the sticky bit lets everyone create files but stops one user from deleting another user's files. That is why /tmp is 1777. It appears as a t in the symbolic form, or as the leading 1 in the octal form.

What are setuid and setgid?+

Setuid on an executable makes it run with the privileges of the file owner, which is how passwd works. Setgid on a directory makes new files inherit the directory's group. In symbolic form they show up as s in the execute position, and in octal as a leading 4 and 2.

How do I convert an ls -l line such as drwxr-xr-x into a number?+

Paste it into the ls -l field. The leading d marks a directory and is ignored. The tool converts the remaining nine characters into the octal form, which for drwxr-xr-x is 755.

Is chmod 777 safe to use?+

Not on a server. At 777 every account on the machine can change the file, and at 666 every account can read and write it. Use 755 for public files and directories, and 600 for anything secret.

Is this chmod calculator free?+

Yes. It runs in your browser and never touches your files or runs a command.

Use cases

  • Work out the octal number for a mode you found in a tutorial or a ticket.
  • Build the right mode for a script, a shared folder, or a secret file.
  • Decode an ls -l line before pasting it into a bug report.
  • Check whether a file carries a setuid, setgid, or sticky bit.
  • Review the permissions on a file before you share it with someone.

Chmod Calculator

A chmod calculator converts between the three ways Linux permissions get written: the octal number, the symbolic string, and the letters you see in an ls -l listing. Tick the boxes you want, or paste a mode you already have, and the tool gives you the other two forms plus a ready-to-run chmod command.

What chmod actually changes

Every file and directory on a Unix-like system carries a mode. The mode decides who may read it, write it, or run it. The mode also records which user owns the file and which group it belongs to, which is why the same number means different things for a file you own and a file owned by root.

chmod is the command that edits the permission bits. It does not move files, does not change owners, and does nothing at all on Windows. The mode it sets is what the filesystem stores, and what you read back later with ls -l.

Permissions are read in three groups of three: the owner, the group, and everyone else. Each group can have read, write, and execute. Read lets you open the file and list a directory, write lets you change the contents, and execute lets you run a program or step into a directory. The execute bit on a directory is what lets you list its contents at all, which is why directories usually carry it for every class.

The three forms of the same mode

The octal form treats each permission as a number. Read is 4, write is 2, execute is 1. Add the three for each group and you get one digit per group, so owner read plus write plus execute is 4 plus 2 plus 1, which is 7.

The symbolic form spells the same thing out letter by letter. Nine characters: rwx for the owner, then the group, then others. A dash means the permission is missing. That is the form you see in the first ten characters of an ls -l line.

The special bits add a fourth digit at the front of the octal number. setuid is 4, setgid is 2, and the sticky bit is 1. In the symbolic form they show up as s, S, t, or T in the execute position of their group.

How to use the calculator

Start with the grid. Three rows for owner, group, and others, three columns for read, write, and execute. Tick what you want and the octal number, the symbolic string, and the chmod commands update immediately.

The three text fields below the grid are for the other direction. Type an octal number such as 755 or 4755 and the grid updates. Type a symbolic string such as rwxr-xr-x and it does the same. Paste the permission part of an ls -l line, with or without the leading file type character, and the tool reads it the way the shell does.

Set the file name at the bottom to get a command you can paste straight into a terminal. The tool always produces two: one with the octal number and one with the symbolic form, which is easier to read when someone else has to maintain it later.

Worked examples

Each example below shows the input, the octal number, and the matching symbolic string.

The default web file

Owner reads and writes, everyone else reads only. This is the mode you will see on most static files on a web server.

Input:   -rw-r--r--
Octal:   644
Command: chmod 644 index.html
         chmod u=rw,g=r,o=r index.html

A script anyone can run

Owner has full control, and everyone else can read the file and run it. The same mode is the usual choice for a directory so that people can list it and enter it.

Input:   -rwxr-xr-x
Octal:   755
Command: chmod 755 deploy.sh
         chmod u=rwx,g=rx,o=rx deploy.sh

A private key

Only the owner has access. SSH refuses to read a private key that is group or world readable, so 600 is the number to remember for keys and tokens.

Input:   -rw-------
Octal:   600
Command: chmod 600 id_ed25519
         chmod u=rw,g=,o= id_ed25519

Reading the setuid, setgid, and sticky letters

The special bits use a letter in the execute slot of their group. A lowercase letter means the special bit is set and the execute bit is also set, so 4755 shows as rwsr-xr-x. An uppercase letter means the special bit is set but execute is not, so a setuid file that cannot be run appears as rwSr-xr-x. The same rule applies to S for setgid and T for the sticky bit.

setuid on an executable makes the program run with the privileges of the file owner. That is how tools like passwd can change a password without being root themselves. setgid on a directory makes new files inherit the group of the directory, which is how shared project folders work. The sticky bit on a directory stops one user from deleting another user's files, which is why /tmp is 1777.

One detail worth knowing: the setuid bit is ignored on shell scripts on Linux, so setting it on a script does nothing. It only works on compiled binaries.

Common modes and what they cost you

644 is a sensible default for public files and a bad default for anything secret. If a private key ends up at 644, every account on the machine can read it, and tools like SSH will refuse to use it.

600 and 700 are the private modes. Use them for keys, token files, and any directory that holds them.

755 is the standard choice for directories, scripts, and program files. It is a good default because the world needs to read and run them, but not write to them.

777 and 666 are the ones to avoid. A file at 666 lets every account on the machine change its contents, which on a shared host means someone else can replace your script. A directory at 777 lets any user delete the files inside it. If a script tells you to run chmod 777, it is usually asking for a smaller change.

Remember that the mask on your shell can add bits back. Running umask 022 after a chmod 666 leaves you at 644 in most cases, which is a common reason a mode change seems to have half worked.

Tips for using chmod safely

Check the current mode before changing it. ls -l on the file gives you the symbolic string, and stat -c '%a %n' gives you the octal number.

Apply a mode to a directory with -R and think about whether you want that. chmod -R 755 on a directory tree also changes every file inside it, including the ones that were deliberately private. Changing directories and files separately is slower but much easier to undo.

Use symbolic chmod when you only want to adjust one part of a mode. chmod u+x script.sh adds the execute bit for the owner and leaves everything else alone, while chmod 755 script.sh replaces all nine bits.

Check whether the filesystem supports permissions at all. Many network mounts and some container volumes ignore the mode bits, and a mode that looks right in ls -l may not be enforced.

On SELinux or AppArmor systems, permissions are only the first layer. A correct mode can still be denied by a policy rule.

Edge cases and troubleshooting

chmod reports Operation not permitted when the file belongs to another user and you are not root. Changing a mode needs ownership of the file, or root.

If a file stays at 777 after you set it, the filesystem is mounted with permission bits ignored, often with a noacl or similar option, or you are looking at a virtual filesystem such as some network and container mounts.

If a directory cannot be entered even though it is readable, the execute bit is missing for your class. Read lets you list the names, execute lets you open the entries.

If you are working in a container or on Windows through a mounted drive, expect the mode to be advisory at best. The Linux permission model only applies on filesystems that store POSIX modes.

This tool does all of its maths in your browser. It never touches your filesystem and never runs a command.

Explore more developer tools on Tolz.me.

Related tools