How to Use the chmod Command in Linux

Change a file's permissions from the Linux command line

The chmod command changes the access permissions of files and folders. The chmod command, like other commands, can be executed from the command line or through a script file.

If you need to list a file's permissions, use the ls command.

Illustration of computer with window open with check mark and stars representing password and permission accepted in computers
Mykyta Dolmatov / Getty Images

Command Syntax

This is the proper syntax when using the chmod command:

chmod [options] mode[,mode] file1 [file2 ...]

The following are the usual options used with chmod:

  • -f, --silent, --quiet: Suppresses most error messages.
  • -v, --verbose: Outputs a diagnostic for every file processed.
  • -c, --changes: Like verbose but reports only when a change is made.
  • -R, --recursive: Changes files and directories recursively.
  • --help: Displays help and exits.
  • --version: Outputs version information and exits.

Below is a list of numerical permissions that can be set for the user, group, and everyone else on the computer. Next to the number is the read, write, and execute letter equivalent.

  • 7, rwx: Read, write, and execute.
  • 6, rw-: Read and write.
  • 5, r-x: Read and execute.
  • 4, r--: Read-only.
  • 3, -wx: Write and execute.
  • 2, -w-: Write only.
  • 1, --x: Execute only.
  • 0, ---: None.

Command Examples

To change the permissions of the file participants so that everybody has full access to it, enter:

chmod 777 participants

The first 7 sets the permissions for the user, the second 7 sets the permissions for the group, and the third 7 sets the permissions for everybody else.

If you want to be the only one who can access it, use:

chmod 700 participants

To give yourself and your group members full access, enter:

chmod 770 participants

If you want to keep full access for yourself, but want to keep other people from modifying the file, use:

chmod 755 participants

The following uses the letters from above to change the permissions of participants so that the owner can read and write to the file, but it doesn't change permissions for anyone else:

chmod u=rw participants

More Information on the chmod Command

Change the group ownership of existing files and folders with the chgrp command. Change the default group for new files and folders with the newgrp command.

Symbolic links used in a chmod command affect the target object.

Setting Modes

Use chmod to set additional file system modes for files and directories. For example, to set the sticky bit, prefix a 1 to the number sequence:

chmod 1755 participants

With a sticky bit, only the file owner, the directory owner, or the root superuser can delete the file, regardless of the file's read-and-write group permissions.