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
- 1 GB KVM VPS Special1 CPU · 1 GB RAM · 20 GB disk · 3 TB bandwidth · New York, Los Angeles, Chicago$21.99/yrabout $1.83/moView at RackNerd
- KVM-512MB1 CPU · 512 MB RAM · 30 GB disk · 500 GB bandwidth · Los Angeles, Dallas, Chicago$26.99/yrabout $2.25/moView at RackNerd
- Ryzen-512MB (Linux)1 CPU · 512 MB RAM · 10 GB disk · 500 GB bandwidth · New York, Chicago, Seattle$26.99/yrabout $2.25/moView at RackNerd
- Storage VPS Special - 100GB Storage1 CPU · 1 GB RAM · 100 GB disk · 10 TB bandwidth · Los Angeles, Dallas, Chicago$35.00/yrabout $2.92/moView at RackNerd
In stock when this page loaded. See all 20 matching plans
What is in this guide
- Install them all at once
- The tools at a glance
- htop: what is using the server
- ncdu: what is filling the disk
- tmux: sessions that survive disconnects
- Midnight Commander: a file manager in the terminal
- nano: editing files
- rsync: copying files efficiently
- Git: tracking your changes
- Network tools: curl, dig, mtr and ss
- systemctl and journalctl: services and logs
- Cheat sheet
- Limits
- When to step up
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
| Tool | What it is for | Use it when |
|---|---|---|
| htop | Live view of CPU, memory and running programs | The server feels slow |
| ncdu | Find what is using disk space | The disk is filling up |
| tmux | Keep terminal sessions running after you disconnect | Running long jobs or working over a shaky connection |
| Midnight Commander | A two-pane file manager in the terminal | Moving or browsing lots of files |
| nano | A simple text editor | Editing config files |
| rsync | Copy files and folders, sending only changes | Backups, moving servers, deploying sites |
| Git | Version control for code and config | You want to undo changes or keep history |
| curl | Fetch a web address from the command line | Testing whether a site or app answers |
| dig | Look up DNS records | Checking where a domain points |
| mtr | Trace the network path to an address | A connection is slow or dropping |
| ss | List open ports and connections | Checking what is listening |
| systemctl, journalctl | Manage services and read their logs | A 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 want | Command or keys |
|---|---|
| Start a named session | tmux new -s work |
| Detach and leave it running | Ctrl+B, then D |
| List sessions | tmux ls |
| Reattach | tmux attach -t work |
| Split the window side by side | Ctrl+B, then % |
| Move between panes | Ctrl+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/fileopens 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/
-akeeps permissions and dates, and copies folders.-vlists what is copied.- A trailing slash on the source copies its contents. Without it, the folder itself is copied inside the destination.
--dry-runshows what would happen without changing anything. Use it whenever you are unsure.--deletealso removes files at the destination that are gone from the source. Powerful and risky: always try it with--dry-runfirst.
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
- 1 GB KVM VPS Special1 CPU · 1 GB RAM · 20 GB disk · 3 TB bandwidth · New York, Los Angeles, Chicago$21.99/yrabout $1.83/moView at RackNerd
- Storage VPS Special - 100GB Storage1 CPU · 1 GB RAM · 100 GB disk · 10 TB bandwidth · Los Angeles, Dallas, Chicago$35.00/yrabout $2.92/moView at RackNerd
- 2 GB KVM VPS Special2 CPU · 2 GB RAM · 35 GB disk · 5 TB bandwidth · New York, Los Angeles, Chicago$35.99/yrabout $3.00/moView at RackNerd
- Ryzen-1GB (Linux)1 CPU · 1 GB RAM · 15 GB disk · 1 TB bandwidth · New York, Chicago, Seattle$194.29/yrabout $16.19/moView at RackNerd
In stock when this page loaded. See all 7 matching plans
Network tools: curl, dig, mtr and ss
| Command | What it tells you |
|---|---|
curl -I example.com | Whether a site answers, and its status code and headers |
curl -I 127.0.0.1:8080 | Whether a local app answers, without going through the internet |
dig example.com +short | The IP address a domain points to |
dig example.com MX +short | Which servers receive the domain's email |
mtr example.com | Each step on the network path, and where delays or losses start |
sudo ss -tulpn | Every port the server listens on, and which program owns it |
ip addr | The 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.
| Command | What it does |
|---|---|
systemctl status nginx | Is it running, and its latest log lines |
sudo systemctl restart nginx | Restart a service |
sudo systemctl reload nginx | Reload settings without dropping connections, where supported |
sudo systemctl enable --now nginx | Start it now and at every boot |
systemctl list-units --type=service --state=running | Every running service |
sudo journalctl -u nginx -n 50 | The last 50 log lines for a service |
sudo journalctl -u nginx -f | Follow a service's log live |
sudo journalctl --since "1 hour ago" | Everything logged in the last hour |
sudo journalctl --vacuum-time=7d | Delete 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
| Question | Command |
|---|---|
| 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
- 4 GB KVM VPS Special3 CPU · 4 GB RAM · 60 GB disk · 7 TB bandwidth · New York, Los Angeles, Chicago$59.99/yrabout $5.00/moView at RackNerd
- Ryzen-4GB (Linux)2 CPU · 4 GB RAM · 30 GB disk · 3 TB bandwidth · New York, Chicago, Seattle$265.57/yrabout $22.13/moView at RackNerd
- KVM-4GB4 CPU · 4 GB RAM · 130 GB disk · 3 TB bandwidth · Los Angeles, Dallas, Chicago$295.08/yrabout $24.59/moView at RackNerd
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.