1. Home
  2. Blog
  3. Basic Linux VPS Commands: 15 Essentials for Beginners

Basic Linux VPS Commands: 15 Essentials for Beginners

A practical list of basic Linux VPS commands, organized by task, with examples and the precautions that help you avoid mistakes in the terminal.

The basic Linux VPS commands fit into a fairly short list, which usually covers navigation, file editing, permissions, service control and reading logs. That handles most of the day-to-day work on a server. The terminal can feel intimidating at first, but it works like a conversation with the machine, and the machine tends to respond consistently.

In this guide, each command comes with an example and a precaution. Feel free to save it and come back whenever you need it. 🙂

Why learn basic Linux VPS commands

A VPS server usually has no graphical interface. You manage everything from the terminal, and that is typically an advantage: the terminal is lightweight, lets you automate tasks and leaves more resources free for your website, bot or application.

You don't need to memorize hundreds of commands. Knowing a few of them, and knowing when to use each one, is enough to operate your VPS server with root access with confidence, regardless of the distribution.

Before you start: connecting to the server

The connection is made via SSH. In the terminal on your computer (or in PowerShell on Windows), use the username and IP address you received when your service was activated:

ssh root@SEU_IP

The first time, the system asks whether you trust the server; confirm and enter the password. If you are on a Linux VPS with Ubuntu, AlmaLinux or Debian, the procedure is the same.

An important precaution: as root, the system almost never asks for confirmation. A wrong command takes effect immediately. So read it twice before pressing Enter.

Commands for navigating and finding files

First, know where you are and what exists around you.

  1. pwd: shows the current directory.
  2. ls -la: lists files, including hidden ones, with permissions and owners.
  3. cd: changes directory. Example: cd /var/www. Use cd .. to go up one level.
  4. find: searches for files. Example: find /var/www -name "*.conf".

Tip: press the Tab key to autocomplete folder and file names. Besides saving typing, it prevents path errors.

Commands for creating, copying and deleting files

  1. mkdir: creates directories. Example: mkdir backups.
  2. cp: copies. Example: cp config.conf config.conf.bak.
  3. mv: moves or renames. Example: mv antigo.txt novo.txt.
  4. rm: deletes. Example: rm arquivo.txt.
  5. cat and nano: cat arquivo displays the contents on screen; nano arquivo opens a simple editor (save with Ctrl+O and exit with Ctrl+X).

To create an empty file, use touch arquivo.txt.

⚠️ Be careful with rm -rf. It can delete entire directories with no recycle bin and no way back. Before running it, run ls on the same path to check what will be removed. And avoid running rm -rf / or commands with empty variables.

A good habit: before editing a configuration file, make a copy with cp. If something goes wrong, you can get back in seconds.

Permissions and owners: chmod, chown and sudo

When you run ls -la, you see something like -rwxr-xr--. Read it in three blocks: owner, group and others. Each block can have r (read), w (write) and x (execute).

  1. chmod: changes permissions. Example: chmod +x script.sh makes the script executable. Avoid chmod 777, which grants broad permissions to all users.
  2. chown: changes the owner. Example: chown usuario:usuario arquivo.
  3. sudo: runs a command with administrator privileges, for that one time only.

The best practice is to create a regular user and use sudo when needed, instead of always working as root. It is safer and leaves less room for accidents.

Processes and resource usage: top, htop, ps and kill

Is your site slow? See who is consuming CPU and memory.

  • top: a real-time panel of processes. Exit with q.
  • htop: a friendlier version of top, with colors and arrow-key navigation. You may need to install it first.
  • ps aux: lists all processes. Combine it with a filter: ps aux | grep nginx.
  • kill: ends a process by its PID. Example: kill 1234. If it doesn't respond, kill -9 1234 forces it to stop.

Try a plain kill first, which asks the program to close gracefully. Keep -9 as a last resort and confirm the PID before running it: ending the wrong process can take down an important service.

Disk space and memory: df, du and free

  1. df -h: shows used and free space on each disk, in a human-readable format.
  2. **du -sh ***: shows how much space each folder in the current directory takes up. Great for finding what is filling up the disk.
  3. free -h: shows RAM and swap usage.

If the disk is nearly full, the server can start showing strange errors. This is usually caused by old logs, forgotten backups or temporary files. Start with df -h, then go into the large folders with du -sh.

Services with systemctl

Many programs, such as web servers and databases, run as services. systemctl is one of the tools used to control them:

systemctl status nginx
systemctl restart nginx
systemctl stop nginx
systemctl start nginx
systemctl enable nginx
  • status: shows whether the service is active and its latest messages.
  • restart: restarts it, useful after changing a configuration.
  • stop and start: stop and start it.
  • enable: makes the service start automatically when the server reboots.

If a service won't start, status is the first place to look. It usually points to the cause.

Logs: tail, journalctl and grep

Logs are the server's diary. When something goes wrong, the answer is almost always there.

  • tail -f /var/log/nginx/error.log: follows the file in real time. Exit with Ctrl+C.
  • journalctl -u nginx -n 50: shows the last 50 lines for the service.
  • grep: filters text. Example: grep "error" arquivo.log.

The combination tail -n 200 arquivo.log | grep -i error shows only recent errors. If you still can't make sense of the message, copy the relevant excerpt and contact HostMF support 24/7 (available in English and Portuguese); having the log on hand speeds up the response.

Updating the system with apt and dnf

Keeping the system up to date closes security vulnerabilities. The command depends on the distribution:

Distribution Update Install a program
Ubuntu / Debian apt update && apt upgrade apt install nome
AlmaLinux / CentOS dnf upgrade dnf install nome

If you use an Ubuntu VPS, you will usually use apt. On AlmaLinux, it is normally dnf. Before major updates, it is worth making a backup and preferably scheduling them for low-traffic hours.

Summary: quick reference table

Command What it does Example
pwd Shows the current folder pwd
ls Lists files ls -la
cd Changes folder cd /var/www
find Searches for files find / -name "*.log"
mkdir Creates a folder mkdir backups
cp / mv Copies / moves cp a.txt b.txt
rm Deletes rm a.txt
nano Edits a file nano config.conf
chmod / chown Permissions / owner chmod +x run.sh
sudo Runs as admin sudo apt update
top / htop Views processes htop
kill Ends a process kill 1234
df / du / free Disk and memory df -h
systemctl Controls services systemctl status nginx
tail / journalctl Reads logs tail -f erro.log

Best practices to avoid surprises in the terminal

  • Make a backup before major changes. Configuration, databases and website files.
  • Test on a small scale. Run the command in a test folder before applying it in production.
  • Don't paste commands you don't understand. If you found something on a forum, look up what each part does.
  • Check the path before deleting. Running ls before rm can save a lot.
  • Ask for help when you get stuck. Describing the error and sending the log resolves most cases.

Making mistakes is part of learning, and most mistakes can be fixed, especially when you have a backup.

Next step: practice on your own server

The terminal only feels natural with practice. Create a test folder, copy files, restart a service, read a log. Within a few days, these commands become habit.

If you don't have a server to train on yet, check out HostMF's Linux VPS plans, with immediate activation, and start practicing today.

Need a server to put this into practice?

Windows and Linux VPS with instant activation, NVMe SSD and 24/7 support.

View VPS plans
Cookies

By using this site, you automatically agree that we use cookies. For what?

I agree