Useful Linux server tools

A fresh Linux server comes with only the basics. A handful of small, free tools make it much easier to see what is happening, move around, copy files and fix problems. None of them use much memory, so they suit any plan size, even 512 MB.

This guide covers the tools worth installing on day one: what each one is for, how to install it, the few commands you will actually use, and a cheat sheet to keep nearby. It assumes Ubuntu or Debian. Most tools exist on other distributions too, sometimes under a different package name.

Low-cost VPS plans in stock right now

In stock when this page loaded. See all 20 matching plans

What is in this guide

Install them all at once

sudo apt update
sudo apt install htop ncdu tmux mc rsync git curl dnsutils mtr-tiny

Package names change from time to time. If one is not found, search for it with apt search NAME. For example, the package that provides dig is called bind9-dnsutils on some releases.

The tools at a glance

ToolWhat it is forUse it when
htopLive view of CPU, memory and running programsThe server feels slow
ncduFind what is using disk spaceThe disk is filling up
tmuxKeep terminal sessions running after you disconnectRunning long jobs or working over a shaky connection
Midnight CommanderA two-pane file manager in the terminalMoving or browsing lots of files
nanoA simple text editorEditing config files
rsyncCopy files and folders, sending only changesBackups, moving servers, deploying sites
GitVersion control for code and configYou want to undo changes or keep history
curlFetch a web address from the command lineTesting whether a site or app answers
digLook up DNS recordsChecking where a domain points
mtrTrace the network path to an addressA connection is slow or dropping
ssList open ports and connectionsChecking what is listening
systemctl, journalctlManage services and read their logsA service will not start or is misbehaving

htop: what is using the server

Run htop. The top shows a bar for each CPU core and bars for memory and swap. Below is a list of programs, busiest first.

  • Press F6 to sort by another column, such as memory.
  • Press F4 to filter the list by name.
  • Press F5 for a tree view, showing which program started which.
  • Press F9 to stop a program, carefully.
  • Press q to quit.

If the swap bar is often full, the server is short of memory. Swap is a safety net, not extra RAM. The plainer top is always available if htop is not installed.

ncdu: what is filling the disk

sudo ncdu -x /

It scans the disk, then shows folders sorted by size. Use the arrow keys to go into a folder and back out, d to delete something, and q to quit. The -x option keeps it on one disk.

Common space users are logs in /var/log, Docker images, package caches, old backups and database dumps. Be sure what something is before deleting it. For a quick summary without ncdu, df -h shows how full each disk is.

tmux: sessions that survive disconnects

If your SSH connection drops, anything running in it normally stops. tmux keeps a session running on the server, so you can reconnect and pick up where you left off.

What you wantCommand or keys
Start a named sessiontmux new -s work
Detach and leave it runningCtrl+B, then D
List sessionstmux ls
Reattachtmux attach -t work
Split the window side by sideCtrl+B, then %
Move between panesCtrl+B, then an arrow key

Use it for long jobs such as big copies, database imports and upgrades. Screen and tmux covers both tools in more detail. For apps that should always run, a systemd service is better than a tmux session, because it restarts after a crash or reboot.

Midnight Commander: a file manager in the terminal

Run mc. You get two panes, each showing a folder. Move between them with Tab and choose files with the arrow keys. The function keys along the bottom copy (F5), move (F6), make folders (F7), delete (F8) and edit (F4). It can also browse inside archives. Press F10 to quit.

It is handy when you need to move many files around and typing paths gets tedious. Run it with sudo mc only when you need to change system files.

nano: editing files

Most guides on this site use nano, because the keys are shown at the bottom of the screen.

  • sudo nano /path/to/file opens a file. System config files need sudo.
  • Ctrl+O then Enter saves. Ctrl+X exits.
  • Ctrl+W searches. Ctrl+K cuts a line and Ctrl+U pastes it.

Before editing an important config file, keep a copy: sudo cp file file.bak. Then you can always go back. Many services have a check command to run before restarting, such as sudo nginx -t or sudo sshd -t.

rsync: copying files efficiently

rsync copies files locally or between servers over SSH, and only sends what changed. Run again, it finishes in seconds.

rsync -av ~/site/ alex@SERVER_IP:site/
rsync -av alex@SERVER_IP:backups/ ~/backups/
rsync -av --dry-run ~/site/ alex@SERVER_IP:site/
  • -a keeps permissions and dates, and copies folders. -v lists what is copied.
  • A trailing slash on the source copies its contents. Without it, the folder itself is copied inside the destination.
  • --dry-run shows what would happen without changing anything. Use it whenever you are unsure.
  • --delete also removes files at the destination that are gone from the source. Powerful and risky: always try it with --dry-run first.

rsync is the backbone of many backups. See using a storage VPS for backups and moving to a new VPS.

Git: tracking your changes

Git is best known for code, but it is just as useful for your server's config files and scripts. Every change is recorded, so you can see what changed and undo it.

mkdir -p ~/config && cd ~/config
git init
cp /etc/nginx/sites-available/example.com .
git add .
git commit -m "nginx config before changes"

Set your name and email once with git config --global user.name "Alex" and git config --global user.email "[email protected]". After editing, git diff shows what changed and git log shows the history.

Never commit passwords, keys or env files. Add them to a file called .gitignore. To deploy websites with Git, see a VPS as a dev and staging server.

1 GB and 2 GB VPS plans in stock, good for learning Linux

In stock when this page loaded. See all 7 matching plans

Network tools: curl, dig, mtr and ss

CommandWhat it tells you
curl -I example.comWhether a site answers, and its status code and headers
curl -I 127.0.0.1:8080Whether a local app answers, without going through the internet
dig example.com +shortThe IP address a domain points to
dig example.com MX +shortWhich servers receive the domain's email
mtr example.comEach step on the network path, and where delays or losses start
sudo ss -tulpnEvery port the server listens on, and which program owns it
ip addrThe server's own IP addresses

In the ss output, an address of 127.0.0.1 means only the server can reach that port. 0.0.0.0 or * means anyone can, unless the firewall stops them. See securing your VPS.

systemctl and journalctl: services and logs

Most server programs run as services, managed by systemd. These come with the system, so there is nothing to install.

CommandWhat it does
systemctl status nginxIs it running, and its latest log lines
sudo systemctl restart nginxRestart a service
sudo systemctl reload nginxReload settings without dropping connections, where supported
sudo systemctl enable --now nginxStart it now and at every boot
systemctl list-units --type=service --state=runningEvery running service
sudo journalctl -u nginx -n 50The last 50 log lines for a service
sudo journalctl -u nginx -fFollow a service's log live
sudo journalctl --since "1 hour ago"Everything logged in the last hour
sudo journalctl --vacuum-time=7dDelete system logs older than a week

Replace nginx with the service you are working on. When something breaks, the log is usually the fastest way to the answer. My VPS is slow or down puts these tools together into a step-by-step check.

Cheat sheet

QuestionCommand
How much memory is free?free -h
How full is the disk?df -h
What is using CPU or memory?htop
What is filling the disk?sudo ncdu -x /
How long has it been up, and how busy?uptime
How many CPU cores?nproc
What is listening?sudo ss -tulpn
Is the firewall on, and what is open?sudo ufw status
Who logged in recently?last -n 10
Is a service running?systemctl status NAME
Why did it fail?sudo journalctl -u NAME -n 50
Where does my domain point?dig example.com +short
Are updates waiting?sudo apt update && apt list --upgradable
Does it need a reboot?ls /var/run/reboot-required

Limits

  • Tools show problems, they do not fix them. Knowing a disk is full is the first step. Deciding what to delete safely is up to you.
  • Careful with sudo. Deleting or overwriting the wrong file as root can break the server. Keep backups, and use dry runs where tools offer them.
  • Names vary. Some package and service names differ between distributions and releases.
  • Not a monitoring system. These tools show the present. To be told when something goes wrong, you need checks that run on their own, ideally from another server.

When to step up

These tools often show when a server has outgrown its plan: swap always in use in htop, the disk always near full in ncdu, or the load average in uptime regularly above the number of cores. If that is what you see, a bigger plan, or splitting jobs across two servers, is the usual fix. How to read VPS specs helps you choose.

4 GB VPS plans in stock, for when you need more room

In stock when this page loaded. See every plan

To compare what is available now, start with the cheapest RackNerd VPS guide and check the sales page.

More RackNerd guides