Linux `chmod` Command
Like many Linux commands, the typical syntax for chmod follows the pattern: first the command, then the options, and finally the file or directory to which it should be applied:
chmod [options] permissions /path/to/file
Before diving in, let’s review the types of Linux permissions and how they are set.
(If you’re not familiar with permissions, I recommend reading the linked article above first.)
Types of Permissions
There are three main permission types:
r– readw– writex– executes– execute with superuser privileges (special)
User Categories
You can set these permissions for three categories of users:
u– file owner (user)g– groupo– others (everyone else)
Actions
To modify permissions, you can use the symbols:
+– grant permission-– revoke permission
Examples:
u+x– allow execution for the ownerugo+x– allow execution for everyoneug+w– allow write permission for the owner and groupo-x– deny execution for othersugo+rwx– allow all permissions for everyone
Numeric Permissions
Permissions for a directory in Linux work the same way as for files.
When setting numeric permissions, specify the owner’s value first, then the group’s, and finally others’. For example:
744– full access for the owner, read-only for others755– full access for the owner, read & execute for others764– full for the owner, read & write for group, read-only for others777– full access for everyone
Each digit is independent; you choose exactly what’s needed.
Useful chmod Options
-c– display information about all changes made-f– suppress error messages-v– show detailed output--preserve-root– prevent recursive operations on the root/--reference– copy permissions from the specified file-R– apply changes recursively--version– display the utility version
Examples of Using chmod
chmod u+x file
chmod 766 file
ls -l file
chmod u-x file
🚀 Explore more guides on our blog 👉 blog.1it.pro
📧 Contact us: admin@1it.pro for expert IT guidance.
🌐 Explore more: Visit 1it.pro for top-tier IT solutions.