LESSON 22 · BEGINNER5 min read

Users, Permissions, Processes, and Services

Understand Linux identity and privilege, read file modes, investigate running processes, and review the services that start at boot.

OWASP Top 10 · MITRE ATT&CK · NIST CSF 2.0Free to readModule 5 of 14
YOUR NEXT SMALL WINS

By the end, you’ll be able to…

  • Read and calculate Linux file permissions and special permission bits.
  • Explain users, groups, sudo, and the principle of least privilege on Linux.
  • Investigate processes, listening sockets, and systemd services.
  • Use logs and service state to diagnose a suspicious or failing host.

01Identity, Groups, and Privilege

Linux identifies users by a numeric user ID (UID) and groups by a group ID (GID). The /etc/passwd file maps usernames to UIDs, home directories, and login shells. /etc/group maps groups to members. /etc/shadow stores password hashes and is readable only by root. A service account usually has no login shell and no password because it exists to run a process, not to log in.

The root account, UID 0, bypasses ordinary permission checks. sudo lets an authorised user run a command as another user, usually root, according to rules in /etc/sudoers and files under /etc/sudoers.d. sudo is not a magic safety switch. A misconfigured rule such as 'analyst ALL=(ALL) NOPASSWD: ALL' gives away full administrative control without a password.

Least privilege on Linux means separate accounts for separate jobs, no shared logins, no unnecessary sudo rights, and no service running as root when a dedicated account will do. Review accounts regularly. Remove stale accounts, lock unused ones, and investigate unexpected UID 0 accounts or group memberships in privileged groups such as sudo, wheel, docker, and adm.

identity-audit.shShell
idgetent passwd | awk -F: '$3 == 0 {print $1, $3, $7}'getent group sudosudo -llastlog | headlast -n 10awk -F: '($2 == "" || $2 == "!") {print $1, $2}' /etc/shadow 2>/dev/null || true
Outputstdout
uid=1000(analyst) gid=1000(analyst) groups=1000(analyst),27(sudo)
root 0 /bin/bash
sudo:x:27:analyst
User analyst may run the following commands:
    (ALL : ALL) ALL

02File Modes and Special Bits

Every file has an owner, a group, and a set of permission bits. The r, w, and x bits mean read, write, and execute. They appear three times for owner, group, and others. A mode such as 640 means the owner can read and write, the group can read, and others have no access. Directories use the execute bit to mean 'traverse' or 'enter'.

chmod changes permissions, chown changes ownership, and umask controls the default permissions for newly created files. Numeric modes are compact but symbolic modes are often clearer during review: chmod g-w file removes group write, while chmod o-rwx file removes all access for others. Never make a file world-writable to 'fix' a permission problem. Find the correct owner or group instead.

Three special bits deserve attention. setuid on an executable makes it run with the file owner's privileges; setgid on a directory makes new files inherit the directory's group; the sticky bit on a shared directory prevents users from deleting each other's files. A setuid root binary is a high-value target. Audit unexpected setuid and setgid files, and never install one you do not trust.

permission-review.shShell
ls -l /etc/passwd /etc/shadow /usr/bin/passwdstat -c "%A %a %U:%G %n" /etc/ssh/sshd_config# Find setuid and setgid files.find / -xdev -type f \( -perm -4000 -o -perm -2000 \) -print 2>/dev/null# Find files writable by everyone.find / -xdev -type f -perm -0002 -print 2>/dev/null# Show the current umask.umask
Outputstdout
-rw-r--r-- 1 root root  3124 /etc/passwd
-rw-r----- 1 root shadow 1892 /etc/shadow
-rwsr-xr-x 1 root root 68208 /usr/bin/passwd
-rw------- root:root /etc/ssh/sshd_config
/usr/bin/passwd
/usr/bin/sudo
0022

03Processes, Signals, and Services

A process is a running program with an ID, an owner, a parent, memory, open files, and a current state. ps shows a snapshot; top or htop shows live resource use; pgrep finds processes by name; pstree shows parent-child relationships. The /proc filesystem exposes process details such as command line, environment, open file descriptors, and network sockets.

Signals are asynchronous notifications. SIGTERM politely asks a process to stop, SIGKILL forces it to stop, SIGHUP often tells a daemon to reload configuration, and SIGSTOP pauses it. Prefer SIGTERM first because it allows cleanup. A process that ignores SIGTERM may need SIGKILL, but killing the wrong process can take down a service or corrupt data.

systemd manages services on most modern Linux distributions. systemctl start, stop, restart, enable, and status control units. journalctl reads the systemd journal. A service can be running but unhealthy, enabled but failed, or masked to prevent it from starting. Investigate the unit file, the process, the listening socket, and the logs together. A port being open is not proof that the intended application is responding.

process-and-service-review.shShell
ps aux --sort=-%cpu | headpgrep -a sshdpstree -p 1sudo ss -tulpnsystemctl status ssh --no-pagersystemctl list-units --type=service --state=running --no-pagersudo journalctl -u ssh --since "24 hours ago" --no-pager | tail -40sudo lsof -i :22
Outputstdout
USER       PID %CPU %MEM COMMAND
root         1  0.0  0.1 /sbin/init
root       842  0.0  0.0 sshd: /usr/sbin/sshd -D
sshd      1180  0.0  0.0 sshd: analyst [priv]
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
● ssh.service - OpenBSD Secure Shell server
     Active: active (running)

04Logs Tell the Story of a Host

Linux logs authentication events, kernel messages, service output, scheduled jobs, and application activity. The exact paths vary by distribution. Debian and Ubuntu commonly use /var/log/auth.log and /var/log/syslog, while Red Hat-family systems use /var/log/secure and /var/log/messages. systemd systems centralise service logs in the journal.

A good investigation correlates at least three sources: authentication logs for who logged in, process or service logs for what ran, and network logs for where the host communicated. Timestamps may be in different time zones. Log rotation may have removed the oldest entries. Attackers with root can alter logs, so endpoint telemetry and remote log collection matter.

Start with a narrow time window around the event. List successful and failed logins, new users, sudo commands, service starts, cron jobs, and outbound connections. Then widen the window if the evidence suggests earlier access. Write down what you checked, what you found, and what you could not determine. Negative evidence is still evidence when it is bounded and honest.

LET IT CLICK

The ideas worth keeping.

  • Linux identity is numeric: UID 0 is root, groups grant additional access, and sudo rules define delegated privilege.
  • Read permissions as owner, group, and others; audit setuid, setgid, and world-writable files.
  • Correlate process, service, socket, and log evidence before concluding what is running.
  • Logs are essential but can be incomplete or altered; remote collection and endpoint telemetry strengthen the story.
TURN UNDERSTANDING INTO SOMETHING YOU CAN DO

Make it yours.

Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.

01

Exercise 1: Calculate permissions

A file has mode 0640 and is owned by root:shadow. Who can read it, who can write it, and who can execute it? Then state what mode you would use for a private SSH private key and why.

Explore a worked solution
one_possible_solution.mdCybersecurity
Owner root can read and write but not execute (6 = rw-). Group shadow can read but not write or execute (4 = r--). Other users have no permissions (0). A private SSH key should be 0600: only the owner can read and write, with no group or other access. The SSH client may refuse to use a key with looser permissions.

Permission triads map to owner, group, and others. Private keys must be readable only by the account that uses them.

02

Exercise 2: Investigate a listening service

A host is listening on 0.0.0.0:8080, but the expected application is not responding. List four checks you would perform and what each one tells you.

Explore a worked solution
one_possible_solution.mdCybersecurity
1. sudo ss -tulpn | grep 8080 identifies the process and confirms the bind address. 2. ps -fp <pid> and cat /proc/<pid>/cmdline show the command line and owner. 3. systemctl status <unit> and journalctl -u <unit> show whether the intended service is healthy and what it logged. 4. curl -v http://127.0.0.1:8080/health tests the application from the host itself, separating network-path problems from application problems. Also check firewall rules and whether a different process owns the port.

An open port only proves something is listening. Correlate the socket, process, service state, and application response.

A SMALL QUESTION. A USEFUL NEXT STEP.

What stayed with you?

Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.

A LITTLE ACTIVE RECALL0 / 4 answered
01What does mode 0644 allow for 'others'?
02What does the setuid bit do?
03Which signal politely asks a process to terminate and allows cleanup?
04Why should you avoid running every command as root?

Keep exploring.

The official references behind this lesson, when you want a second angle or the full details.

One lesson closer.

Reading is a start. Trying it yourself makes the connection.

Completion is saved in this browser. It records reading and hands-on practice progress.