πŸ“‘Linux/Unix: Permissions & Ownership
Estimated reading: 3 minutes 105 views

πŸ” Linux/Unix: File Permissions & ls -l Explained – Read, Write & Execute Control

🧲 Introduction – Why Learn Linux/Unix File Permissions?

Every file and directory in Linux/Unix has a set of permissions that determine who can read, write, or execute them. Understanding file permissions is critical for system security, collaboration, and automation. The ls -l command gives a clear view of permissions, ownership, and moreβ€”all in one place.

🎯 In this guide, you’ll learn:

  • How to read and understand file permission strings using ls -l
  • What read, write, and execute mean for users, groups, and others
  • Permission breakdowns for files vs. directories
  • Real examples of permission control

πŸ“‚ Understanding ls -l Output

πŸ§ͺ Example:

ls -l

πŸ’‘ Output:

-rw-r--r-- 1 user group  1024 Jun 15 12:00 notes.txt

Breakdown:

PartMeaning
-Type (- = file, d = directory, l = link)
rw-Owner permissions (read, write)
r--Group permissions (read only)
r--Others permissions (read only)
1Number of hard links
userFile owner
groupGroup owner
1024File size in bytes
Jun 15 12:00Last modification date/time
notes.txtFile name

πŸ” Permission Types

SymbolMeaningApplies to
rRead (view content)File/Directory
wWrite (edit/remove)File/Directory
xExecute (run file or access dir)File/Directory

For Directories:

  • r β†’ List contents
  • w β†’ Create/delete files
  • x β†’ Enter the directory

πŸ‘₯ User Classes

ClassSymbolDescription
OwneruUser who owns the file
GroupgGroup associated with the file
OthersoAll other users
AllaEveryone (u + g + o)

πŸ”’ Numeric (Octal) Representation of Permissions

rwxBinaryOctal
rwx1117
rw-1106
r-x1015
r–1004
-wx0113
-w-0102
–x0011
0000

πŸ§ͺ Example:

-rwxr-xr--  β†’  Owner=7, Group=5, Others=4  β†’  754

πŸ› οΈ Modify Permissions with chmod

βœ… Syntax:

chmod [permissions] filename

πŸ§ͺ Examples:

chmod 755 script.sh           # rwxr-xr-x
chmod u+x file.sh             # Add execute to owner
chmod go-w file.txt           # Remove write from group and others

πŸ‘‘ View and Change Ownership

View Ownership:

ls -l

Change Owner:

sudo chown user file.txt

Change Group:

sudo chgrp groupname file.txt

πŸ“Œ Summary – Recap & Next Steps

Mastering Linux file permissions helps protect sensitive data, control access levels, and prevent accidental changes. Using ls -l gives you full visibility into permissions, ownership, and file metadata.

πŸ” Key Takeaways:

  • Use ls -l to check file types, permissions, owners, and size.
  • Permissions are divided among user, group, and others with r, w, and x.
  • Numeric (chmod 755) and symbolic (chmod u+x) modes both work.
  • Use chown and chgrp to manage file ownerships.

❓ FAQs

❓ What does drwxr-xr-x mean?
βœ… It’s a directory (d) with permissions: owner (read/write/execute), group (read/execute), others (read/execute).

❓ How do I make a file executable?
βœ… Use:

chmod +x filename.sh

❓ How can I change file permissions recursively?
βœ… Use:

chmod -R 755 myfolder/

❓ What’s the safest permission for scripts?
βœ… Use chmod 755 to allow execute by all, but write only by the owner.

❓ Can a group member modify a file?
βœ… Only if the group has write permission (w), and the user belongs to that group.


Share Now :
Share

πŸ”΅ Linux/Unix: File Permissions / ls -l

Or Copy Link

CONTENTS
Scroll to Top