Chmod With Symbols
Part of the Fundamentals section of Coddy's Terminal journey — lesson 56 of 82.
Symbolic mode offers a more intuitive way to use chmod. Instead of calculating numbers, you specify exactly what you want to change using letters and symbols.
The format is: chmod WHO OPERATOR PERMISSION file
For WHO, use: u (user/owner), g (group), o (others), or a (all three).
For OPERATOR, use: + (add), - (remove), or = (set exactly).
For PERMISSION, use: r (read), w (write), or x (execute).
Here are some examples:
# Add execute permission for the owner
chmod u+x script.sh# Remove write permission from others
chmod o-w document.txt# Give group read and execute permissions
chmod g+rx program.sh# Set exact permissions for all users
chmod a=r readme.txtThe symbolic method shines when you want to modify a single permission without affecting the others. With chmod u+x, you add execute for the owner while keeping all other permissions unchanged. This is often more convenient than recalculating the entire numeric value.
Challenge
EasyYou have a script file setup.sh that currently doesn't have execute permission. Use chmod with symbolic mode to add execute permission for the owner only.
Use the symbolic format with u for user/owner, + to add permission, and x for execute.
After modifying the permissions, use ls -l setup.sh to verify the change.
Your output should show the permission string -rwxr--r-- for the file, indicating the owner now has execute permission while group and others retain only read access.
Hint: Run
chmod u+x setup.shto add execute permission for the owner, thenls -l setup.shto display the updated permissions.
Cheat sheet
Symbolic mode for chmod uses letters and symbols to modify permissions:
Format: chmod WHO OPERATOR PERMISSION file
WHO:
u- user/ownerg- groupo- othersa- all three
OPERATOR:
+- add permission-- remove permission=- set exact permission
PERMISSION:
r- readw- writex- execute
Examples:
# Add execute permission for the owner
chmod u+x script.sh
# Remove write permission from others
chmod o-w document.txt
# Give group read and execute permissions
chmod g+rx program.sh
# Set exact permissions for all users
chmod a=r readme.txtSymbolic mode is useful for modifying specific permissions without affecting others.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Directories
Create A DirectoryCopy A DirectoryMove And Rename A DirectoryDelete A DirectoryRecap - Directory Operations7File Content
Head And TailWord CountSort CommandUnique CommandGrep BasicsGrep With FlagsRecap - Text Detective2Navigation
Print Working DirectoryList FilesChange DirectoryAbsolute vs Relative PathsHome And Root DirectoryRecap - Find Your Way8Redirection
Standard OutputOverwrite To A FileAppend To A FileStandard InputStandard ErrorRecap - Log Builder11Permissions
Understanding PermissionsReading PermissionsChmod With NumbersChmod With SymbolsFile OwnershipRecap - Lock It Down6Wildcards And Patterns
The Star WildcardThe Question Mark WildcardBracket WildcardsCombining WildcardsRecap - Selective Operations9Piping
What Is A PipeChaining Two CommandsChaining Multiple CommandsPipe With GrepRecap - Data Pipeline