Linux Permissions Basics
Understanding File Permissions in Linux
In Linux systems, file permissions are a critical aspect of system security and access control. Every file and directory has a set of permissions that determine who can read, write, or execute it.
Permission Types
Linux uses three primary permission types:
Permission |
Symbol |
Meaning |
Read |
r |
View file contents or list directory contents |
Write |
w |
Modify file or create/delete files in directory |
Execute |
x |
Run a file or access a directory |
Permission Levels
Permissions are set for three different user levels:
graph TD
A[User Permissions] --> B[Owner Permissions]
A --> C[Group Permissions]
A --> D[Others Permissions]
Permission Representation
Permissions are typically represented by a 3-digit octal number or symbolic notation:
- Octal: 755 (rwxr-xr-x)
- Symbolic: u=rwx,g=rx,o=rx
Basic Permission Commands
Viewing Permissions
ls -l filename
Changing Permissions
## Using chmod with octal
chmod 644 filename
## Using chmod with symbolic mode
chmod u+x filename
Permission Examples
## Grant read and execute permissions to owner and group
chmod 550 script.sh
## Remove write permissions for others
chmod o-w document.txt
Key Concepts
- Default permissions are controlled by umask
- Root user (superuser) can override all permissions
- Permissions are inherited when creating new files
LabEx Tip
When learning Linux permissions, practice is crucial. LabEx provides interactive environments to experiment with file permissions safely.