Basic Linux Commands: The 50 You Need to Manage a Server
The Linux commands that cover almost everything you'll do on a server: moving around, files and folders, reading files and logs, searching, permissions, processes, disk and memory, networking, packages and services — each with a one-line explanation.
Once your app lives on a Linux server, you'll be typing commands into a terminal over SSH. You don't need hundreds. These cover nearly everything. (The terminal for complete beginners, How to SSH into a server)
Moving around
pwd # where am I?
ls # list files
ls -la # list all files (including hidden) with details
cd /srv/myapp # go to a folder
cd .. # up one level
cd ~ # your home folder
cd - # back to the previous folder
Files and folders
mkdir logs # make a folder
mkdir -p a/b/c # make nested folders
touch notes.txt # create an empty file
cp a.txt b.txt # copy
cp -r src/ backup/ # copy a folder
mv old.txt new.txt # move or rename
rm file.txt # delete a file (no recycle bin!)
rm -r folder/ # delete a folder and everything in it — be careful
ln -s /srv/app/current app # create a shortcut (symlink)
There's no undo for rm. Double-check paths, especially with -r. (File paths explained)
Reading files
cat config.yml # print a whole file
less app.log # scroll through a file (q to quit, / to search)
head -n 20 app.log # first 20 lines
tail -n 50 app.log # last 50 lines
tail -f app.log # follow new lines live — great for logs
nano .env # edit a file (Ctrl+O save, Ctrl+X exit)
Searching
grep "ERROR" app.log # lines containing ERROR
grep -r "DATABASE_URL" /srv/myapp # search a folder recursively
grep -i "timeout" app.log # case-insensitive
find /srv -name "*.log" # find files by name
find . -size +100M # files over 100 MB
Permissions and ownership
ls -l # see permissions and owners
chmod +x deploy.sh # make a script executable
chmod 600 .env # only the owner can read/write
chown app:app -R /srv/myapp # change owner
sudo command # run a command as administrator
(Linux file permissions: chmod 755, 644)
Processes
ps aux # all running processes
ps aux | grep node # find a particular one
top # live view (q to quit); htop is friendlier if installed
kill 1234 # ask process 1234 to stop
kill -9 1234 # force it
(How to kill a process in Linux)
Disk and memory
df -h # free disk space per drive
du -sh * # size of each item in this folder
du -sh /var/log # size of one folder
free -h # memory usage
uptime # how long it's been up, and load
A full disk breaks everything — check df -h first when things go strange. (No space left on device)
Networking
curl -I https://example.com # check a website responds
curl http://127.0.0.1:3000 # check your app locally
ss -tlnp # what's listening on which port
ping example.com # is a host reachable?
dig example.com # DNS lookup
ip a # this server's IP addresses
(What is curl?, Ports explained)
Packages (Debian/Ubuntu)
sudo apt update # refresh the package list
sudo apt upgrade # install updates
sudo apt install htop # install a package
sudo apt remove htop # remove it
Services and logs
sudo systemctl status nginx # is a service running?
sudo systemctl restart myapp
journalctl -u myapp -f # follow a service's logs
Handy extras
history # commands you've run
Ctrl+R # search your command history
Ctrl+C # stop the current command
clear # clear the screen
command --help # quick help for most commands
man command # full manual
Two operators worth knowing: | sends one command's output into another (ps aux | grep node), and > writes output to a file (> overwrites, >> appends). (Bash scripting for beginners)
Long-running work
Close your SSH session and anything you started in it stops — unless you run it inside tmux. (tmux cheat sheet)
EasySpawn gives you a terminal on your server from any browser — and if you'd rather not remember any of these, ask Claude Code in plain English. See how it works or join the waitlist.
Related: The Terminal for Complete Beginners · What Is Linux? · How to SSH Into a Server · Bash Scripting for Beginners
Keep reading
How to SSH Into a Server (Mac, Windows and Linux)
SSH lets you open a terminal on a remote server securely. How to connect from macOS, Windows and Linux, logging in with a password vs an SSH key, the first-connection fingerprint prompt, a config file shortcut, and fixes for the common connection errors.
What Is Linux? A Beginner's Guide for People Building Apps
Linux runs most of the world's servers — including, probably, the one your app will live on. What Linux is, kernels vs distributions, Ubuntu vs Debian vs Alpine, how it differs from Windows and macOS, and the handful of Linux facts that prevent deploy bugs.