# The Linux commands sysadmins actually use, sorted by the problem in front of you

- **Published on:** 2026-11-11
- **Category:** News
- **Original page:** https://free-linux.com/articles/linux-commands-sysadmins-actually-use

About fifty commands grouped by what just happened: the server is slow, the disk is full, who logged in, a service won't start, a process won't die. With the one-liners people really type, the classics that are now obsolete, and real output tested on Debian 13.

---

"100 Linux commands" lists share one flaw: they tell you what `df` does, not when you'll reach for it. Nobody at 3 a.m. thinks "time for `lsof`". They think "the disk is at 100% and I can't find what's filling it". So this list is sorted by the problem you're facing, with the lines people actually end up typing.

Everything here was tested on **Debian 13** (systemd 257, coreutils 9.7, procps 4.0.4, OpenSSH 10.0) on a test server called `web01` running nginx. The output is what that machine printed, trimmed where it ran long. Nearly all of it works the same on Ubuntu, Fedora or the RHEL family; where it doesn't, I say so. I'm assuming you're root or using `sudo`.

## Before you touch anything: where am I?

Sounds silly until you restart the service on the wrong box.

```bash
hostnamectl          # hostname, OS, kernel, whether it's a VM or container
cat /etc/os-release  # exact distribution and version
uname -r             # kernel version
uptime               # how long it's been up, and the load
```

`hostnamectl` is the most complete: on the test machine it reports `Virtualization: docker`, `Operating System: Debian GNU/Linux 13 (trixie)` and the architecture. If `uptime` says the box booted ten minutes ago and nobody rebooted it, that's your first clue.

## "The server is slow"

Start by working out which resource has run out: CPU, memory or disk. Each has its command.

**`uptime` and `nproc`.** Load average (the three numbers at the end, over 1, 5 and 15 minutes) only means something next to the core count. A load of 8 on a machine where `nproc` says 12 is comfortable; on a 2-core box it isn't. On Linux the load also counts processes blocked waiting on disk, so high load with an idle CPU usually points at I/O.

**`free -h`.** The column that matters is `available`, not `free`:

```bash
$ free -h
               total        used        free      shared  buff/cache   available
Mem:            15Gi       3.7Gi       358Mi       2.1Gi        13Gi        11Gi
Swap:          1.0Gi       366Mi       657Mi
```

358 MiB free looks scary, but the kernel uses spare memory as disk cache and gives it back on demand. `available` (11 GiB) is what programs can actually get without swapping.

**`vmstat 1 5`** prints one line per second and is the quickest way to see the whole picture:

```bash
$ vmstat 1 3
procs -----------memory---------- ---swap-- -----io---- -system-- -------cpu-------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st gu
 2  0 375080 366428 232828 14402164   16   21   992   531 2616    3  1  0 99  0  0  0
 5  0 375080 287768 233036 14473508    0    0     0 66632 34787 47949  6  4 87  2  0  0
 6  0 375080 153752 235504 14599024    0    0     8  3924 56066 93761 16  9 75  1  0  0
```

Skip the first line, which is the average since boot. Then look at four things: `r` (processes waiting for CPU; if it stays above the core count, you're short on CPU), `b` (processes blocked on I/O), `si`/`so` (if they're not zero most of the time, you're swapping) and `wa` (CPU time spent waiting on disk).

**`iostat -xz 1`**, from the `sysstat` package, tells you which disk is suffering. Watch `r_await` and `w_await` (milliseconds per request) and `aqu-sz` (queue size). `%util` is misleading on SSDs and NVMe, which serve many requests in parallel: 100% does not mean the device is maxed out.

**Sorted `ps`.** `top` and `htop` are for watching live; to paste results into a ticket, `ps` is better:

```bash
ps -eo pid,user,%cpu,%mem,etime,cmd --sort=-%cpu | head
ps -eo pid,user,%cpu,%mem,etime,cmd --sort=-%mem | head
top -b -n 1 -o %MEM | head -15     # a single top snapshot, sorted by memory
```

Processes in state `D` (uninterruptible sleep, nearly always disk or NFS) can't be killed and push the load up. To list them:

```bash
ps -eo pid,stat,wchan:20,cmd | awk '$2 ~ /^D/'
```

**The kernel.** If a process vanished without explanation, the OOM killer may have taken it. `dmesg -T` shows the kernel ring buffer with readable timestamps; `journalctl -k` shows the same thing, stored and searchable:

```bash
$ journalctl -k -b -g "out of memory|oom-kill"
…
Nov 03 08:55:38 web01 kernel: Memory cgroup out of memory: Killed process 40342 (mysqld) total-vm:1986320kB, anon-rss:404132kB, …
```

The test machine turned up a real one: a MySQL that had gone over its container's memory limit. If a service "just dies" now and then, this is the first search to run.

## "The disk is full"

<figure>
  <img src="/articles/comandos-sysadmin/lsof-l1-df-du-borrado.webp" alt="Root terminal on web01: df -h says /srv/www (a 182M loop device) is 72% full with 121M used, while du -sh /srv/www only adds up to 13K; lsof +L1 shows a sleep process with PID 330 holding open /srv/www/acceso.log, 125829120 bytes and marked deleted; after emptying it with : > /proc/330/fd/3, df -h drops to 64K used and 1%" loading="lazy" decoding="async">
  <figcaption>df and du disagreeing because of a deleted log that is still open, reproduced in a Debian 13 container with a loop device · Own screenshot</figcaption>
</figure>


**`df -h`** tells you which filesystem is full. **`df -i`** tells you whether it's the inodes that ran out: a disk at 40% can refuse writes if something created millions of tiny files (PHP sessions, mail queues).

To find the culprit, top down:

```bash
$ du -xh --max-depth=1 / 2>/dev/null | sort -h | tail -6
16K	/root
2.4M	/etc
89M	/var
239M	/usr
301M	/srv
629M	/
```

The `-x` matters: it stops `du` wandering into other filesystems mounted underneath (`/proc`, a multi-terabyte NFS share), which is what makes it take forever. Then step into the biggest directory and repeat. If `ncdu` is installed, `ncdu -x /` does the same interactively and lets you delete from inside.

To go straight for big files:

```bash
$ find / -xdev -type f -size +100M -exec ls -lh {} + 2>/dev/null
-rw-r--r-- 1 root root 300M Nov  3 08:52 /srv/datos/backup.img
```

### When `df` and `du` disagree

The classic: someone deletes a huge log with `rm`, no space comes back and `df` still says the disk is full. That's because the process writing to it still has it open, and the kernel won't free a file while anyone holds it open, even after its name is gone (we covered why in the piece on [hard and symbolic links](/articles/ln-hard-links-vs-symbolic-links-linux)). Reproduced on a 182 MB filesystem:

```bash
$ df -h /srv/www
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      182M  121M   48M  72% /srv/www
$ du -sh /srv/www
13K	/srv/www
$ lsof +L1
COMMAND PID USER FD   TYPE DEVICE  SIZE/OFF NLINK NODE NAME
sleep   320 root 3w   REG    7,0 125829120     0   13 /srv/www/acceso.log (deleted)
```

`lsof +L1` lists open files with fewer than one link, meaning deleted ones. You now have the PID (320) and the file descriptor (3). The clean fix is to restart or reload that service. If you can't, empty the file through `/proc` without touching the process:

```bash
$ : > /proc/320/fd/3
$ df -h /srv/www
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      182M   64K  168M   1% /srv/www
```

Lesson for next time: you empty a log that's in use with `truncate -s 0 file`; you don't `rm` it.

**`findmnt` and `lsblk -f`.** Before blaming a directory, check what's mounted where. `findmnt /srv/www` shows which device and filesystem sit behind that path; `findmnt -t ext4,xfs,btrfs` filters by type; `lsblk -f` lists disks, partitions, UUIDs and usage. It reads far better than bare `mount` and is more reliable than `/etc/fstab`, which says what should be mounted, not what is.

**The systemd journal** takes space too. `journalctl --disk-usage` tells you how much, and `journalctl --vacuum-size=500M` or `--vacuum-time=2weeks` trims old archives. To make it stick, set `SystemMaxUse=` in `/etc/systemd/journald.conf`.

## "Who's logged in, and what happened?"

```bash
w                  # who's in, from where, and what they're running
who                # the same, terser
last -n 20         # recent logins and reboots
lastlog2           # each user's last login
id ana             # UID, primary group and supplementary groups
```

`w` is the first thing I type on a shared machine: if someone else is halfway through an `apt upgrade`, better to know.

Debian 13 changed something here worth knowing. The classic `/var/log/wtmp` file has a year-2038 problem, so Debian replaced it with **wtmpdb**, an SQLite database. `last` still exists, but it now comes from the `wtmpdb` package, and you'll see that in its output ("wtmpdb begins…"). `lastlog` is now `lastlog2`, and `lastb`, which showed failed logins, is gone.

Failed logins now live in the journal:

```bash
$ journalctl -u ssh -g "Invalid user|Failed password" --since today
Nov 03 08:53:36 web01 sshd-session[177]: Invalid user admin from 127.0.0.1 port 56238
```

Two details to watch. On Debian and Ubuntu the unit is called `ssh`; on Fedora and the RHEL family it's `sshd`. And since OpenSSH 9.8 those messages come from the `sshd-session` process, not `sshd`, so old filters like `journalctl _COMM=sshd` return "No entries". Filter by unit with `-u` and you won't get bitten.

## Services and logs with systemd

This is where most of the time goes. If you want to know how [systemd ended up everywhere](/articles/systemd-the-controversy), that story has its own article; this is the hands-on part.

**What's broken.** `systemctl --failed` is the first thing to run after a reboot or an alert:

```bash
$ systemctl --failed
  UNIT          LOAD   ACTIVE SUB    DESCRIPTION
● nginx.service loaded failed failed A high performance web server and a reverse proxy server

1 loaded units listed.
```

**Why.** `systemctl status nginx` shows the state and the last few log lines. For more, `journalctl` filtered by unit and time:

```bash
$ journalctl -u nginx --since "1 hour ago"
Nov 03 08:52:50 web01 nginx[346]: 2026/11/03 08:52:50 [emerg] 346#346: unknown directive "bad" in /etc/nginx/sites-enabled/default:92
Nov 03 08:52:50 web01 nginx[346]: nginx: configuration file /etc/nginx/nginx.conf test failed
Nov 03 08:52:50 web01 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Nov 03 08:52:50 web01 systemd[1]: Failed to start nginx.service - A high performance web server and a reverse proxy server.
```

There it is: a typo on line 92. The variants I use most:

```bash
journalctl -u nginx -f              # live, like tail -f
journalctl -p err -b                # errors only, since the last boot
journalctl -b -1 -p warning         # warnings from the previous boot (after an unexpected reboot)
journalctl --list-boots             # which boots are stored
journalctl -u nginx -o cat          # message only, no date or host, ready for grep or awk
```

`--since` and `--until` take `today`, `yesterday`, `"2026-11-10 14:00"` or `"30 min ago"`.

**Start, stop, reload.**

```bash
nginx -t && systemctl reload nginx   # check the config, then reload without dropping connections
systemctl restart nginx              # stop and start: cuts whatever is in flight
systemctl enable --now nginx         # start at boot, and right now too
systemctl is-active nginx            # prints active/failed; handy in scripts
systemctl reset-failed               # clear the "failed" state once it's fixed
```

Validating before reloading (`nginx -t`, `apachectl configtest`, `sshd -t`, `named-checkconf`) saves half the scares. A `restart` with a broken config leaves the service down; a `reload` with a broken config, in nginx's case, keeps the old one running. I checked: the reload fails, `systemctl is-active` still says `active` and the site keeps answering.

**Inventory.**

```bash
systemctl list-units --type=service --state=running
systemctl list-unit-files --type=service --state=enabled
systemctl list-timers               # systemd's scheduled jobs, with the next run
```

`list-timers` deserves attention: on a modern distribution many periodic jobs that used to live in cron are now systemd timers, and if you only check `crontab -l` you won't see them.

**Changing a unit without editing the packaged one.** `systemctl cat nginx` shows the unit file plus all its drop-ins. `systemctl edit nginx` opens an override file in `/etc/systemd/system/nginx.service.d/` where you put only what you change (a `Restart=on-failure`, a `LimitNOFILE=`), and a package upgrade won't overwrite it. If you edit it by hand instead, run `systemctl daemon-reload` afterwards.

**A one-off job.** `systemd-run` replaces `at` and improvised `nohup … &`:

```bash
$ systemd-run --unit=cleanup --on-active=10min /usr/bin/find /tmp -mtime +7 -delete
Running timer as unit: cleanup.timer
Will run service as unit: cleanup.service
```

The job is logged in the journal under its name (`journalctl -u cleanup`) and shows up in `systemctl list-timers`.

**Slow boot.** `systemd-analyze blame` sorts services by how long they took to start.

## Processes

```bash
pgrep -a nginx              # PIDs and command lines of matching processes
pstree -p                   # the full tree, with PIDs: who's whose child
pkill -x sleep              # kill by exact name
kill 1234                   # SIGTERM: ask the process to exit cleanly
kill -HUP 1234              # many daemons reload their config on SIGHUP
kill -9 1234                # SIGKILL: last resort, no cleanup
renice -n 10 -p 1234        # lower the priority of a process that's already running
timeout 30s command         # kill it if it takes longer than 30 seconds (exits with 124)
```

About `kill -9`: the process can't close files, flush buffers or remove its lock file. Try a plain `kill` first and give it a few seconds. And if the process is in state `D`, not even `-9` will move it: it's waiting on the kernel.

A trap with `pkill -f` and `pgrep -f`, which match the whole command line rather than just the name: they also match the shell that launched them if the pattern appears in its own command line. While testing this article, a `bash -c '… pkill -f "sleep 900" …'` killed itself. Whenever you can, use `-x` with the exact name, and before any `pkill -f`, run the same pattern with `pgrep -af` to see what's going to fall.

To find which process holds a port or a file:

```bash
lsof -i :80                 # who's listening on, or connected to, port 80
lsof -p 1234                # everything a process has open
fuser -v 80/tcp             # same as lsof -i, shorter
```

## Files and permissions

**`namei -l`** clears up most of the "Permission denied" errors that seem to make no sense. It shows the permissions of every directory along the path, not just the last one:

```bash
$ namei -l /srv/app/uploads
f: /srv/app/uploads
drwxr-xr-x root     root     /
drwxr-xr-x root     root     srv
drwxr-x--- www-data www-data app
drwxr-xr-x www-data www-data uploads
```

`uploads` is world-readable, but `app` lets nobody outside the group through, so user `ana` can't get there. To give that one user access without opening the directory to everyone, use an ACL:

```bash
$ setfacl -m u:ana:rx /srv/app
$ getfacl -p /srv/app
# file: /srv/app
# owner: www-data
# group: www-data
user::rwx
user:ana:r-x
group::r-x
mask::r-x
other::---

$ ls -ld /srv/app
drwxr-x---+ 3 www-data www-data 4096 Nov  3 08:53 /srv/app
```

That `+` at the end of the permissions in `ls -l` tells you there's an ACL. Miss it and you can spend a long time wondering why someone has access.

Others I use daily:

```bash
stat -c '%A %a %U:%G %n' /srv/app        # permissions as text and octal, owner and group
chown -R www-data:www-data /srv/app      # careful with -R and with where you are
find /usr/bin /usr/sbin -perm -4000      # setuid binaries: review them now and then
find /etc -type f -mmin -60              # what changed in /etc in the last hour
find /srv -xdev -type f -perm -o+w       # world-writable files
grep -rn "listen" /etc/nginx/            # where a directive is defined
tail -F /var/log/nginx/error.log         # like -f, but survives log rotation
```

`find /etc -mmin -60` is very handy when something broke "and nobody touched anything".

## Archives and transfers

**`tar`.** The syntax worth memorising:

```bash
tar -czf etc-$(date +%F).tar.gz -C / etc     # create, gzip, relative paths
tar --zstd -cf etc.tar.zst -C / etc          # zstd: compresses faster than gzip
tar -tf etc-2026-11-03.tar.gz | head         # list without extracting
tar -xzf etc-2026-11-03.tar.gz -C /tmp/restore etc/hostname   # pull out a single file
```

`-C` keeps absolute paths out of the archive and lets you restore somewhere else to compare before overwriting anything. And never extract a tarball of unknown origin as root into `/` without listing it first.

**`rsync`** is the tool for copying between machines or directories. Golden rule: dry run first.

```bash
$ rsync -avhn --delete /srv/origen/ /srv/destino/
sending incremental file list
deleting viejo
f1
f2
f3

sent 103 bytes  received 37 bytes  280.00 bytes/sec
total size is 6  speedup is 0.04 (DRY RUN)
```

`-n` (`--dry-run`) shows what it would do, including what `--delete` is about to remove on the destination. If you're happy, drop the `-n`. The trailing slash on the source matters: with it, rsync copies the contents; without it, you get the directory itself inside the destination. For another machine, `rsync -avh /srv/source/ user@server:/srv/dest/` runs over SSH.

`scp` still works, but `rsync` resumes interrupted transfers and only sends what changed, which is what you want as soon as files get large.

**Check it arrived intact:**

```bash
$ sha256sum etc.tar.zst > etc.tar.zst.sha256
$ sha256sum -c etc.tar.zst.sha256
etc.tar.zst: OK
```

For installing and updating packages each family has its own tools (`apt list --upgradable` on Debian, `dnf check-update` on RHEL); we went through them in the overview of [package managers](/articles/linux-package-managers).

## Networking, in three lines

Network commands deserve their own article, and they'll get one in a few days. To get by until then:

```bash
ss -tlnp        # what's listening on TCP, and which process owns it
ip -br a        # interfaces and addresses, one per line
ip r            # routing table
```

## What you should stop typing

On a fresh Debian 13 install many of the classics aren't even there: `netstat`, `ifconfig`, `route` and `arp` come in `net-tools`, which is optional and not installed by default.

| Old | Now | Notes |
| --- | --- | --- |
| `netstat -tlnp` | `ss -tlnp` | same flags for the basics |
| `ifconfig` | `ip a` / `ip -br a` | `net-tools` no longer installed |
| `route -n` | `ip r` | |
| `arp -n` | `ip neigh` | |
| `service nginx restart`, `/etc/init.d/nginx restart` | `systemctl restart nginx` | `service` still exists as a wrapper |
| `chkconfig`, `update-rc.d` | `systemctl enable` / `disable` | |
| `tail -f /var/log/syslog` | `journalctl -f` | Debian no longer installs rsyslog by default: there's no `/var/log/syslog` |
| `lastb` | `journalctl -u ssh -g "Failed\|Invalid"` | removed in Debian 13 |
| `lastlog` | `lastlog2` | Debian 13 |
| `egrep`, `fgrep` | `grep -E`, `grep -F` | deprecated since 2007; GNU grep warns on every use since 3.8 (Debian patches the warning out) |
| `nohup cmd &`, `at` | `systemd-run` | ends up in the journal |
| `iptables` | `nft` | iptables lives on as a layer over nftables |

On `/var/log`: the RHEL family still ships rsyslog, so there `journalctl` coexists with `/var/log/messages` and `/var/log/secure`. Even so, `journalctl` works on both families and filters by unit and time, which is a lot more effort with `grep` over text files.

## Where to go next

If these commands are heading into scripts, the [history of Bash](/articles/history-of-bash-shell) helps explain why some things behave the way they do. And if you run containers, much of what you see with `ps`, `systemctl` or `findmnt` inside one comes down to the kernel's [namespaces and cgroups](/articles/namespaces-and-cgroups).

## How we tested this

`web01` is a Docker container from the `debian:13` image (Debian 13.7) with systemd 257 booted as PID 1, so that `systemctl`, `journalctl` and `hostnamectl` behave as they would on a real server. On top of that went nginx and OpenSSH 10.0 from the Debian repositories, alongside coreutils 9.7 and procps 4.0.4. That's why `hostnamectl` reports `Virtualization: docker`, and why the kernel log, with the MySQL OOM kill, belongs to Docker's virtual machine, which every container shares. The `df`, `du` and `lsof +L1` case uses a file mounted as a loop device, which requires `--privileged`; the screenshot comes from a repeat run on 3 November in a fresh container.

To reproduce it:

```bash
docker run -d --name web01 --hostname web01 --privileged --cgroupns=host debian:13 \
  bash -c 'apt-get update && apt-get install -y systemd systemd-sysv && exec /sbin/init'
docker exec -it web01 bash
apt-get install -y nginx openssh-server lsof sysstat rsync   # inside the container
```

With `--privileged` the container can touch the host's devices: use it on a test machine or a VM, never on a server that runs real services.

**Sources:** the man pages for [ps(1)](https://man7.org/linux/man-pages/man1/ps.1.html), [free(1)](https://man7.org/linux/man-pages/man1/free.1.html), [vmstat(8)](https://man7.org/linux/man-pages/man8/vmstat.8.html), [lsof(8)](https://man7.org/linux/man-pages/man8/lsof.8.html), [findmnt(8)](https://man7.org/linux/man-pages/man8/findmnt.8.html), [namei(1)](https://man7.org/linux/man-pages/man1/namei.1.html), [ss(8)](https://man7.org/linux/man-pages/man8/ss.8.html) and [ip(8)](https://man7.org/linux/man-pages/man8/ip.8.html) at man7.org; the systemd documentation for [systemctl](https://www.freedesktop.org/software/systemd/man/latest/systemctl.html), [journalctl](https://www.freedesktop.org/software/systemd/man/latest/journalctl.html) and [systemd-run](https://www.freedesktop.org/software/systemd/man/latest/systemd-run.html); the GNU manuals for [coreutils](https://www.gnu.org/software/coreutils/manual/coreutils.html), [tar](https://www.gnu.org/software/tar/manual/) and [grep](https://www.gnu.org/software/grep/manual/grep.html); the [rsync manual](https://download.samba.org/pub/rsync/rsync.1); the kernel documentation on [/proc](https://docs.kernel.org/filesystems/proc.html); and the [Debian 13 release notes](https://www.debian.org/releases/trixie/release-notes/).
