Linux Command Line Essentials for Developers and Support Engineers
Updated 28 Oct 2026 2 min read
On this page 12 sections
- 1Why the command line matters
- 2Moving around and managing files
- 3Viewing and searching
- 4Pipes and redirection: the superpower
- 5Permissions and ownership
- 6Processes and resources
- 7Services, logs and networking
- 8Environment variables and packages
- 9A tiny shell script
- 10Practice tasks
- 11Common interview questions
- 12Next steps
Why the command line matters
Most servers, cloud machines, containers and many development tools run Linux. Knowing the command line lets you work on remote machines, read logs, automate boring tasks and troubleshoot problems quickly. It is expected in DevOps, backend, support, QA and embedded roles, and it is a common interview topic.
You can practise on Windows with WSL (Windows Subsystem for Linux), in a virtual machine, on a Mac terminal (very similar) or in a free online terminal.
Moving around and managing files
pwd # where am I?
ls -la # list files, including hidden, with details
cd /var/log # change directory (cd .. goes up, cd ~ goes home)
mkdir projects # create a folder
touch notes.txt # create an empty file
cp a.txt backup.txt # copy
mv backup.txt old/ # move or rename
rm notes.txt # delete a file (no recycle bin!)
rm -r old/ # delete a folder and its contents; be careful
Safety habit: double-check the path before running rm -r, and never run commands you do not understand from the internet, especially with sudo.
Viewing and searching
cat file.txt # print a file
less app.log # scroll through a long file (q to quit)
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 debugging)
grep "ERROR" app.log # lines containing ERROR
grep -i -n "timeout" app.log # ignore case, show line numbers
grep -r "timeout" src/ # search recursively in a folder
find . -name "*.log" # find files by name
wc -l app.log # count lines
Pipes and redirection: the superpower
A pipe (|) sends the output of one command into the next.
# how many ERROR lines are in the log?
grep "ERROR" app.log | wc -l
# the five most common IP addresses in an access log (first column)
cut -d' ' -f1 access.log | sort | uniq -c | sort -nr | head -5
# save output to a file (overwrite) or append
ls -la > files.txt
echo "done" >> files.txt
Learn sort, uniq, cut, awk and sed gradually; together they handle a huge number of log-analysis jobs.
Permissions and ownership
ls -l shows something like -rwxr-xr--. The three groups are owner, group and others; each has r (read = 4), w (write = 2) and x (execute = 1).
chmod 755 script.sh # owner rwx (7), group r-x (5), others r-x (5)
chmod +x script.sh # make executable
chown user:group file # change owner and group
sudo command # run with administrator rights
Example: 644 means the owner can read and write, everyone else can only read.
Processes and resources
ps aux | grep java # find a process
top # live view of CPU and memory (htop is nicer)
kill 1234 # ask a process to stop (kill -9 forces it, last resort)
df -h # disk space per filesystem
du -sh * # size of each item in the current folder
free -h # memory usage
uptime # load average
A common troubleshooting question: "The server is slow. What do you check?" A good answer walks through load (top), memory (free), disk space and I/O (df), the application logs (tail, grep) and the network.
Services, logs and networking
systemctl status nginx # is a service running?
sudo systemctl restart nginx
journalctl -u nginx -n 100 # recent logs for a service
ping example.com # is a host reachable?
curl -I https://example.com # fetch HTTP headers
ss -tulpn # which ports are listening, and which process owns them
ssh user@server # connect to a remote machine
scp file.txt user@server:/tmp # copy a file over SSH
For more on how networking works, see computer networks interview guide.
Environment variables and packages
export API_URL="https://api.example.com"
echo $API_URL
printenv | grep API
sudo apt update && sudo apt install git # Debian/Ubuntu package install
A tiny shell script
#!/usr/bin/env bash
set -euo pipefail # stop on errors and unset variables
LOG="$1"
if [ ! -f "$LOG" ]; then
echo "File not found: $LOG" >&2
exit 1
fi
errors=$(grep -c "ERROR" "$LOG" || true)
echo "Found $errors error lines in $LOG"
Save it as count_errors.sh, make it executable with chmod +x count_errors.sh and run ./count_errors.sh app.log.
Practice tasks
- Create a folder structure with five files, then move, rename and delete some
- Write a one-line command that counts how many lines in a log contain "WARN"
- From a text file of words, print the three most frequent ones
- Make a script executable and run it
- Start a simple web server (
python3 -m http.server) and find which process is using its port withss
Common interview questions
- Difference between
>and>>; what is a pipe? - Explain file permissions
chmod 755 - How do you find a process and kill it?
- How do you check disk usage and find the biggest folders?
- Hard link vs soft link; what is the root directory?
- What does
grepdo, and how do you search recursively?
Next steps
Use Linux daily, then learn Docker and Kubernetes and Git. The operating systems guide explains what happens underneath.
Found this useful? Share it with a friend.