Basic Linux Commands for Homelab Beginners (Cheat Sheet)

Almost everything you do on a homelab server happens in a terminal. You connect over SSH, see a blinking cursor, and have to know what to type. That is the point where many beginners freeze, because Linux has thousands of commands and most cheat sheets list sixty of them with no sense of which ones matter.

This guide covers about 40 Linux commands that a mini PC homelab owner will actually use, grouped by the job you’re trying to do: moving around, handling files, checking health, managing services, reading logs, fixing network problems, and looking after Docker. It assumes you have a server running Ubuntu Server or a similar system. If you don’t have one yet, start with our guide to installing Ubuntu Server on a mini PC.

Three safety rules before you type anything

  1. Read a command before you run it. This is especially true for anything you copy from a website, including this one. If you don’t know what a part does, look it up first.
  2. Use sudo only when needed. The word sudo runs a command as the administrator, so a mistake can damage the whole system. If a command works without it, leave it off.
  3. There is no recycle bin. The rm command deletes for good. A typo in a command like rm -rf can wipe out folders you meant to keep.

Moving around

CommandWhat it does
pwdShows which folder you’re in
ls -laLists files, including hidden ones, with sizes and owners
cd /srv/dockerMoves into a folder
cd ..Moves up one folder
cd ~Goes back to your home folder
man lsOpens the manual for a command (press q to leave)
ls --helpShows a short summary of a command’s options

Two keyboard tricks will save you more time than any command. Press Tab to finish a file or folder name for you, and press the up arrow to bring back the previous command.

Working with files and folders

CommandWhat it does
mkdir -p /srv/docker/appCreates a folder, plus any missing parent folders
cp file.txt backup.txtCopies a file
cp -r folder folder-backupCopies a whole folder
mv old.txt new.txtMoves or renames a file
rm file.txtDeletes a file permanently
nano compose.yamlOpens a simple text editor (Ctrl+O saves, Ctrl+X exits)
cat file.txtPrints a small file on screen
less file.txtLets you scroll through a long file (press q to leave)
tail -f file.logShows the end of a file and keeps updating as it grows

Be careful with rm -r and rm -rf, which delete entire folders. Before you run one, use ls on the same path to confirm you’re about to delete what you think you are.

Finding things

grep -i "error" file.log
grep -r "8096" /srv/docker
find /srv -name "compose.yaml"

The first command searches one file for a word. The second searches every file inside a folder, which is handy when you can’t remember which Compose file uses a certain port. The third looks for files by name.

Permissions and ownership

Many “permission denied” errors come from files owned by the wrong user. Start by looking at who owns what:

ls -l
id

The first column of ls -l shows the permissions, and the next two columns show the owner and group. The id command shows your own user and group numbers, which Docker apps often ask for.

CommandWhat it does
chmod +x script.shMakes a script runnable
sudo chown -R $USER:$USER /srv/dockerMakes your account the owner of a folder and everything in it

Avoid the popular “fix” of chmod 777, which lets everyone read, change, and run the file. It hides the real problem and weakens your security.

Checking system health

CommandWhat it tells you
uptimeHow long the server has been running and how busy it is
free -hHow much memory is used and available
df -hHow full each disk is
sudo du -sh * | sort -rh | headWhich folders in the current location use the most space
lsblkWhich drives and partitions the system can see
top or htopLive view of processes using CPU and memory (press q to leave)

A full disk is one of the most common reasons a homelab service suddenly breaks, so df -h is worth running first when something misbehaves. The htop tool is nicer than top but may need installing with sudo apt install htop.

Managing services and reading logs

On Ubuntu, background programs are managed by systemd. These two tools cover most of what you’ll need:

systemctl status docker
sudo systemctl restart docker
sudo systemctl enable docker
journalctl -u docker -f
journalctl -xe
  • systemctl status shows whether a service is running and its last few log lines.
  • restart stops and starts it again, and enable makes it start at every boot.
  • journalctl -u docker -f follows the logs for one service live, and press Ctrl+C to stop.
  • journalctl -xe jumps to the latest entries, which is the first place to look after a failure.

For hardware and driver problems, sudo dmesg --level=err shows kernel error messages, such as a drive that dropped off.

Installing and updating software

sudo apt update
sudo apt upgrade
sudo apt install htop
sudo apt autoremove

update refreshes the list of available software, upgrade installs newer versions, install adds a program, and autoremove clears out leftovers. Run the first two regularly, and reboot with sudo reboot if a kernel update was installed.

Network commands

CommandWhat it does
ip addrShows your IP address
ip routeShows your default gateway (your router)
ping 1.1.1.1Tests whether you can reach the internet
ping example.comTests whether DNS works (Ctrl+C to stop)
sudo ss -tulpnLists which programs are listening on which ports
curl -I http://192.168.1.50:8096Checks whether a web service answers
ssh user@192.168.1.50Logs in to another machine

The ss command is the one to remember when you see “port already in use.” It tells you exactly which program holds the port. Our home network basics guide explains IP addresses, gateways, and DNS, and gives a step-by-step checklist that uses several of these commands.

Copying files between machines

scp file.txt user@192.168.1.50:/home/user/
rsync -av /srv/docker/ user@192.168.1.60:/backup/docker/

scp copies a single file over SSH. rsync copies whole folders and only sends what changed, which makes it a good starting point for backups. Pay attention to the trailing slashes, because they change what gets copied. Our homelab backup strategy for beginners shows where this fits in a real plan.

Docker commands

If you run apps in containers, these cover most daily needs:

CommandWhat it does
docker psLists running containers
docker ps -aLists all containers, including stopped ones
docker logs -f container-nameFollows one container’s logs
docker compose up -dStarts the apps in a Compose file
docker compose pullDownloads newer images
docker compose downStops and removes the containers
docker system dfShows how much disk space Docker uses

Run the docker compose commands from the folder that holds your compose.yaml. Our Docker Compose tutorial for beginners explains each one. Be careful with commands that start with docker system prune, which delete unused data. Read what they will remove before you agree.

A simple routine when something breaks

  1. Is the machine reachable? Try ping and ssh from your computer.
  2. Is the disk full? Run df -h.
  3. Is it out of memory? Run free -h or htop.
  4. Is the service running? Use systemctl status or docker ps.
  5. What do the logs say? Use journalctl -u name -f or docker logs -f name.
  6. Is the port open? Use sudo ss -tulpn and curl.

To stop guessing in the first place, set up alerts with a monitoring tool, as described in our Uptime Kuma monitoring guide.

Shortcuts worth learning

  • Tab completes names, so you type less and make fewer typos.
  • Ctrl+C stops whatever is running.
  • Ctrl+R searches your command history.
  • Up arrow brings back the previous command.
  • sudo !! repeats the last command with sudo, which helps after a “permission denied.”
  • history lists your recent commands.

Frequently asked questions

How many Linux commands do I need to learn?

A few dozen cover almost everything you’ll do on a homelab. Learn them as you need them rather than memorizing a long list.

What does sudo mean?

It runs a command with administrator rights. Use it only when a task needs it, and understand the command first.

Which text editor should a beginner use?

Nano. It shows its shortcuts at the bottom of the screen, which makes it much easier than editors like vim.

How do I undo a mistake?

For most commands you can’t, which is why backups matter. Back up important folders before large changes.

Wrapping up

You don’t need to master Linux to run a homelab. Learn how to move around, read files, check disk and memory, manage services, read logs, and test the network, then add Docker commands as you start running containers. Follow the three safety rules, and use the troubleshooting routine whenever something breaks. The rest you’ll pick up one problem at a time.

Sources