Almost every server, container and cloud machine you will work with as a DevOps engineer runs Linux. You do not need to memorise hundreds of commands, but a core set will save you hours every week. This guide groups the most useful ones by task, with examples you can try on any Linux machine, a virtual machine, or Windows with WSL.
Always be careful when running commands as an administrator. Practise on a test machine first, and read a command before you press Enter.
1. Moving Around and Managing Files
pwd # show the current directory ls -lah # list files with sizes, permissions and hidden files cd /var/log # change directory cd ~ # go to your home directory mkdir -p projects/demo # create a folder (and any missing parent folders) cp file.txt backup.txt # copy a file cp -r folder folder-bak # copy a folder mv old.txt new.txt # rename or move rm file.txt # delete a file (there is no recycle bin) rm -r folder # delete a folder and everything in it
Tip: be extremely careful with rm -r, especially with variables or wildcards. Check the path with ls first.
2. Reading and Editing Files
cat app.conf # print a whole file less app.log # scroll through a long file (press q to quit) head -n 20 app.log # first 20 lines tail -n 50 app.log # last 50 lines tail -f app.log # follow a log file live as it grows nano app.conf # simple terminal editor vim app.conf # powerful editor (press i to type, Esc then :wq to save)
The command tail -f is one of the most used tools for debugging, because it shows new log lines the moment they are written.
3. Searching
grep "error" app.log # lines that contain "error" grep -i "error" app.log # ignore upper/lower case grep -r "DB_HOST" /etc/myapp # search inside all files in a folder grep -v "debug" app.log # lines that do NOT contain "debug" find /var/log -name "*.log" # find files by name find . -type f -mtime -1 # files changed in the last day
4. Combining Commands with Pipes
The pipe symbol | sends the output of one command into another. This is where Linux becomes powerful:
grep "ERROR" app.log | wc -l cut -d' ' -f1 access.log | sort | uniq -c | sort -nr | head -10 ps aux | grep nginx ls -l > files.txt echo "done" >> files.txt
5. Permissions and Ownership
Every file has an owner, a group and permissions for read (r), write (w) and execute (x). The command ls -l shows them, for example -rwxr-xr--.
chmod +x deploy.sh # make a script executable chmod 644 file.txt # owner can read/write, others can read chmod 600 id_rsa # private keys must not be readable by others chown ubuntu:ubuntu app/ # change owner and group sudo command # run one command as administrator
Avoid chmod 777
Giving everyone full access to a file or folder is a common shortcut that creates security problems. Find the exact permission the program needs and grant only that.
6. Processes and System Health
top # live view of CPU and memory use (q to quit) htop # friendlier version, if installed ps aux # list all running processes kill 1234 # ask process 1234 to stop kill -9 1234 # force it to stop (last resort) free -h # memory usage df -h # disk space per filesystem du -sh /var/log/* # how big is each item in a folder uptime # how long the machine has been up, and load
When a server is slow, the usual first questions are: is the CPU busy (top), is memory full (free -h), and is the disk full (df -h)?
7. Services and Logs with systemd
Most modern Linux distributions use systemd to start and manage background services.
sudo systemctl status nginx # is the service running? sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx sudo systemctl enable nginx # start automatically at boot journalctl -u nginx -n 100 # last 100 log lines for the service journalctl -u nginx -f # follow the logs live
8. Networking
ip addr # show IP addresses ping -c 4 google.com # test connectivity curl -I https://example.com # fetch only the HTTP headers curl -s https://api.example.com/health # call an API quietly ss -tulpn # which programs are listening on which ports nslookup example.com # check DNS
If a website is down, curl -I shows the HTTP status, ss -tulpn shows whether your app is really listening on the port, and nslookup checks whether the domain points where you expect.
9. Remote Access and File Transfer
ssh -i mykey.pem ubuntu@203.0.113.10 # log in to a remote server scp backup.tar.gz ubuntu@203.0.113.10:/home/ubuntu/ # copy a file to a server rsync -avz ./site/ ubuntu@203.0.113.10:/var/www/site/ # sync a folder efficiently
10. Installing and Updating Software
sudo apt update sudo apt install nginx sudo yum install nginx # or: sudo dnf install nginx tar -czf backup.tar.gz folder/ tar -xzf backup.tar.gz
Habits That Make You Faster
- Press Tab to auto-complete file names and commands.
- Press the Up arrow or Ctrl+R to search your command history.
- Use
man command or command --help when you forget an option. - Write repeated tasks as small shell scripts and keep them in Git.
- Learn to read error messages carefully; the answer is often in the last line.
What to Learn Next
With these commands you can inspect a server, read its logs and fix common problems. The next steps are shell scripting, cron jobs for scheduling, and then the tools built on top of Linux: Docker, Kubernetes and Terraform. Our DevOps roadmap shows the full order, and the free tutorials page has video lessons including Linux.
Build Your Linux and DevOps Skills
Learn Linux, AWS, Docker, Kubernetes and CI/CD through live projects with mentor support.
Apply for the Program →