Skip to content
Intermediate LinuxLesson 7 of 27 1 min read

Users and Permissions

Understand users, groups, and the chmod / chown commands.

On this page4 sections

Linux is a multi-user system. Every file belongs to a user and a group, and has three permission sets: owner, group, and everyone else.

Reading permissions

Run ls -l and you will see something like:

-rwxr-x---  1  alice  devs  1024  Jun 28  script.sh

Breakdown:

  • - - regular file (d for directory)
  • rwx - owner can read, write, execute
  • r-x - group can read and execute
  • --- - others have no access

Changing permissions

bash
chmod 755 script.sh      # owner: rwx, group+other: rx
chmod +x script.sh       # add execute for everyone
chmod 600 secret.txt     # owner only

The numbers are octal:

Digitrwx
7yesyesyes
6yesyes
5yesyes
4yes

Changing ownership

Permissions are only half the story - each file also has an owner (a user) and a group. chown changes one or both:

bash
chown alice script.sh          # give ownership to alice
chown alice:devs script.sh     # set owner AND group in one go
chown :devs script.sh          # change only the group

A common real pattern: put teammates in a shared group, then chown :teamgroup a project's files and chmod g+rwx the directory so everyone in that group can collaborate without being the file's owner.

Why this matters

Servers get hacked because files are too permissive. When in doubt, least privilege - grant only what is needed.

Challenge

Make script.sh executable for the owner only (no permissions for group or others).

Want to experiment first? Try things in the practice terminal (opens in a new tab), then enter the command that solves the task here.

Quiz

Lock in the concepts. Score at least 80% to mark the lesson complete.

0 of 3 answered

Done with this one?

Skipped the challenge? You can mark the lesson complete by hand.

Your notes

Kept on this browser only.