How to Use Symbolic Mode with chmod
Welcome to this beginner-friendly Linux tutorial! Today, we’re learning how to change file permissions using symbolic mode with the chmod command.
Don't worry if you've never used chmod before. We’ll go step-by-step and use real examples so that it’s easy to follow.
🔍 What is chmod?
The chmod command is used to change the permissions of files and directories in Linux. Permissions decide who can read, write, or execute a file.
📘 Understanding Symbolic Mode
In symbolic mode, we use letters and symbols to describe permissions:
- u = user (owner)
- g = group
- o = others
- a = all (u+g+o)
Then we use operators:
- + = add permission
- - = remove permission
- = = set exact permission
- r = read
- w = write
- x = execute
🛠️ Let's Practice!
Step 1: Create a sample file
touch demo.txt
Step 2: Check the current permissions
ls -l demo.txt
-rw-r--r-- 1 user user 0 Jul 2 10:00 demo.txt
This means the owner can read and write, and group/others can only read.
🔧 Add execute permission for the user
chmod u+x demo.txt
Check again:
ls -l demo.txt
-rwxr--r-- 1 user user 0 Jul 2 10:00 demo.txt
Now the user has execute permission too.
➖ Remove read permission from others
chmod o-r demo.txt
ls -l demo.txt
-rwxr----- 1 user user 0 Jul 2 10:00 demo.txt
Others can no longer read the file.
🔄 Set group permissions to exactly read and execute
chmod g=rx demo.txt
ls -l demo.txt
-rwxr-x--- 1 user user 0 Jul 2 10:00 demo.txt
The group now has only read and execute permissions.
📌 Tip: Use a to affect all
chmod a-w demo.txt
ls -l demo.txt
-r-xr-xr-- 1 user user 0 Jul 2 10:00 demo.txt
This removes write permission from everyone.
🎉 Recap
chmodin symbolic mode is readable and intuitive- Use
u,g,o,ato choose who you're modifying - Use
+,-,=to set permissions - Use
r,w,xto define permission types
Practice with different combinations and try it out on both files and directories!
That’s it for this tutorial! 🚀
