Chmod: Mastering File Permissions in Linux/Unix

COURSE LESSON

Continue your learning

Sign in to access your enrolled courses, or view the course details before enrolling.

Sign in View course

The chmod command in Linux/Unix is essential for managing file permissions. It stands for "change mode," allowing users to modify file or directory permissions.

Question: How does the chmod command work?

Chmod operates by using a three-component notation (user, group, others) followed by specific permissions. The syntax is:

chmod mode object, where object can be a file or directory.

Question: What are the basic permission types in chmod?

Permissions include:

  • r - read
  • w - write
  • x - execute (for files) or search (for directories)

These can be combined, such as rw, which stands for "read and write."

Question: What is the significance of the setuid bit?

The setuid bit allows a file to retain its owner's group when run by any user. For example, u+rwx means the file has all permissions in its own group.

Question: How does the setgid bit function?

The setgid bit ensures that new files in a directory inherit the directory's group. When set, new files created by users will belong to the directory's group.

Question: What is octal notation in chmod?

Octal notation assigns numeric values to permissions. Each digit represents different permissions:

  • 4 - read
  • 2 - write
  • 1 - execute

For example, 750 translates to rwx-r-x---, meaning all for the owner, read and execute for the group, and no permissions for others.

Question: What are ACLs in chmod?

ACLs (Access Control Lists) allow more specific permission settings. They can be added using chmod g:+rwx, providing additional flexibility beyond standard permissions.

Protocol/Artifact Reference

Man page for chmod (Linux)