Essential Linux Commands for Your VPS

You just got your first VPS, logged in over SSH, and now you are staring at a blank terminal. Everything you need to do on this machine starts with a command. This is not a full Linux textbook. It is the practical set of commands that covers 90% of day-to-day VPS work, explained with real examples.

Connecting to your server

Before anything else, you need to get in. Open a terminal on your local machine and connect with SSH:

ssh root@your-server-ip

If you use a key file instead of a password:

ssh -i ~/.ssh/mykey root@your-server-ip

Once you see the command prompt, you are on your server. Everything you type now runs there, not on your own machine.

Navigation and file management

Moving around and working with files is the foundation of everything else.

  • pwd prints your current directory. If you are lost, start here.
  • ls -la lists all files in the current directory, including hidden ones, with permissions and sizes.
  • cd /var/www changes directory. Use cd .. to go up one level.
  • mkdir myproject creates a new directory.
  • cp file.txt backup.txt copies a file. Add -r for directories.
  • mv old.txt new.txt moves or renames a file.
  • rm file.txt deletes a file. rm -rf directory/ deletes a directory and everything in it. Be careful: there is no recycle bin.

Reading and editing files

You will read configuration files constantly. These commands help:

  • cat config.yml prints the entire file to the screen.
  • less config.yml opens the file in a scrollable viewer. Press q to quit.
  • head -n 20 logfile.log shows the first 20 lines.
  • tail -n 50 logfile.log shows the last 50 lines. Add -f to follow the file in real time, which is perfect for watching logs.
  • nano config.yml opens a simple text editor in the terminal. Edit, then press Ctrl+O to save and Ctrl+X to exit.

Package management (Debian/Ubuntu)

Most VPS providers ship Debian or Ubuntu. Installing and updating software uses apt:

  • apt update refreshes the package list. Always run this first.
  • apt upgrade installs available updates for all packages.
  • apt install nginx installs a package (nginx in this example).
  • apt remove nginx removes it.

On CentOS or AlmaLinux, replace apt with dnf.

Managing services

Services like web servers, databases and game servers are controlled with systemctl:

  • systemctl start nginx starts the service.
  • systemctl stop nginx stops it.
  • systemctl restart nginx restarts it (useful after config changes).
  • systemctl status nginx shows whether it is running and any recent log lines.
  • systemctl enable nginx makes it start automatically on boot.

Monitoring your server

Knowing what your server is doing right now saves debugging time later:

  • htop shows CPU, RAM and running processes in a live dashboard. Press q to quit. Install it with apt install htop if it is not already there.
  • df -h shows disk space usage per partition. Watch for a root partition above 90%.
  • free -h shows total, used and available memory.
  • uptime shows how long the server has been running and the load average.

Networking

Checking connectivity and open ports:

  • ping google.com tests whether the server can reach the internet.
  • curl -I https://example.com checks HTTP response headers from a URL.
  • ss -tlnp lists all listening TCP ports and which process owns each one.
  • ufw allow 80 opens port 80 in the firewall. ufw status lists current rules.

Permissions and ownership

Files on Linux have an owner and permission flags. When something does not work, permissions are often the reason:

  • chown -R www-data:www-data /var/www/site sets the owner of a directory and everything inside it.
  • chmod 755 script.sh makes a script executable.
  • chmod 600 secrets.env restricts a file so only the owner can read it.

A HostValues VPS gives you full root access on a KVM machine with these tools ready out of the box. Pick your OS, log in and start building.

Do I need to know Linux to use a VPS?

You need the basics covered in this guide, yes. A VPS gives you an empty machine and expects you to manage it. If you prefer a managed experience where software is pre-installed, a game panel or managed hosting is a better fit. But learning these commands is not hard, and the control you gain is worth the initial effort.

What is the difference between apt and dnf?

apt is the package manager for Debian-based systems (Debian, Ubuntu). dnf is for Red Hat-based systems (CentOS, AlmaLinux, Fedora). They do the same thing with slightly different syntax. Most VPS guides assume Ubuntu, so apt is what you will see most often.

How do I keep my VPS secure?

Start with three steps: disable root password login and use SSH keys instead, enable a firewall (ufw) and only open ports you need, and run apt update && apt upgrade regularly to patch known vulnerabilities. These three steps block the vast majority of automated attacks.


Still stuck? Open a support ticket and our team will help you out.

Back to the blog