Linux Commands for VPS Beginners: 33 Commands You Will Actually Use

You do not need hundreds of Linux commands to run a VPS. About thirty cover nearly all daily work: moving around the file system, editing files, fixing permissions, checking CPU, memory and disk, restarting services, reading logs, testing the network and installing packages. This guide groups them by task, with one practical example each, then shows the five-minute routine to follow when someone says "the site is slow".
Examples are for Ubuntu and Debian. Commands that change the system need sudo when you are logged in as a normal user, which is how you should work. If you have not set that up yet, start with our guide to securing a Linux VPS with SSH keys, UFW and fail2ban.
Navigate and manage files
pwdprints the directory you are in. Run it before any delete.ls -lahlists files with sizes, owners and hidden files such as.envand.htaccess.cdchanges directory.cd /var/wwwgoes to an absolute path,cd ..goes up,cd -returns to the previous one.mkdir -pcreates a directory and any missing parents:mkdir -p /var/www/example.com/public.cp -acopies while keeping permissions and timestamps. Make a copy before editing a config:sudo cp -a /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak.mvmoves or renames:mv old-name.php new-name.php.rmdeletes with no recycle bin.rm -r dirdeletes a directory. Preferrm -riwhen unsure; it asks before each file.nanois the easiest editor for beginners. Save with Ctrl+O, exit with Ctrl+X.lessreads long files page by page:less /var/log/syslog. Press/to search,qto quit.tail -ffollows a log live while you reproduce a problem:sudo tail -f /var/log/nginx/error.log.grepfinds text.grep -Rn "DB_HOST" /var/www/example.comshows every file and line that mentions it.findfinds files by name, size or age. Large files:sudo find / -xdev -type f -size +500M.
Permissions and ownership
Most "403 Forbidden" and "permission denied" errors come down to these three:
sudoruns one command as root:sudo systemctl restart nginx.chownchanges the owner. Web files usually belong to the web server user:sudo chown -R www-data:www-data /var/www/example.com.chmodchanges permissions. The safe default for websites is 755 for directories and 644 for files:
sudo find /var/www/example.com -type d -exec chmod 755 {} \;
sudo find /var/www/example.com -type f -exec chmod 644 {} \;Files with secrets, such as .env or wp-config.php, can go stricter with 640 or 600 as long as the app user can still read them.
Processes and resources
uptimeshows load average for 1, 5 and 15 minutes. As a rule of thumb, a load that stays above your number of vCPUs means work is queuing.topshows live CPU and memory per process. On the%Cpu(s)line,wais time waiting for disk andstis CPU steal from the host. Our explainer on KVM virtualization and CPU steal covers what a highstmeans.htopis a friendliertopwith colours and sorting. Install withsudo apt install htopif missing.free -hshows memory. Read theavailablecolumn, notfree: Linux uses spare RAM for cache, and that is good.df -hshows free disk space per file system.df -ishows inodes; a disk can be "full" with free gigabytes if you run out of inodes.du -shshows what uses space:sudo du -sh /var/* | sort -hlists the biggest directories last.pslists processes. Top memory users:ps aux --sort=-%mem | head -n 10.killstops a process by its PID:kill 12345. Usekill -9only if it ignores the normal signal. For services, usesystemctlinstead.
Services and logs
systemctlmanages services:
sudo systemctl status nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl enable --now nginx
systemctl list-units --type=service --state=failedreload applies config without dropping connections where the service supports it. Always test nginx config first with sudo nginx -t.
journalctlreads the systemd journal. The last hour of one service:sudo journalctl -u nginx --since "1 hour ago". Follow live with-f. Errors since the last boot:sudo journalctl -p err -b.
Network
ip ashows your IPv4 and IPv6 addresses per interface.ss -tulpnshows which ports are listening and which program owns each one (run withsudoto see program names).curltests HTTP from the server itself:curl -I https://example.comshows status code and headers. Replace example.com with your domain.pingchecks basic reachability and latency:ping -c 5 example.com.digchecks DNS:dig +short A example.comtells you which IP the domain points to. Install withsudo apt install dnsutilsif missing.
Packages
aptis the package manager on Ubuntu and Debian:
sudo apt update
apt list --upgradable
sudo apt upgrade
sudo apt install nginx
sudo apt remove --purge package-name
sudo apt autoremoveupdate refreshes the package list; upgrade installs the updates. RHEL-family systems such as AlmaLinux use dnf instead. Our comparison of Linux distributions for a VPS explains those differences.
Archives and file transfer
tarpacks and unpacks archives:
tar -czf site-2026-10-10.tar.gz /var/www/example.com
tar -tzf site-2026-10-10.tar.gz | head
tar -xzf site-2026-10-10.tar.gz -C /tmp/restoreThe middle line lists contents without extracting, a quick check that the archive is not empty.
rsynccopies efficiently between servers and resumes where it stopped:rsync -avz /var/www/example.com/ [email protected]:/var/www/example.com/. The trailing slashes mean "the contents of".
Dangerous commands and habits
rm -rfwith a variable or wildcard.rm -rf $DIR/*with an empty$DIRbecomesrm -rf /*. Check withechofirst, use quotes, and never run delete commands you copied without reading.chmod -R 777. It "fixes" permission errors by letting any process write anywhere in your site, including a compromised plugin. Fix the owner withchowninstead.chown -Ron the wrong path. Running it on/or/etccan break sudo and SSH. Double-check the path.ddormkfson the wrong disk. Confirm the device name withlsblkbefore touching a disk.Piping internet scripts to bash.
curl ... | sudo bashruns code you have not read as root. Download, read, then run.Deleting a log that is still open. The disk space is not freed until the process restarts. Empty it instead:
sudo truncate -s 0 /var/log/big.log.Restarting SSH or enabling a firewall from your only session. Keep a second session open.
A five-minute routine for "the site is slow"
Load:
uptimeandnproc. Load well above the vCPU count means CPU pressure.Who uses CPU:
top, pressPto sort by CPU. Notewa(disk) andst(steal).Memory:
free -h. Lowavailableand growing swap use mean you are short on RAM.Disk:
df -handdf -i. A full disk breaks databases and sessions in strange ways.Errors:
sudo tail -n 50 /var/log/nginx/error.logandsudo journalctl -p err --since "30 min ago".Services:
systemctl status php8.3-fpmon Ubuntu 24.04 (php8.1-fpmon 22.04), or your app service and database.Time to first byte from the server itself:
curl -o /dev/null -s -w 'connect=%{time_connect} ttfb=%{time_starttransfer} total=%{time_total}\n' https://example.comIf TTFB is fast from the server but slow for visitors, look at network distance and front-end weight, not the server. For audiences in Egypt, our guide to VPS hosting for Egypt discusses location choices.
Frequently asked questions
What are the most important Linux commands for a server?
For daily VPS work: ls, cd, nano, tail -f, grep, systemctl, journalctl, df -h, free -h, top, ss -tulpn and apt. Learn those first and add the rest as you need them.
How do I check CPU and RAM usage on a Linux VPS?
Use top or htop for live CPU and memory per process, free -h for total memory, and uptime for load average compared with your vCPU count from nproc.
How do I find what is filling my disk?
Run df -h to see which file system is full, then sudo du -sh /var/* | sort -h and drill down. Logs, old backups and caches are the usual causes. Also check df -i for inodes.
Is it safe to practise commands on a production server?
Read-only commands such as ls, df, top and journalctl are safe. Practise anything that deletes, moves or changes permissions on a test server or a copy first.
The best way to learn these is on a server of your own. An IM HOST Linux VPS gives you full root access on KVM with Ubuntu, Debian, CentOS Stream or AlmaLinux, and if a command does something you did not expect, our engineers answer 24/7.
More from our blog
Discover more practical guides and product insights from the IM Host team.
View all articles