Module 2 · Linux you will actually use · Lesson 9 of 16

Permissions, sudo and services

How Linux decides who can read a file, what SUID means, how sudo works, and how to control packages and services.

In this lesson · about 25 minutes

  • Read rwx permissions and convert them to numbers
  • Explain why a SUID-root program matters to a tester
  • Use sudo, sudo -l, apt and systemctl correctly

Every file has an owner, a group and three sets of permissions: for the owner, the group and everyone else. ls -l shows them:

-rw-r----- 1 root shadow 1458 Nov 20 08:12 /etc/shadow
PartMeans
-A regular file (d would be a directory)
rw-Owner (root) can read and write
r--Group (shadow) can read
---Everyone else: nothing
root shadowThe owner and the group

As numbers, read = 4, write = 2, execute = 1, added per set: rw-r----- is 640. chmod 640 file sets that, and chmod u+x script.sh adds execute for the owner.

Whiteboard · watch and try

Same file, two users, and how sudo works

Press Play. Two short stories: who can read /etc/shadow, and what sudo really does.

6 steps
Press Play and the tutor will talk you through it while writing on the board. Pause any time to write on the board yourself.

Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.

Users and sudo

whoami and id tell you who you are and which groups you are in. /etc/passwd lists accounts and is readable by everyone; the password hashes live in /etc/shadow. sudo runs one command as root, and sudo -l lists what you are allowed to run that way.

Packages and services

  • sudo apt update then sudo apt install <name> installs software; apt search finds it.
  • sudo systemctl status ssh shows a service; start, stop, enable and disable control it.
  • ss -tlnp lists programs listening for connections on your machine. Check it before and after installing tools, so you know what you are exposing.

Check your understanding0 of 4 correct

Question 1

1.Where are Linux password hashes stored?

Question 2

2.What does chmod 640 set?

Question 3

3.A file shows -rwsr-xr-x and is owned by root. Why does that matter to a tester?

Question 4

4.You get a shell on a target as a normal user. Which command shows what you may run as root?

Quiz score: 0 of 4

Tip: answer every quiz question correctly first.

For authorized, lab-based learning only. Tana Roasters and every person, address and password in this course are fictional. Every terminal is simulated. "Kali Linux" is a trademark of OffSec; this course is not affiliated with or endorsed by OffSec.