Understanding File Permissions and Ownership in Linux
Introduction
File permissions in Linux determine who can read, write, or execute files. Understanding this concept is crucial for system security and user management.
Step 1: View File Permissions
Use the ls -l command to list files with their permissions.
ls -l
➡️ Example output:
-rw-r--r-- 1 user group 1234 Sep 18 file.txt
Step 2: Permission Breakdown
r = read
w = write
x = execute
In -rw-r--r--:
First part (rw-) → owner permissions
Second part (r--) → group permissions
Third part (r--) → others permissions
Step 3: Change Permissions with chmod
To add execute permission for the owner:
chmod u+x file.txt
➡️ u = user (owner), g = group, o = others, a = all.
Step 4: Change Ownership with chown
To change the owner of a file:
sudo chown newuser file.txt
➡️ To change both owner and group:
sudo chown newuser:newgroup file.txt
Step 5: Numeric Permissions
You can also set permissions using numbers (octal mode):
4 = read
2 = write
1 = execute
Example:
chmod 755 script.sh
➡️ 755 means: owner = read/write/execute, group = read/execute, others = read/execute.
Conclusion
Mastering file permissions and ownership is key to maintaining a secure Linux environment. In the next post, we’ll dive into process management.

Comments
Post a Comment