Linux command line basics for your first VPS

Learn how the Linux prompt works, how commands, options and arguments fit together, and the first commands you need to find your way around a new VPS.

  • Beginner
  • Linux VPS
  • 6 min read

By RunRacks Team · Published

A Linux VPS has no desktop. You manage it by typing commands into a shell over SSH. This guide explains what you see when you log in, how a command is built, and the handful of commands you will use every day on Ubuntu, Debian, AlmaLinux or Rocky Linux.

Before you start

  • A RunRacks Linux VPS. The IP address, username and password are on the service page in your Dashboard.
  • An SSH connection to the server. If you have not logged in yet, follow Connect to your Linux VPS with SSH first.
  • Nothing else. Every command below is safe to run and changes nothing on the server.

Read the prompt

After you log in, the shell shows a prompt and waits for input. It usually looks like this:

Text
root@vps1:~#

Each part tells you something:

  • root is the user you are logged in as.
  • vps1 is the server's hostname.
  • ~ is the folder you are in. The tilde is short for your home directory.
  • # means you are root, the all-powerful admin user. A normal user sees $ instead.

How a command is built

Most commands follow the same pattern:

Text
command  -options  arguments
  • The command is the program to run, such as ls.
  • Options (also called flags) change how it behaves. Short options use one dash and one letter, such as -l. Long options use two dashes and a word, such as --all. Short options can be combined, so -l -a and -la mean the same thing.
  • Arguments tell the command what to work on, usually a file or folder name.

For example, this lists the contents of /etc in long format, including hidden files:

Terminal
ls -la /etc

Linux is case-sensitive. ls works, LS does not, and File.txt and file.txt are two different files.

Your first commands

Where am I? (pwd)

pwd prints the full path of the current folder:

Terminal
pwd
Text
/root

What is here? (ls)

ls lists files and folders. Add -l for details (permissions, owner, size, date) and -a to include hidden files whose names start with a dot:

Terminal
ls
ls -la

Move around (cd)

cd changes the current folder:

Terminal
cd /var/log
cd ..
cd ~

The first line goes to an absolute path, cd .. goes up one level, and cd ~ (or just cd) returns to your home folder. For more detail, see Navigate folders in Linux with cd, ls and pwd.

Tidy up and leave (clear, exit)

  • clear wipes the screen. Your history is kept. You can also press Ctrl + L.
  • exit closes the shell and ends your SSH session. Ctrl + D does the same on an empty line.

Who am I? (whoami)

Terminal
whoami

It prints the current username. It is handy after switching users or when a prompt has been customised.

Read what the server tells you

Linux follows a simple convention: no news is good news. Many commands print nothing when they succeed. If you see the prompt again with no message, the command most likely worked.

When something fails, the error usually names the problem:

Text
ls: cannot access '/var/lgo': No such file or directory

Read errors from left to right. The first word is the program that complained, then the thing it was working on, then the reason. Common reasons:

  • No such file or directory: a typo in the path, or you are in a different folder than you think.
  • Permission denied: your user is not allowed to do that. You may need sudo.
  • command not found: the program is not installed, or the name is misspelled.

To check whether the last command succeeded, print its exit status. Zero means success; anything else means an error:

Terminal
echo $?

Safe habits for new VPS owners

The shell does exactly what you type, with no undo and no recycle bin. A few habits prevent most accidents:

  • Use Tab completion. Type the first letters of a file or command and press Tab. The shell fills in the rest, which avoids typos in paths.
  • Look before you change. Run pwd and ls before deleting or moving files.
  • Copy commands carefully. When you paste from a guide, read the whole line before pressing Enter.
  • Back up config files before editing them, for example cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.
  • Work as a normal user with sudo, not as root, once your server is set up. See Create a sudo user on Linux.
  • Stop a stuck command with Ctrl + C. It cancels the running program and gives you the prompt back.

If you lock yourself out of SSH, you can still reach the server through the browser console in the Dashboard control panel.

Check it works

Run this short sequence. Each command should succeed without errors:

Terminal
whoami
pwd
cd /etc
ls -l | head
cd
pwd

You should see your username, your home folder, the first lines of the /etc listing, and your home folder again at the end.

Troubleshooting

  • `command not found`: check the spelling and case. If it is spelled correctly, the package is not installed. Install it with apt (Ubuntu, Debian) or dnf (AlmaLinux, Rocky).
  • The terminal seems frozen: a program is still running or waiting for input. Press Ctrl + C. If you pressed Ctrl + S by accident, press Ctrl + Q to resume output.
  • A `>` prompt appears and nothing happens: you opened a quote or bracket without closing it. Press Ctrl + C and type the command again.
  • Typing your password shows nothing: this is normal. Linux does not echo passwords, not even as dots. Type it and press Enter.

Next steps

Was this guide helpful?

Still stuck?

Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.

Getting started

Edit files with nano: a beginner's guide

Open, edit, search and save files with the nano text editor on a Linux server, including cutting and pasting lines, showing line numbers and safely editing system config files with sudo.

  • Beginner
  • Linux VPS
  • 5 min read

Getting started

Your first hour with a new RunRacks server

A step-by-step roadmap for the first hour after your RunRacks server is delivered, from finding your login details to changing the password, updating the OS and picking your next guides.

  • Beginner
  • All
  • 5 min read

Getting started

How to choose a server location

Pick a data center location based on where your users, broker or team are, confirm it with ping tests, and weigh the legal and latency points that come with each choice.

  • Beginner
  • All
  • 4 min read