Skip to content
Current coupon:10% offUse it in your order

Basic Linux commands for managing a VPS

The commands you'll use most when managing a VPS: moving around folders, working with files, the nano editor, installing packages, services and logs, disk space, memory and network. With cheat sheets and explanations.

  • beginner
  • ~20 min
  • Updated 1 Oct 2026

An overview of the commands you'll use every day when managing a VPS. For each one we explain what it does and what its options mean. At the end you'll find a printable cheat sheet.

What you'll need

  • A StormHost VPS with Ubuntu 24.04 or Debian 13
  • An SSH connection (guide) or the browser console
  • About 20 minutes to try things out

How to read a command#

bash
ls -la /var/log
PartExampleMeaning
CommandlsThe program that runs (here, listing a folder).
Options-laChange its behavior. Short ones are written with one dash and can be combined (-l -a = -la), long ones with two (--all).
Argument/var/logWhat the command works on (a file, folder, package name).

Useful keys:

KeyWhat it does
TabCompletes the name of a command, file or folder. Pressing it twice lists the options. Saves you typos.
Up / Down arrowsScroll through previously entered commands.
Ctrl+CInterrupts the running command. In a terminal it is not copy.
Ctrl+RSearches the command history by text.
Ctrl+LClears the screen (same as the clear command).

sudo: as root (# at the end of the prompt) you can do everything. As a regular user ($ at the end of the prompt), put sudo in front of a command that needs administrator rights, for example sudo apt update. It asks for your user's password. In this guide we write commands for root; as a regular user, add sudo.

Help: almost every command has help via command --help and a manual via man command (scroll with the space bar, quit with q).

Folders and paths#

Linux has no C: and D: drives. Everything starts at the root folder /.

FolderWhat's in it
/The root of the whole system.
/rootThe home folder of the root user.
/home/janThe home folder of the user jan. The shortcut for your own home folder is ~.
/etcConfiguration files for the system and services.
/var/logLogs (some logs are only in the journal, see journalctl).
/var/wwwThe usual place for websites.
/tmpTemporary files, deleted on restart.

An absolute path starts with / and works from anywhere (/etc/ssh/sshd_config). A relative path starts from the folder you're in (logs/latest.log). . is the current folder, .. the parent folder.

bash
pwd
ls -la
cd /var/log
cd ..
cd
  • pwd – prints which folder you're in right now.
  • ls -la – lists the folder contents: -l in detail (permissions, owner, size, date), -a including hidden files (they start with a dot).
  • cd /var/log – goes to the /var/log folder.
  • cd .. – goes one level up.
  • cd – with no argument, returns to your home folder.

How to read a line from ls -la:

Outputtext
-rw-r--r-- 1 root root 1234 Oct  1 10:00 config.yml
PartMeaning
-Type: - file, d folder, l link.
rw-r--r--Permissions: owner (rw-), group (r--), others (r--). r read, w write, x execute (for a folder, enter).
root rootOwner and group.
1234Size in bytes (human-readable with the -h option, e.g. 1.2K).
Oct 1 10:00Date of the last change.

Files#

CommandWhat it does
cat file.txtPrints the whole file. Handy for short files.
less file.txtViews a long file. Arrows and the space bar scroll, /text searches, q quits.
tail -n 50 file.logThe last 50 lines. With -f it keeps printing new lines (following a log).
cp source targetCopies a file. Copy a folder with the -r (recursive) option.
mv source targetMoves or renames a file or folder.
mkdir -p path/to/folderCreates a folder; -p also creates missing parent folders.
rm fileDeletes a file.
rm -r folderDeletes a folder including its contents.

rm deletes for good

Linux has no recycle bin. What you delete with rm is gone. Be especially careful with rm -r, and never run rm -rf with a path you haven't checked twice. One extra space is enough: rm -rf /var/www/ my-site instead of rm -rf /var/www/my-site deletes the whole /var/www folder with all websites. You can restore the whole VPS from a backup in the Backups tab, but you lose the changes made since the backup.

The nano editor#

bash
nano /etc/hosts

Opens the file in a simple editor. The controls are listed in the bottom lines; ^ means Ctrl and M- means Alt.

KeysWhat they do
Ctrl+O, then EnterSaves the file.
Ctrl+XCloses the editor. With unsaved changes it asks: Y save, N discard.
Ctrl+WSearches for text.
Ctrl+KCuts the whole line.
Ctrl+UPastes the cut line.
Alt+UUndoes the last change.

Paste text from the clipboard with your terminal's shortcut (Windows Terminal Ctrl+V, PuTTY a right-click, macOS Cmd+V).

Permissions and owner#

bash
chmod 644 soubor.txt
chmod 755 skript.sh
chown jan:jan soubor.txt
chown -R www-data:www-data /var/www/web
  • chmod – changes permissions. The number has three digits: owner, group, others. Each digit is a sum of 4 (read) + 2 (write) + 1 (execute).
  • chown user:group – changes the owner and group.
  • -R – recursively, meaning for everything inside the folder too.
NumberPermissionsTypical use
644owner reads and writes, others only readRegular files, website configuration
600only the owner reads and writesPasswords, keys, .env
755owner everything, others read and executeFolders, executable scripts
700owner onlyPrivate folders (~/.ssh)

Don't use 777 permissions (everyone can do everything). They won't solve a permission problem; they just open the file to anyone.

Packages (apt)#

CommandWhat it does
apt updateDownloads the current package list. Always run it before installing.
apt upgradeUpdates installed packages. Installs new dependencies but never removes a package.
apt full-upgradeUpdates everything, even if some package has to be removed for it (typically with a bigger dependency change).
apt install htopInstalls a package. Separate multiple packages with a space.
apt remove htopUninstalls a package but keeps its configuration files.
apt purge htopUninstalls a package including its configuration.
apt autoremoveRemoves dependencies nothing needs anymore.
apt search nameSearches for a package by name and description.

The -y option (apt install -y htop) automatically confirms the “Do you want to continue?” question.

Services and logs#

Services (web server, database, SSH) are managed by systemd with the systemctl command.

CommandWhat it does
systemctl status nginxService status: active (running) is running, failed crashed, plus the last few log lines. Quit with q.
systemctl restart nginxRestarts the service.
systemctl reload nginxLoads a new configuration without interruption (only some services support it).
systemctl stop nginx / start nginxStops / starts the service.
systemctl enable nginxThe service starts when the VPS boots. With --now it also starts right away.
systemctl disable nginxThe service doesn't start at boot.
systemctl --failedLists services that crashed.

journalctl reads service logs:

bash
journalctl -u nginx -n 50 --no-pager
journalctl -u nginx -f
journalctl -u nginx --since "1 hour ago"
  • -u nginx – only entries of the nginx service.
  • -n 50 – the last 50 lines.
  • --no-pager – print directly, without the less viewer.
  • -f – keep printing new entries (quit with Ctrl+C).
  • --since "1 hour ago" – entries from the last hour ("2026-10-01 10:00" works too).

Disk, memory and processes#

CommandWhat it shows
df -hUsed and free space on disks. Watch the line with the mount point /. -h = human-readable units.
du -sh /var/logHow much space a folder takes. -s total, -h human-readable.
du -xh --max-depth=1 / 2>/dev/null | sort -hSizes of the folders in the root, sorted from smallest. For finding what filled up the disk. -x counts only the system disk, 2>/dev/null hides messages about inaccessible files, sort -h sorts by size.
free -hRAM and swap. The available column is what matters.
uptimeHow long the VPS has been running and the average load over 1, 5 and 15 minutes.
htopA live overview of processes, CPU and memory. The M key sorts by memory, P by CPU, q quits. If it's missing: apt install htop.
topA simpler version of htop, always installed.
ss -tulpnPorts that programs are listening on.

The ss -tulpn options: -t TCP, -u UDP, -l only listening ports, -p program name, -n numbers instead of names. The address 0.0.0.0 or [::] means reachable from outside (if the firewall lets it through), 127.0.0.1 only inside the VPS.

Network#

CommandWhat it does
ip aIP addresses of the network interfaces (ip -br a for a short version).
ip rThe routing table. The default via … line is the default gateway.
ping -c 4 1.1.1.1Connection test: 4 packets to the server 1.1.1.1.
curl -I https://example.czDownloads only a website's headers. Confirms that the site responds (HTTP/2 200).
dig example.cz A +shortLooks up a domain's DNS record. If it's missing: apt install bind9-dnsutils.

Users#

CommandWhat it does
whoamiWhich user you're logged in as.
id janThe groups of the user jan.
adduser janCreates a user (see Securing a new VPS).
passwd janChanges the password of the user jan (without a name, the current user's password).
sudo -iSwitches from a regular user to root.
exitLogs you out, or ends sudo -i.

Restart and shutdown#

CommandWhat it does
rebootRestarts the VPS system.
poweroffShuts down the VPS. You can only turn it back on with the Start button in the Console tab.

After a RAM or CPU upgrade, reboot isn't enough; use the Restart button in the customer area (see Browser console).

Cheat sheet#

TaskCommand
Where am Ipwd
What's in the folderls -la
Go to a foldercd /path
Show a filecat file / less file
Edit a filenano file
Follow a logtail -f file.log
Copy / movecp a b / mv a b
Delete (for good)rm file / rm -r folder
Permissionschmod 644 file
Ownerchown jan:jan file
Updatesapt update && apt full-upgrade
Installapt install package
Service statussystemctl status service
Restart a servicesystemctl restart service
Service logjournalctl -u service -f
Disk spacedf -h
What takes up spacedu -sh /path/*
Memoryfree -h
Processeshtop
Open portsss -tulpn
IP addressesip -br a
Interrupt a commandCtrl+C

Troubleshooting#

command not found#

The program isn't installed, or there's a typo in the name. Ubuntu often tells you which package contains the program (Command 'htop' not found, but can be installed with: apt install htop).

Permission denied#

You don't have the rights. As a regular user, repeat the command with sudo. For a script, the execute permission is missing: chmod +x skript.sh.

No such file or directory#

The path doesn't exist. Check it with the Tab key (it completes only existing names) and check upper and lower case: Linux treats Config.yml and config.yml as different files.

E: Unable to locate package#

Run apt update first. If the error persists, the package has a different name; search with apt search.

E: Could not get lock /var/lib/dpkg/lock-frontend#

Another installation is running in the background (often automatic updates). Wait a few minutes and run the command again.

No space left on device#

The disk is full. Find what takes up the space (du -xh --max-depth=1 / 2>/dev/null | sort -h, then the same in the biggest folder, for example du -xh --max-depth=1 /var 2>/dev/null | sort -h), delete what you don't need (old backups, logs), clean up packages (apt clean) and old journal entries (journalctl --vacuum-size=200M). Or extend the disk.

Summary

  • Command = program, options and arguments; Tab completes, Ctrl+C interrupts.
  • Files: ls, cd, cat, less, nano, cp, mv, rm (permanent!).
  • Packages: apt update, apt install, apt full-upgrade.
  • Services: systemctl status|restart|enable, logs with journalctl -u service.
  • Resources: df -h, du -sh, free -h, htop, ss -tulpn.

Search the guides