Reading Permissions
Part of the Fundamentals section of Coddy's Terminal journey. Lesson 54 of 82.
Every line of ls -l starts with a 10-character permission string, for example:
-rw-r--r-- 1 user user 120 Jan 10 09:00 report.txt
drwxr-xr-x 2 user user 4096 Jan 10 09:00 projectsThe first character is the type: - for a regular file, d for a directory. The other nine are three groups of three:
- characters 2-4: the owner's permissions
- characters 5-7: the group's permissions
- characters 8-10: everyone else's (others)
In each group r means read, w write and x execute, and - means that permission is missing.
So rw-r--r-- lets the owner read and write, and everyone else only read. On a directory, x is what lets you enter it with cd.
Challenge
EasyUse ls -l to display the detailed file listing and examine the permission strings for each item.
Look at the output and identify the permissions for each file and directory. For each item, read the 10-character permission string and determine:
- Whether it's a file (
-) or directory (d) - What permissions the owner has (first group of three)
- What permissions the group has (second group of three)
- What permissions others have (third group of three)
Run the command:
ls -lIn the output, notice how backup.sh, report.txt, and config.cfg are regular files without execute permission (x). Compare these to the projects directory, which starts with d instead of - and includes execute permission, allowing users to enter the directory.
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 PipelinePractice on your own: Terminal playground