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

KeyWhat it does
TabCompletes the name of a command, file or folder you started to type. Press it twice to see all matches.
Arrow upBrings back the previous command, so that you can run it again or correct it.
Ctrl+CStops the command that is running.
Ctrl+RSearches the commands you typed before: press it and type a part of the command.

Files and Folders

CommandWhat it does
pwdShows the folder you are in.
ls -laLists the files of the folder with size, owner and date, hidden files too.
cd /var/wwwGoes to a folder. cd .. goes one level up, cd alone goes to your home folder.
mkdir -p data/photosCreates a folder, with the folders above it if they are missing.
cp notes.txt copy.txtCopies a file. For a folder: cp -r photos photos-copy.
mv old.txt new.txtRenames a file or folder, or moves it to another folder.
rm notes.txtDeletes a file. For a folder with everything in it: rm -r photos. There is no recycle bin.
ln -s /data/photos photosCreates a link named photos that leads to the folder /data/photos.
tar czf photos.tar.gz photosPacks 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

CommandWhat it does
cat notes.txtPrints a short file.
less /var/log/dpkg.logOpens a long file to read: arrows and Page Down move, /word searches, q closes.
tail -n 20 /var/log/dpkg.logShows the last 20 lines. tail -f keeps showing new lines until you press Ctrl+C.
nano notes.txtOpens a file in an editor: Edit Files on Your Server With nano.
grep -ri "error" /var/logFinds 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

CommandWhat it does
df -hShows how full each disk is.
du -sh /var/logShows how much space one folder takes.
lsblkLists the disks and their partitions.
free -hShows the memory: total, used and available.
htopShows the running programs with their processor and memory use. q closes it.
ps aux | grep nginxShows whether a program runs, and its number (PID) in the second column.
kill 1234Asks the program with this number to stop. kill -9 1234 stops it by force.
uptimeShows 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

CommandWhat it does
systemctl status sshShows whether a service runs, with its last messages.
systemctl restart nginxRestarts a service. start and stop work the same way.
systemctl enable --now nginxStarts a service now and after every restart of the server.
journalctl -u ssh -n 50Shows the last 50 log lines of a service.
rebootRestarts 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

CommandWhat it does
apt updateFetches the current list of programs and versions.
apt upgradeInstalls all available updates.
apt install htopInstalls a program. apt remove htop removes it.

More: Install, Update and Remove Programs on Ubuntu and Debian With apt.

Network

CommandWhat it does
ip -br aShows the network cards and the addresses of the server.
ping -c 3 1.1.1.1Tests whether the server reaches the Internet.
ss -tlnpLists the programs that wait for connections, with their ports: See Which Programs Listen on Your Linux Server.
curl -I https://example.orgAsks a website for its answer, without the page itself.
wget https://example.org/file.zipDownloads a file from a link into the current folder.

More: Check the Network of Your Linux Server: ping, mtr and iperf3.

Users and Rights

CommandWhat it does
whoamiShows the user you are logged in as.
sudo apt updateRuns one command as administrator when you are not root.
passwdChanges your password.
wShows who is logged in right now: Who Logged In to Your Linux Server? Check Logins and Failed Attempts.
chmod 600 notes.txtSets who may read and change a file; 600 means only the owner.
chown alex:alex notes.txtGives a file to another user and group.

More: Add Users and Give Them sudo on Your Linux Server.

Help

  • ls --help prints a short list of the options of a command.
  • man ls opens the full manual of a command; q closes it.
  • history lists the commands you typed.
  • exit ends the SSH session.

Good to Know

Was this answer helpful? 0 Users Found This Useful (0 Votes)