githubEdit

binary-lockchmod and File Permissions

πŸ›‘οΈ chmod and File Permissions in Linux

chmod (change mode) is used to manage file permissions in Linux. Permissions control who can read, write, or execute a file or directory.


πŸ”€ Permission Types

Symbol
Meaning
Applies To

r

Read

View content

w

Write

Modify content

x

Execute

Run as program


πŸ‘₯ Permission Levels

Level
Description

u

User (owner)

g

Group

o

Others (everyone else)

a

All (user + group + others)


πŸ”’ Numeric (Octal) Representation

Each permission is a number:

Permission
Binary
Octal

r

100

4

w

010

2

x

001

1

Add values to combine permissions:

Access
Octal

r--

4

rw-

6

rwx

7

Example: chmod 755 file Means:

  • User: rwx (7)

  • Group: r-x (5)

  • Others: r-x (5)


πŸ”§ Common Usage

Set Permissions with Numbers

Add or Remove Permissions Symbolically

Recursive Change (for folders)


πŸ” View File Permissions

Use ls -l to list file permissions:

Example output:

  • First char: - (file) or d (directory)

  • Next 9: permissions for user, group, others


πŸ” Special Bits (Optional)

Bit
Octal
Description

setuid

4

Run as file owner's user ID

setgid

2

Run as group's ID / sticky group

sticky

1

Only owner can delete (e.g. /tmp)

Set using chmod:


βœ… Examples

Make script executable

Remove all access for others

Set folder and contents to rwxr-xr-x


Last updated