Timedora

Essential Linux Administration

A practical introduction to Linux process and service control, log inspection, package maintenance, and evidence-led troubleshooting.

Privileges and Processes

Use only when a command needs them. In practice, prefix that specific command with sudo instead of working as root for routine tasks. This limits the scope of commands that run with elevated privileges.

Inspect before stopping a process

A process is a running program. Use ps to take a snapshot of processes, or top to view them live. Process information can include the , parent PID, state, CPU use, use, and command. For example:

ps -eo pid,ppid,stat,%cpu,%mem,cmd --sort=-%cpu | head
top

The PID identifies a process. Before stopping one, verify that the PID belongs to the process you actually intend to stop; acting on the wrong PID can affect unrelated work.

Escalate only if needed

Try a normal termination first:

kill PID

Here, replace PID with the verified process ID. By default, kill sends , allowing the process to shut down cleanly. If it does not exit, forced termination is available:

kill -KILL PID

SIGKILL forces termination, so it does not give the process the same opportunity to shut down cleanly. Treat it as a last resort, not the first response.

Services and Their Logs

On many Linux distributions, systemd manages background services as units. Begin by checking a service's current state:

systemctl status ssh.service

The status output helps establish whether the service is active and may include recent related messages. Service names vary by distribution and software package, and not all Linux systems use systemd.

Current state and boot-time behavior

These common commands affect a service in different ways:

sudo systemctl start ssh.service
sudo systemctl stop ssh.service
sudo systemctl restart ssh.service
sudo systemctl enable --now ssh.service

start, stop, and restart change the service's current state. By contrast, enable configures the service to start at boot. The --now option also starts it immediately, so enable --now affects both boot-time behavior and the current state.

Use logs as evidence

A service's status is one part of the picture. On systemd systems, journalctl lets you examine the for more detail. Filter by service and limit the output to recent entries:

sudo journalctl -u ssh.service -n 50

To watch new entries while reproducing a problem, follow the service log:

sudo journalctl -u ssh.service -f

Press Ctrl-C to stop following. You can also narrow results to the current boot and to errors or more severe priorities:

sudo journalctl -b -p err

Here, -b selects entries from the current boot, and -p err selects errors and more severe priorities. Access to system logs may require elevated permissions or membership in a distribution-specific group. Some systems also write text logs under /var/log.

Maintaining Software

Use the provided by your distribution and its configured repositories. Package managers track installed software and resolve dependencies. Avoid installing packages from untrusted sources.

Choose commands for your distribution

On Debian- and Ubuntu-based systems, refresh package metadata before upgrading. Common operations include:

sudo apt update
sudo apt upgrade
sudo apt install PACKAGE
sudo apt remove PACKAGE

On Fedora and other DNF-based systems, typical operations include:

sudo dnf upgrade
sudo dnf install PACKAGE
sudo dnf remove PACKAGE

Replace PACKAGE with the package name. These commands are common counterparts, not interchangeable command syntax: is a front end to Debian package tools, while DNF manages packages on RPM-based distributions. Follow the practices for the distribution in use.

Before confirming a proposed package transaction, review what it will change. This is especially important when removing software or upgrading a production system.

Troubleshooting with Evidence

Troubleshoot by gathering evidence before changing configuration. A useful sequence is to check the affected service, inspect its recent logs, and then examine system resources. A failed service or high resource use is a clue—not a diagnosis by itself.

Check the relevant evidence

These commands examine several common resource and service checks:

df -h
df -i
free -h
ps -eo pid,%cpu,%mem,cmd --sort=-%mem | head
systemctl --failed

df -h shows filesystem space. df -i checks use: running out of inodes can prevent creating files even when disk space remains. free -h summarizes , including an estimate of what is available for new applications. The process listing shows CPU and use and sorts by use, helping identify -heavy processes; use a CPU-based sort or top to investigate CPU use. systemctl --failed lists failed units, including services.

Work from symptom to targeted change

Suppose a web service will not start. Rather than repeatedly restarting it, first check its status, read recent journal entries, and check filesystem space:

systemctl status nginx.service
sudo journalctl -u nginx.service -n 50
df -h

These checks gather evidence; they do not, by themselves, establish the cause. If the problem began after a change, verify the relevant configuration and package state, and consult the service's documentation. Make one change at a time, then confirm the result and record what changed. Avoid deleting log or system files, force-killing processes, or making broad permission changes as a first response.

  • : A background service managed by systemd.