Linux CLI 17 ๐ง Owner, group member and the rest
Every file and directory in Linux has permissions that control who can do what. Understanding permissions is essential for security and collaboration.
Reading ls -l Output
$ ls -l
-rw-r--r-- 1 kronos users 1024 Jan 15 10:30 1.txt
drwxr-xr-x 2 kronos users 4096 Jan 15 10:30 d2
Let’s break down each column:
-rw-r--r-- 1 kronos users 1024 Jan 15 10:30 1.txt
โ โ โ โ โ โ โ
โ โ โ โ โ โ โโโ Filename
โ โ โ โ โ โโโโโโโโโโโโโโโ Last modification date
โ โ โ โ โโโโโโโโโโโโโโโโโโโโ File size (bytes)
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ Group
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Owner
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Hard links count
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ File type + permissions
File Type โ The First Character
| Character | Type | Example |
|---|---|---|
- | Regular file | -rw-r--r-- |
d | Directory | drwxr-xr-x |
l | Symbolic link | lrwxrwxrwx |
c | Character device | crw-rw-rw- |
b | Block device | brw-rw---- |
p | Pipe (FIFO) | prw-r--r-- |
s | Socket | srwxrwxrwx |
Examples:
-rw-r--r-- regular file
drwxr-xr-x directory
lrwxrwxrwx symbolic link
crw-rw-rw- character device (e.g., /dev/tty)
brw-rw---- block device (e.g., /dev/sda)
prw-r--r-- named pipe
srwxrwxrwx socket
The Three Permission Groups
The next 9 characters (positions 2โ10) are divided into three groups of three:
- rw- r-- r--
โ โ โ โ
โ โ โ โโโ Permissions for the "rest" (others)
โ โ โโโโโโโโ Permissions for group members
โ โโโโโโโโโโโโโ Permissions for the owner
โโโโโโโโโโโโโโโโ File type
| Group | Characters | Applies To |
|---|---|---|
| 1st group | 2, 3, 4 | Owner’s permissions |
| 2nd group | 5, 6, 7 | Group members’ permissions |
| 3rd group | 8, 9, 10 | Everyone else (the rest) |
The Three Permission Types
Within each group of three:
r w x
โ โ โ
โ โ โโโ x = execute permission
โ โโโโโ w = write permission
โโโโโโโ r = read permission
| Position | Symbol | Meaning |
|---|---|---|
| 1st | r | Read permission |
| 2nd | w | Write permission |
| 3rd | x | Execute permission |
| Missing | - | No permission |
What Each Permission Means
| Permission | On a File | On a Directory |
|---|---|---|
| r (read) | View file contents | List directory contents (ls) |
| w (write) | Modify file contents | Create/delete files in directory |
| x (execute) | Run file as program | Enter the directory (cd) |
Important:
xon a directory means you can enter it withcd. Withoutx, you can’tcdinto it โ even if you haver.
Example Analysis
Example 1: 1.txt โ A Regular File
-rw-r--r-- 1 kronos users 1024 Jan 15 10:30 1.txt
Breaking it down:
- rw- r-- r--
โ โ โ โ
โ โ โ โโโ Rest: read only
โ โ โโโโโโโโ Group: read only
โ โโโโโโโโโโโโโ Owner: read and write
โโโโโโโโโโโโโโโโ Regular file
| Who | Permissions | Meaning |
|---|---|---|
| Owner | rw- | Can read and write (modify) |
| Group | r-- | Can only read |
| Rest | r-- | Can only read |
Owner: kronos โ the user who owns the file
Group: users โ the group the file belongs to
What each can do:
- kronos (owner): Read the file, edit it, but cannot execute it
- Group members: Only read the file
- Others: Only read the file
Example 2: d2 โ A Directory
drwxr-xr-x 2 kronos users 4096 Jan 15 10:30 d2
Breaking it down:
d rwx r-x r-x
โ โ โ โ
โ โ โ โโโ Rest: read and enter
โ โ โโโโโโโโ Group: read and enter
โ โโโโโโโโโโโโโ Owner: read, write, and enter
โโโโโโโโโโโโโโโโ Directory
| Who | Permissions | Meaning |
|---|---|---|
| Owner | rwx | Can list, modify (create/delete), and enter |
| Group | r-x | Can list and enter, but not modify |
| Rest | r-x | Can list and enter, but not modify |
What each can do:
- kronos (owner): Full control โ
cdin,ls, create/delete files - Group members: Enter the directory, see contents, but can’t add/remove files
- Others: Same as group โ can look but not touch
Who Owns What?
| Term | Meaning | Example |
|---|---|---|
| Owner | The user who owns the file | kronos |
| Group | The group that owns the file | users |
| Rest | Everyone else on the system | โ |
Visual:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ System โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโ
โ โ Owner โ โ Group โ โ Rest โโ
โ โ kronos โ โ users โ โ Others โโ
โ โ โ โ โ โ โโ
โ โ rw- (rwx) โ โ r-- (r-x) โ โ r-- โโ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Common Permission Combinations
| Permissions | Symbolic | Octal | Meaning |
|---|---|---|---|
rwxrwxrwx | 777 | Everyone: full access | |
rwxr-xr-x | 755 | Owner: full; others: read+execute | |
rw-r--r-- | 644 | Owner: read+write; others: read | |
rwx------ | 700 | Owner only: full access | |
rw------- | 600 | Owner only: read+write | |
rwxr-x--- | 750 | Owner: full; group: read+execute | |
rw-rw-r-- | 664 | Owner+group: read+write; others: read | |
rwxrwx--- | 770 | Owner+group: full; others: none |
Octal (Numeric) Permissions
Each permission type has a numeric value:
| Permission | Value |
|---|---|
r (read) | 4 |
w (write) | 2 |
x (execute) | 1 |
- (none) | 0 |
Add them up per group:
| Permission | Calculation | Octal |
|---|---|---|
rwx | 4 + 2 + 1 | 7 |
rw- | 4 + 2 + 0 | 6 |
r-x | 4 + 0 + 1 | 5 |
r-- | 4 + 0 + 0 | 4 |
-wx | 0 + 2 + 1 | 3 |
-w- | 0 + 2 + 0 | 2 |
--x | 0 + 0 + 1 | 1 |
--- | 0 + 0 + 0 | 0 |
Example:
-rw-r--r-- โ 6 4 4 โ 644
drwxr-xr-x โ 7 5 5 โ 755
-rwxr-x--- โ 7 5 0 โ 750
Complete Example Session
# ============================================
# PART 1: READING LS -L OUTPUT
# ============================================
$ ls -l
-rw-r--r-- 1 kronos users 1024 Jan 15 10:30 1.txt
drwxr-xr-x 2 kronos users 4096 Jan 15 10:30 d2
lrwxrwxrwx 1 kronos users 10 Jan 15 10:30 link -> /etc
crw-rw-rw- 1 root root 1, 3 Jan 15 10:30 /dev/null
brw-rw---- 1 root disk 8, 0 Jan 15 10:30 /dev/sda
# ============================================
# PART 2: ANALYZING PERMISSIONS
# ============================================
# File: 1.txt โ regular file
# Owner: kronos โ read, write
# Group: users โ read
# Rest: read
-rw-r--r-- 1 kronos users 1024 Jan 15 10:30 1.txt
# Directory: d2
# Owner: kronos โ read, write, enter
# Group: users โ read, enter
# Rest: read, enter
drwxr-xr-x 2 kronos users 4096 Jan 15 10:30 d2
# ============================================
# PART 3: PERMISSION MEANING
# ============================================
# For 1.txt:
# Owner kronos: can read and write
# Group users: can read only
# Others: can read only
# Nobody can execute
# For d2 (directory):
# Owner kronos: can cd in, ls, create/delete files
# Group users: can cd in, ls, but not create/delete
# Others: same as group
# ============================================
# PART 4: PRACTICAL EXAMPLES
# ============================================
# A private file โ only owner can read/write
-rw------- 1 kronos users 1024 Jan 15 10:30 private.txt
# A shared file โ owner and group can read/write
-rw-rw-r-- 1 kronos developers 1024 Jan 15 10:30 shared.txt
# An executable script
-rwxr-xr-x 1 kronos users 2048 Jan 15 10:30 script.sh
# A web file โ readable by everyone
-rw-r--r-- 1 root root 4096 Jan 15 10:30 /var/www/index.html
# A secret directory โ only owner
drwx------ 2 kronos users 4096 Jan 15 10:30 .ssh
Quick Reference
File Types (First Character)
| Symbol | Type |
|---|---|
- | Regular file |
d | Directory |
l | Symbolic link |
c | Character device |
b | Block device |
p | Pipe |
s | Socket |
Permission Groups
| Group | Positions | Applies To |
|---|---|---|
| 1st | 2, 3, 4 | Owner |
| 2nd | 5, 6, 7 | Group members |
| 3rd | 8, 9, 10 | The rest (others) |
Permission Types
| Symbol | Name | Value | On File | On Directory |
|---|---|---|---|---|
r | Read | 4 | View contents | List contents |
w | Write | 2 | Modify contents | Create/delete files |
x | Execute | 1 | Run program | Enter with cd |
- | None | 0 | No access | No access |
Common Octal Values
| Octal | Symbolic | Meaning |
|---|---|---|
644 | rw-r--r-- | Owner: rw; others: r |
755 | rwxr-xr-x | Owner: rwx; others: rx |
700 | rwx------ | Owner only |
600 | rw------- | Owner only (files) |
664 | rw-rw-r-- | Owner+group: rw |
777 | rwxrwxrwx | Everyone: rwx (rarely needed) |
Best Practices
โ Do This:
# Files โ 644 (rw-r--r--) is the safe default
chmod 644 file.txt
# Directories โ 755 (rwxr-xr-x) is the safe default
chmod 755 mydir
# Private files โ 600 (rw-------) for sensitive data
chmod 600 ~/.ssh/id_rsa
chmod 600 .env
# Private directories โ 700 (rwx------)
chmod 700 ~/.ssh
# Executables โ 755 (rwxr-xr-x)
chmod 755 script.sh
โ Don’t Do This:
# Don't give everyone everything
chmod 777 file.txt # โ Security risk!
chmod -R 777 /var/www # โ Very dangerous!
# Don't remove execute from directories
chmod -x mydir # โ Can't cd into it
# Don't make scripts non-executable and expect them to run
chmod 644 script.sh
./script.sh # โ Permission denied
chmod +x script.sh # โ
Fix
# Don't share sensitive files with group/others
chmod 644 ~/.ssh/id_rsa # โ Private key should be 600!
Common Pitfalls
| Pitfall | Problem | Solution |
|---|---|---|
x on directory | Needed to cd in | Keep x on directories |
Files without r | Can’t read | Add r |
Scripts without x | Can’t execute | chmod +x script.sh |
| Everyone can read | Security risk | Use 600 for private |
| Confusing owner/group | Wrong access | Check with ls -l |
777 on web files | Wide open to attacks | Use 644 for files, 755 for dirs |
Real-World Examples
1. Web Server Files
# HTML files โ owner write, all read
-rw-r--r-- 1 www-data www-data index.html
# Directories โ owner full, all enter+list
drwxr-xr-x 2 www-data www-data uploads/
# Never use 777!
2. SSH Keys
# Private key โ owner only
-rw------- 1 kronos users id_rsa
# Public key โ readable by all
-rw-r--r-- 1 kronos users id_rsa.pub
# SSH directory โ owner only
drwx------ 2 kronos users .ssh/
3. Shared Development
# Team-shared project โ group can write
drwxrwxr-x 5 alice developers project/
-rw-rw-r-- 1 alice developers README.md
4. System Binaries
# Executables โ everyone can run
-rwxr-xr-x 1 root root /usr/bin/ls
-rwxr-xr-x 1 root root /bin/bash
Visual: Permission Structure
-rw-r--r-- 1 kronos users 1024 Jan 15 10:30 1.txt
โโโฌโโโฌโโโฌโ
โ โ โ โโโ Rest: read only
โ โ โโโโโโ Group: read only
โ โโโโโโโโโ Owner: read + write
โโโโโโโโโโโ Regular file
POSITIONS:
1 2 3 4 5 6 7 8 9 10
โ โ โ โ โ โ โ โ โ โ
โ r w - r - - r - -
โ โโโโฌโโโ โโโโฌโโโ โโโโฌโโโ
โ โ โ โ
โ Owner Group Rest
โ
File type (- = file, d = directory)
Summary
| Concept | Description |
|---|---|
| First character | File type (-, d, l, etc.) |
| Positions 2โ4 | Owner permissions |
| Positions 5โ7 | Group permissions |
| Positions 8โ10 | Others permissions |
| r | Read (4) |
| w | Write (2) |
| x | Execute/Enter (1) |
| – | No permission (0) |
Key takeaways:
ls -lshows permissions in a 10-character string- First character = file type
- Next 9 characters = permissions in three groups (owner, group, rest)
- Each group has three permissions: read (r), write (w), execute (x)
xon a directory means you cancdinto itxon a file means you can run it as a program- Permission values are summed: r=4, w=2, x=1
- 644 = files (owner rw, others r)
- 755 = directories/executables (owner rwx, others rx)
- 600 = private files (owner only)
- 777 = dangerous โ avoid at all costs
Remember: Permissions control who can do what. The three groups โ owner, group, rest โ let you set fine-grained access. Use 644 for regular files, 755 for directories and executables, and 600 for sensitive data. Never use 777 โ it’s a security hole. And always think: who needs to read this? Who needs to write this? Who needs to execute this?
Stop using slow, ad-bloated tool sites! ๐คฎ
๐ Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
โ
Finance (Mortgage, Interest, Inflation)
โ
Tech (Base64, JSON, Dev Suite, IP)
โ
Health (BMI, BMR, TDEE)
โ
Productivity (Timer, Workspace, QR)
โก๏ธ Fast & Private
๐ No data leaves your device
๐ 100% Free
๐ Use it now: https://tools.kandz.me
๐ Bookmark itโyouโll need it later!