UNIT 6: File Permissions

In Linux, you are not always the admin. Linux is a multi-user system, meaning many people can log into one server.

1. The Permission Model

Every file defines rules for three categories of people:

2. Read, Write, Execute

Each person can have a combination of three powers:

Letter Meaning Numeric Value
r READ (Open file) 4
w WRITE (Edit/Delete) 2
x EXECUTE (Run as program) 1

3. Numeric vs Symbolic Mode

To change permissions, we use the CHMOD command.

The Symbolic Way (Easy)

Use letters to add (+) or remove (-) permissions.

chmod u+x script.sh # Give User eXecute power
chmod g-w report.txt # Take Write power from Group

The Numeric Way (Pro)

We sum up the numbers 4, 2, and 1.

chmod 755 script.sh
# User=7 (ALL), Group=5 (Read+Exec), Others=5 (Read+Exec)

4. Ownership (CHOWN)

Sometimes you need to transfer a file to another user.

sudo chown bob:developers file.txt # Change owner to 'bob' and group to 'developers'

⚠️ SECURITY WARNING

Never set permissions to 777.

This gives Write and Execute access to the whole world. Hackers scan for 777 folders to upload viruses.

MISSION: Make the script start_server.sh executable for the User.

root@learnix:~#