Users, Processes and Services

Video + 10 min read

sara
ali
web01
sshd, nginx, mysqld, bash ...
ssh login
ssh login
Users, Processes and Services
0:00 / 4:51 · Users, Processes and Services
Chapters and transcript

Users, Processes and Services One Linux server is shared by many users, and it runs many programs at the same time. Some accounts are real people. Others belong to services, like the web server. Knowing who is on a system, and what is running, is the base of both attack and defence. Let us find out how to see it.

Users and groups Every user has a name and a number, called a UID. The i d command shows who I am. My UID is one thousand and one, and I am in three groups. A group gives the same rights to many users. One of my groups is sudo. So next I type sudo dash l, to see what I am allowed to run as root. Here, everything.

root and sudo Now meet root. Root is the administrator account, with UID zero. It can read any file, change any setting and stop any program. You can spot it by the hash sign at the end of the prompt. Because root can do everything, attackers want root more than anything else. That is why logging in directly as root is risky.

root and sudo Instead, admins use sudo, often read as super user do. It runs one command with root rights. Ali asks to read the shadow file. Sudo checks that ali is allowed, and runs it. Sara is not in the sudo group, so her request is refused. And every use of sudo is logged, so admins can see who did what.

Processes A process is a program that is running right now. Each one has a number, called a PID, and runs as some user. P s a u x lists every process. The output is trimmed here. Look at the first column: root, the web server user, and ali. To stop a process, use kill with its PID. If it will not stop, kill dash nine forces it.

Quick check Quick check. A server is suddenly very slow. You suspect something unwanted, like a hidden miner, is eating the CPU. Which command gives you a live view of the busiest processes? Take a moment, then choose.

Services A service is a program that runs in the background all the time, like a web server or an SSH server. Most modern Linux systems manage services with systemd, using the system c t l command. System c t l status ssh shows the SSH service. It is loaded, enabled at boot, and active, running since Monday morning.

Services These commands need sudo. Start runs a service now, and stop stops it now. Restart stops it and starts it again. Enable makes it start automatically at boot, and disable means it will not. Every running service is something that could be attacked. So a good habit is to disable the services you do not need.

Logs Logs record what happened, and they are the first place a defender looks. Auth dot log holds logins, sudo use and SSH activity on Debian and Ubuntu. On Red Hat style systems, the same records are in secure. Syslog holds general system messages. And on systems with systemd, journal c t l reads the central log. Dash u ssh shows only the SSH service.

Logs Attackers know this too. After breaking in, they often try to delete or edit the logs to hide their tracks. So serious organisations send every log line to a separate log server as it happens. The attacker can wipe the local file, but the copy stays safe, and the defenders can still see what happened.

Updates Software has bugs, and some are security holes. When one is found, developers release a fix, called a patch, and the details often become public. An attacker tries a known flaw. The server that was never updated is open to it. The patched server is not. On Ubuntu, sudo apt update, then sudo apt upgrade, installs the newer versions. Regular patching is one of the simplest defences there is.

Putting it together Let us put it together. I d shows who you are, and sudo dash l shows what you may run as root. P s a u x and top show what is running. System c t l manages services, so disable what you do not need. Logs live in slash var slash log and journal c t l. And apt keeps software patched. Now read the lesson below, and answer the quiz.

A Linux system is shared by many users and runs many programs at the same time. Knowing who is on the system and what is running is the base of both attack and defence.

Users and groups

Every person or program that uses the system has a user account. Each user has a name and a number called a UID (user ID).

Users can belong to groups. A group is a simple way to give the same rights to many users. For example, everyone in the group developers might be allowed to edit files in /srv/app.

The id command shows who you are and which groups you are in:

ali@server:~$ id
uid=1001(ali) gid=1001(ali) groups=1001(ali),27(sudo),1005(developers)

Many accounts are not real people. Services like a web server often run as their own user, such as www-data. This limits the damage if that service is hacked.

root and sudo

root is the administrator account, with UID 0. Root can read any file, change any setting and stop any program. Because of this, attackers want root more than anything else.

Logging in directly as root is risky. Instead, admins use sudo (often read as "super user do") to run a single command with root rights:

ali@server:~$ sudo cat /etc/shadow
[sudo] password for ali:

Only users that the system allows, often members of the sudo or wheel group, can use it. Each use of sudo is logged, so admins can see who did what.

You can check what you are allowed to run with:

sudo -l

Attackers who gain a normal account almost always run sudo -l early. A rule that lets a user run a powerful program as root can be a direct path to full control.

Processes

A process is a program that is currently running. Each process has a number called a PID (process ID) and runs as some user.

ps aux lists every process on the system:

ali@server:~$ ps aux
USER       PID %CPU %MEM COMMAND
root         1  0.0  0.1 /sbin/init
root       812  0.0  0.2 /usr/sbin/sshd -D
www-data  1450  0.3  1.1 nginx: worker process
ali       2210  0.0  0.1 bash

(The real output has more columns. They are trimmed here to keep it simple.)

top shows a live view of processes, sorted by how much CPU they use. Press q to quit. It is useful when a server is suddenly slow, which can be a sign of something unwanted, such as a hidden cryptocurrency miner.

Stopping a process

Use kill with the PID to ask a process to stop:

kill 2210

If it does not stop, kill -9 2210 forces it to end straight away. You can only kill your own processes unless you use sudo.

Services

A service is a program that runs in the background all the time, such as a web server or SSH server. Most modern Linux systems manage services with systemd, using the systemctl command.

ali@server:~$ systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
     Active: active (running) since Mon 2026-03-02 08:00:11 UTC

Other common commands, which need sudo:

Command What it does
sudo systemctl start nginx Start a service now
sudo systemctl stop nginx Stop a service now
sudo systemctl restart nginx Stop and start it again
sudo systemctl enable nginx Start it automatically at boot
sudo systemctl disable nginx Do not start it at boot

Every running service is something that could be attacked. A good habit is to disable services you do not need.

Logs

Logs record what happened on the system. They are the first place a defender looks after something goes wrong.

Location What it holds
/var/log/auth.log Logins, sudo use and SSH activity (Debian and Ubuntu)
/var/log/secure The same kind of records on Red Hat style systems
/var/log/syslog General system messages (Debian and Ubuntu)
/var/log/nginx/ Web server access and error logs, if nginx is installed

Systems that use systemd also keep a central log that you read with journalctl:

journalctl -u ssh          # logs for the ssh service only
journalctl -f              # follow new log lines live
journalctl --since today   # only today's entries

You can combine logs with grep from the last lesson, for example grep "Failed password" /var/log/auth.log to find failed SSH logins.

Attackers often try to delete or edit logs to hide their tracks. Serious organisations send logs to a separate server so they cannot be quietly changed.

Updates and patching

Software has bugs, and some bugs are security vulnerabilities. When one is found, the developers release a fixed version, called a patch. Details of the flaw then often become public. Anyone who has not installed the patch is now running software with a known weakness.

On Debian and Ubuntu, you update with:

sudo apt update && sudo apt upgrade
Part What it does
apt update Downloads the latest list of available packages and versions
apt upgrade Installs the newer versions of packages you already have
&& Runs the second command only if the first one worked

Many real attacks do not use clever new tricks. They use old, known vulnerabilities on systems that were never updated. Regular patching is one of the simplest and most effective defences there is.

Check your understanding

Answer every question correctly to complete this lesson. If you miss one, try the quiz again.

1. What does sudo do?

2. Which command shows every running process on the system?

3. Why do attackers like servers that are not updated?

Locked: answer every quiz question above correctly to complete this lesson.

Spotted a mistake or something unclear? Report a mistake