What is chmod (change mode)? Command to change permissions of files and directories in UNIX/Linux

Explanation of IT Terms

What is chmod (change mode)?

chmod, short for change mode, is a command used in Unix/Linux systems to change the permissions or access rights of files and directories. It is an essential command in managing file permissions and security in these operating systems.

Every file and directory in Unix/Linux has three types of permissions associated with it – read (r), write (w), and execute (x). These permissions are set for three different user types – the owner of the file or directory, the group it belongs to, and other users.

The chmod command allows users to change these permissions by using numeric or symbolic mode.

Numeric Mode

In numeric mode, the chmod command represents permissions using a three-digit number. Each digit represents the permissions for each user type, in the order of owner, group, and other users.

The numeric values used in the chmod command are:

  • 0: No permission
  • 1: Execute permission
  • 2: Write permission
  • 3: Write and execute permissions
  • 4: Read permission
  • 5: Read and execute permissions
  • 6: Read and write permissions
  • 7: Read, write, and execute permissions

For example, chmod 755 filename sets the owner to have read, write, and execute permissions, while the group and other users have read and execute permissions only.

Symbolic Mode

In symbolic mode, the chmod command uses symbols and operators to represent permissions. The symbols used are:

  • r: Read permission
  • w: Write permission
  • x: Execute permission

The operators used in symbolic mode are:

  • +: Adds a permission
  • -: Removes a permission
  • =: Assigns permissions explicitly

For example, chmod u+x filename adds execute permission for the owner, while chmod go-rw filename removes read and write permissions for the group and other users.

It is important to use the chmod command carefully and responsibly, as incorrect permissions can lead to security vulnerabilities or limited access to files and directories.

By utilizing the chmod command, users can effectively manage file permissions and enhance the security and accessibility of their Unix/Linux systems.

Reference Articles

Reference Articles

Read also

[Google Chrome] The definitive solution for right-click translations that no longer come up.