CHMOD, short for Change Mode, is a command-line utility in Unix-like operating systems, including Linux and macOS, used to set file system permissions. It was developed as part of the original Unix system in the 1970s. CHMOD is used in terminal shells and scripts to control access to files and directories, specifying read, write, and execute permissions for the owner, group, and others. Users can access it via built-in command-line shells such as bash or zsh, with detailed documentation available in the system manual (man chmod) or at the GNU Coreutils CHMOD Manual.
CHMOD exists to enforce security and control over file access in multi-user environments. Its design philosophy emphasizes precision, simplicity, and flexibility, allowing users to explicitly define permissions using symbolic or octal notation. By standardizing access control, CHMOD ensures both safety and efficiency in system administration tasks.
CHMOD: Basic Symbolic Usage
Permissions can be set symbolically using letters r, w, and x for read, write, and execute, combined with u (user), g (group), and o (others).
# give the owner read, write, execute permissions
chmod u+rwx script.sh
# add execute permission for group
chmod g+x script.sh
# remove write permission for others
chmod o-w script.shSymbolic notation allows fine-grained permission control without requiring numeric values, providing clarity when managing multiple users and groups. This is similar to permission management in Unix File Permissions or CHOWN.
CHMOD: Numeric (Octal) Usage
Permissions can also be set numerically using octal notation, where each digit represents the sum of read (4), write (2), and execute (1) for user, group, and others.
# set full permissions for owner, read/execute for group, none for others
chmod 750 script.sh
# read/write for owner, read for group and others
chmod 644 document.txtOctal notation provides a compact method for specifying multiple permissions at once and is widely used in scripts and automated deployments, similar to UMASK.
CHMOD: Recursive Operations
CHMOD supports recursion to apply permissions to directories and their contents using the -R flag.
# recursively set directories to read/write/execute for owner
chmod -R u+rwx /home/user/projectsRecursive usage simplifies large-scale permission changes, especially in project directories. This approach is commonly combined with CHOWN and Unix File Permissions to enforce consistent security settings across file hierarchies.
CHMOD is used in system administration, scripting, and deployment workflows across Unix-like systems to control file and directory access. Its flexibility and compatibility make it an essential tool for managing multi-user environments while ensuring system security.