Understanding Permissions
Part of the Fundamentals section of Coddy's Terminal journey — lesson 53 of 82.
Every file and directory in Linux has permissions that control who can access it and what they can do with it. This security system prevents unauthorized users from reading your private files or modifying important system files.
Permissions are divided into three types of actions:
- Read (r) - View the contents of a file or list a directory's contents
- Write (w) - Modify a file or add/remove files in a directory
- Execute (x) - Run a file as a program or enter a directory
These permissions are assigned to three different categories of users:
- Owner - The user who created the file
- Group - A set of users who share access
- Others - Everyone else on the system
When you run ls -l, the first column shows the permission string. It looks something like -rwxr-xr--. This string tells you exactly who can do what with that file.
In the upcoming lessons, you'll learn how to read this string and modify permissions to control access to your files.
Challenge
EasyUse the ls -l command to view the detailed listing of files in your current directory. This will display the permission strings for each file and directory.
Examine the output and identify the permission string for script.sh. Notice how the first column shows a 10-character string that represents the file type and permissions.
Run the command:
ls -lIn the output, you'll see entries for both files and the documents directory. Pay attention to:
- The first character:
-for files,dfor directories - The next 9 characters showing read (r), write (w), and execute (x) permissions
- The owner and group names that appear after the permission string
This is your first look at how Linux displays permission information. In the next lessons, you'll learn to read these strings in detail and modify them.
Cheat sheet
Linux uses permissions to control file and directory access. There are three types of actions:
- Read (r) - View file contents or list directory contents
- Write (w) - Modify a file or add/remove files in a directory
- Execute (x) - Run a file as a program or enter a directory
Permissions are assigned to three categories of users:
- Owner - The user who created the file
- Group - A set of users who share access
- Others - Everyone else on the system
To view file permissions, use:
ls -lThe first column shows a 10-character permission string (e.g., -rwxr-xr--):
- First character:
-for files,dfor directories - Next 9 characters: read (r), write (w), and execute (x) permissions for owner, group, and others
Try it yourself
ls -lThis 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