Linux file permissions can be confusing, but they don't have to be. This quick guide breaks down the rwx system—read, write, execute—for users, groups, and others in simple, visual terms.
What Does rwx Mean?
- r (read): View file contents or list directory.
- w (write): Modify file or add/remove files in directory.
- x (execute): Run a program or enter a directory.
Permissions are grouped into three sets:
- User (owner) – the file's owner.
- Group – users in the file's group.
- Others – everyone else.
How to View Permissions
Use ls -l in the terminal. You'll see something like: -rwxr-xr--. The first character is the file type (- for file, d for directory), followed by three triples of rwx.
Changing Permissions with chmod
- Symbolic mode:
chmod u+x file.shadds execute for the user. - Numeric mode:
chmod 755 file.shsets rwx for owner, r-x for group/others.
Pro Tips
- Directories need execute to be accessible.
- Use
chmod -Rwith caution on directories. - Always follow the principle of least privilege.
Master these basics to secure your Linux system and boost your command-line skills!