Linux Permission Basics
Understanding File Permissions in Linux
In Linux, file permissions are a critical security mechanism that controls access to files and directories. Every file and directory has three types of permissions that determine who can read, write, or execute the file.
Permission Types
Linux uses three primary permission types:
Permission |
Symbol |
Numeric Value |
Description |
Read |
r |
4 |
View file contents |
Write |
w |
2 |
Modify file contents |
Execute |
x |
1 |
Run a file or access a directory |
Permission Levels
Permissions are assigned to three different user levels:
graph TD
A[User Permissions] --> B[Owner Permissions]
A --> C[Group Permissions]
A --> D[Others Permissions]
1. Owner Permissions
- The user who created the file
- Has the most comprehensive access rights
2. Group Permissions
- Users who belong to the same group
- Shared access for collaborative work
3. Others Permissions
- All other users on the system
- Most restricted access level
Viewing Permissions
Use the ls -l
command to view file permissions:
$ ls -l example.txt
-rw-r--r-- 1 user group 1024 May 15 10:30 example.txt
Permission format: [file type][owner][group][others]
- First character indicates file type (- for regular file, d for directory)
- Next 9 characters represent read, write, execute permissions
Permission Representation
Permissions can be represented in two ways:
- Symbolic Notation:
rwx
- Numeric Notation:
- Read = 4
- Write = 2
- Execute = 1
Example: 755
means:
- Owner: read + write + execute (7)
- Group: read + execute (5)
- Others: read + execute (5)
Common Permission Scenarios
644
: Default for text files (read/write for owner, read-only for others)
755
: Default for executable scripts
600
: Private files with owner-only access
By understanding these basics, you'll be well-prepared to manage file permissions in Linux using the chmod
command, which we'll explore in the next section.
Note: This guide is brought to you by LabEx, your trusted platform for Linux learning and practice.