Chmod Command Cheatsheet: Understanding and Using File Permissions in Linux
Understanding and Using File Permissions in Linux
3 min read
One of the most important concepts in Linux is file permissions. It's what allows you to control who can read, write, and execute files and directories on your system. The
chmod (change mode) command is used to change the permissions of files and directories in Linux. It's a powerful command, and mastering it can be a bit tricky, especially for new Linux users. In this post, we'll go over a
chmod command cheatsheet with examples to help you understand and use file permissions in Linux.
chmod command is used to change the permissions of files and directories in Linux. It allows you to specify which users and groups can read, write, and execute a file or directory. The
chmod command works by changing the mode of a file or directory. The mode is a set of three octal (numeric) digits that specify the permissions for the file's owner, group, and others.
u: user (owner)
a: all (user, group, and other)
The basic syntax for
chmod [permission] [file or directory]
The first digit represents the owner's permissions
The second digit represents the group's permissions
The third digit represents the permissions for others
Each digit can have a value between 0 and 7
chmod 755 file.txt # grants owner read, write and execute permissions and read, execute permissions for group and other chmod 744 file.txt # grants owner read, write permissions and read permissions for group and other chmod 700 file.txt # grants owner read, write and execute permissions, no permissions for group and other
"+" adds a permission
"-" removes a permission
"=" sets the exact permissions
chmod u+rwx file.txt # grants owner read, write, and execute permissions chmod g+rw file.txt # grants group read and write permissions chmod o-r file.txt # removes read permissions for others chmod a=rw file.txt # sets read and write permissions for owner, group and others
In this post, we've covered the basics of the
chmod command, including its syntax, numeric notation, and symbolic notation. We've also provided examples of how to use the command to change file permissions in Linux. Remember that changing the permissions of important system files can cause issues with your system, so it's always recommended to back up any important files before modifying their permissions. With this cheat sheet, you should have a better understanding of how to use the
chmod command to manage file permissions in Linux.
Did you find this article valuable?
Support vishnu chilamakuru by becoming a sponsor. Any amount is appreciated!