You manage a Linux server by typing commands over SSH. You do not need many: the ones on this page cover almost all daily work. Each table is one kind of task, and the links lead to the guides that explain a topic in full. The examples use Ubuntu 26.04 LTS.
How to connect: How to Connect to a Linux Server via SSH.
Four Keys That Save the Most Time
| Key | What it does |
|---|---|
| Tab | Completes the name of a command, file or folder you started to type. Press it twice to see all matches. |
| Arrow up | Brings back the previous command, so that you can run it again or correct it. |
| Ctrl+C | Stops the command that is running. |
| Ctrl+R | Searches the commands you typed before: press it and type a part of the command. |
Files and Folders
| Command | What it does |
|---|---|
pwd | Shows the folder you are in. |
ls -la | Lists the files of the folder with size, owner and date, hidden files too. |
cd /var/www | Goes to a folder. cd .. goes one level up, cd alone goes to your home folder. |
mkdir -p data/photos | Creates a folder, with the folders above it if they are missing. |
cp notes.txt copy.txt | Copies a file. For a folder: cp -r photos photos-copy. |
mv old.txt new.txt | Renames a file or folder, or moves it to another folder. |
rm notes.txt | Deletes a file. For a folder with everything in it: rm -r photos. There is no recycle bin. |
ln -s /data/photos photos | Creates a link named photos that leads to the folder /data/photos. |
tar czf photos.tar.gz photos | Packs a folder into one file. Unpack it with tar xzf photos.tar.gz. |
More: File Permissions on Linux: Who May Read, Change and Run a File, Pack Folders Into Archives on Linux: tar, zip and Split Parts.
Read and Search
| Command | What it does |
|---|---|
cat notes.txt | Prints a short file. |
less /var/log/dpkg.log | Opens a long file to read: arrows and Page Down move, /word searches, q closes. |
tail -n 20 /var/log/dpkg.log | Shows the last 20 lines. tail -f keeps showing new lines until you press Ctrl+C. |
nano notes.txt | Opens a file in an editor: Edit Files on Your Server With nano. |
grep -ri "error" /var/log | Finds a word in all files of a folder; -i ignores capital letters. |
find /etc -name "sshd_config" | Finds a file by its name: Find Files on Your Linux Server by Name, Size, Date or Content. |
Disk, Memory and Programs
| Command | What it does |
|---|---|
df -h | Shows how full each disk is. |
du -sh /var/log | Shows how much space one folder takes. |
lsblk | Lists the disks and their partitions. |
free -h | Shows the memory: total, used and available. |
htop | Shows the running programs with their processor and memory use. q closes it. |
ps aux | grep nginx | Shows whether a program runs, and its number (PID) in the second column. |
kill 1234 | Asks the program with this number to stop. kill -9 1234 stops it by force. |
uptime | Shows how long the server has been running and how busy it is. |
More: What Fills the Disk and What Loads the Server, How to Use Additional Disks on a Linux Server.
Services and Logs
| Command | What it does |
|---|---|
systemctl status ssh | Shows whether a service runs, with its last messages. |
systemctl restart nginx | Restarts a service. start and stop work the same way. |
systemctl enable --now nginx | Starts a service now and after every restart of the server. |
journalctl -u ssh -n 50 | Shows the last 50 log lines of a service. |
reboot | Restarts the server. |
More: Keep a Program Running on Linux, A Service Does Not Start: Find Out Why, Find Errors in the Logs of Your Linux Server: journalctl.
Software
| Command | What it does |
|---|---|
apt update | Fetches the current list of programs and versions. |
apt upgrade | Installs all available updates. |
apt install htop | Installs a program. apt remove htop removes it. |
More: Install, Update and Remove Programs on Ubuntu and Debian With apt.
Network
| Command | What it does |
|---|---|
ip -br a | Shows the network cards and the addresses of the server. |
ping -c 3 1.1.1.1 | Tests whether the server reaches the Internet. |
ss -tlnp | Lists the programs that wait for connections, with their ports: See Which Programs Listen on Your Linux Server. |
curl -I https://example.org | Asks a website for its answer, without the page itself. |
wget https://example.org/file.zip | Downloads a file from a link into the current folder. |
More: Check the Network of Your Linux Server: ping, mtr and iperf3.
Users and Rights
| Command | What it does |
|---|---|
whoami | Shows the user you are logged in as. |
sudo apt update | Runs one command as administrator when you are not root. |
passwd | Changes your password. |
w | Shows who is logged in right now: Who Logged In to Your Linux Server? Check Logins and Failed Attempts. |
chmod 600 notes.txt | Sets who may read and change a file; 600 means only the owner. |
chown alex:alex notes.txt | Gives a file to another user and group. |
More: Add Users and Give Them sudo on Your Linux Server.
Help
ls --helpprints a short list of the options of a command.man lsopens the full manual of a command; q closes it.historylists the commands you typed.exitends the SSH session.
Good to Know
- Names are case sensitive.
Notes.txtandnotes.txtare two different files. - Put names with spaces between quotes:
cd "My Folder". - A command that runs for hours stops when you close SSH, unless you start it in tmux: Keep a Program Running on Linux.
- New here? Start with Linux Server: Quick Start Guide.
