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 Linux VPS. The IP address, username and password are on the service page in your VPS provider's control panel.
- 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:
root@vps1:~#Each part tells you something:
rootis the user you are logged in as.vps1is 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.
Tip: Always glance at the prompt before you press Enter. It tells you who you are and where you are, which are the two facts that decide what a command will do.
How a command is built
Most commands follow the same pattern:
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 -aand-lamean 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:
ls -la /etcLinux 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:
pwd/rootWhat 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:
ls
ls -laMove around (cd)
cd changes the current folder:
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)
clearwipes the screen. Your history is kept. You can also press Ctrl + L.exitcloses the shell and ends your SSH session. Ctrl + D does the same on an empty line.
Who am I? (whoami)
whoamiIt 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:
ls: cannot access '/var/lgo': No such file or directoryRead 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 needsudo.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:
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
pwdandlsbefore 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.
Warning: Be very careful with rm, especially rm -rf and wildcards such as *. Deleted files do not go to a trash folder and cannot be recovered without a backup.
If you lock yourself out of SSH, you can still reach the server through the browser console in your VPS provider's control panel.
Check it works
Run this short sequence. Each command should succeed without errors:
whoami
pwd
cd /etc
ls -l | head
cd
pwdYou 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 withapt(Ubuntu, Debian) ordnf(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
- Learn where things live: The Linux directory structure explained.
- Keep a reference handy: Linux commands cheat sheet for VPS owners.
- Finish your server setup with Linux VPS first steps.
