New to Linux, or about to start your first support role? These are the commands you’ll use in your first week, grouped by task. Each table shows what the command does and a real example. Once you’re comfortable, move on to the production support cheat sheet.
Originally published January 2021, rewritten November 2026.
Jump to
- 1. Moving around
- 2. Viewing files
- 3. Creating, copying, moving and deleting
- 4. Finding files and text
- 5. Disk and system information
- 6. Processes and jobs
- 7. Permissions, ownership and users
- 8. Archives and downloads
- 9. Combining commands
- 10. Keyboard shortcuts
- 11. Getting help
- Practice lab: 10 steps
Three things to know first
- Everything is case-sensitive.
Logs,logsandLOGSare three different directories. - Paths are absolute or relative. An absolute path starts at the root,
/(for example/var/log/app.log). A relative path starts from where you are (for examplelogs/app.log)..means “here”,..means “one level up” and~means your home directory. - There is no recycle bin. Deleted files are gone, so read commands twice before pressing Enter.
1. Moving around
| Command | What it does | Example |
|---|---|---|
pwd | Print the directory you’re in | pwd → /home/rakesh |
ls | List what’s in a directory | ls /var/log |
ls -l | Long listing: permissions, owner, size, date | ls -lh (human-readable sizes) |
ls -a | Include hidden files (names starting with .) | ls -la ~ |
ls -lt | Sort by modification time, newest first | ls -lt /app/logs | head |
cd dir | Change directory | cd /app/logs |
cd .. | Go up one level | cd ../config |
cd or cd ~ | Go to your home directory | cd |
cd - | Go back to the previous directory | cd - |
2. Viewing files
| Command | What it does | Example |
|---|---|---|
cat | Print a whole file (best for short files) | cat app.conf |
less | Scroll through a file. /word searches, n finds next, G jumps to the end, q quits | less app.log |
head | First 10 lines (or -n N) | head -n 20 trades.csv |
tail | Last 10 lines (or -n N) | tail -n 50 app.log |
tail -f | Follow a file as new lines are written; Ctrl+C to stop | tail -f app.log |
wc -l | Count lines | wc -l trades.csv |
diff | Show the lines that differ between two files | diff app.conf app.conf.bak |
Avoid cat on large log files: it can flood your terminal with millions of lines. Use less or tail instead.
3. Creating, copying, moving and deleting
| Command | What it does | Example |
|---|---|---|
touch | Create an empty file (or update its timestamp) | touch notes.txt |
mkdir | Create a directory | mkdir reports |
mkdir -p | Create nested directories in one go | mkdir -p reports/2026/11 |
cp | Copy a file | cp app.conf app.conf.bak |
cp -r | Copy a directory and everything in it | cp -r config config_backup |
mv | Move or rename | mv report.csv archive/mv old.txt new.txt |
rm | Delete a file | rm notes.txt |
rm -i | Delete, but ask first (safer) | rm -i *.tmp |
rm -r | Delete a directory and its contents | rm -r old_reports |
rmdir | Delete an empty directory only | rmdir empty_dir |
ln -s | Create a shortcut (symbolic link) | ln -s /app/releases/2.4 current |
Golden rule: before any rm -r, run pwd and ls to check exactly where you are and what you’re about to delete. Before editing a config file, copy it first with a date: cp app.conf app.conf.$(date +%Y%m%d).
4. Finding files and text
| Command | What it does | Example |
|---|---|---|
grep | Find lines containing text | grep ERROR app.log |
grep -i | Ignore upper/lower case | grep -i timeout app.log |
grep -r | Search every file under a directory | grep -r "db.host" /app/config |
grep -c | Count matching lines | grep -c ERROR app.log |
find by name | Find files by name under a directory | find /app -name "*.conf" |
find by type | Directories only (-type d) or files only (-type f) | find /app -type d -name logs |
find by age | Files modified in the last N days | find /app/logs -mtime -1 |
locate | Fast search of a pre-built index of file names | locate -i settlement |
which | Show where a command lives | which python3 |
locate is fast but uses an index that’s usually updated once a day, so it may miss new files. find is slower but always up to date.
5. Disk and system information
| Command | What it does | Example |
|---|---|---|
df -h | Free and used space on each filesystem | df -h /app |
du -sh | Total size of a directory | du -sh /app/logs |
free -h | Memory and swap usage | free -h |
uptime | How long the server has been up, and its load | uptime |
hostname | The server’s name (always check before changing anything) | hostname |
hostname -I | The server’s IP addresses | hostname -I |
uname -a | Kernel and OS details | uname -r |
whoami | Which user you’re logged in as | whoami |
date | Current date, time and time zone | date |
6. Processes and jobs
| Command | What it does | Example |
|---|---|---|
top | Live view of running processes and CPU/memory use; q quits | top |
ps -ef | List every process on the system | ps -ef | grep java |
pgrep -a | Find a process by name and show its PID | pgrep -a pricing |
kill PID | Ask a process to stop cleanly (SIGTERM, signal 15) | kill 4321 |
kill -9 PID | Force a process to stop immediately (SIGKILL). Last resort: no cleanup happens | kill -9 4321 |
command & | Run a command in the background | ./report.sh & |
jobs | List background jobs started from this shell | jobs |
fg / bg | Bring a job to the foreground / resume it in the background | fg %1 |
history | Commands you’ve run before | history | grep ssh |
7. Permissions, ownership and users
Every file has an owner, a group, and read (r), write (w) and execute (x) permissions for the owner, the group and everyone else. In ls -l output, -rwxr-x--- means the owner can do everything, the group can read and run it, and others have no access.
| Command | What it does | Example |
|---|---|---|
chmod +x | Make a script executable | chmod +x deploy.sh |
chmod 644 | Set permissions with numbers (r=4, w=2, x=1 for owner, group, others) | chmod 640 app.conf |
chown | Change a file’s owner and group | sudo chown appuser:appgroup app.conf |
sudo | Run one command with admin rights | sudo systemctl status pricing |
id | Your user ID and groups | id |
useradd / passwd | Create a user, then set their password (admins only) | sudo useradd -m johnsudo passwd john |
userdel | Remove a user (admins only) | sudo userdel john |
Use sudo only when you need it. In a bank, admin actions are logged and audited, and most support engineers only have sudo rights for specific commands. sudo -l shows yours.
8. Archives and downloads
| Command | What it does | Example |
|---|---|---|
tar czf | Create a compressed archive | tar czf logs.tar.gz /app/logs |
tar tzf | List what’s inside without extracting | tar tzf logs.tar.gz |
tar xzf | Extract an archive | tar xzf logs.tar.gz -C /tmp |
gzip / gunzip | Compress or decompress a single file | gzip app.log.1 |
zip / unzip | Work with .zip files (handy for sharing with Windows users) | unzip release.zip |
wget / curl -O | Download a file from a URL | curl -O https://repo.internal/tool.tar.gz |
An easy way to remember the tar letters: create, extract, list; z for gzip; f for “file name follows”.
9. Combining commands
Linux gets powerful when you connect small commands together.
| Symbol | Meaning | Example |
|---|---|---|
| | Pipe: send one command’s output into the next | grep ERROR app.log | wc -l |
> | Write output to a file (overwrites it) | grep ERROR app.log > errors.txt |
>> | Append output to a file | echo "checked $(date)" >> notes.txt |
; | Run commands one after another, regardless of success | date; uptime |
&& | Run the next command only if the previous one succeeded | cd /app/logs && ls -lt |
|| | Run the next command only if the previous one failed | ping -c1 dbhost || echo "unreachable" |
A real example: the 10 most common errors in a log.
grep ERROR app.log | sort | uniq -c | sort -rn | head
Use && rather than ; when it matters: cd /wrong/path; rm -r * would delete files in whatever directory you happened to be in, while cd /wrong/path && rm -r * stops safely when the cd fails.
10. Keyboard shortcuts
| Keys | What they do |
|---|---|
| Tab | Auto-complete a command, file or directory name (press twice to see options) |
| ↑ / ↓ | Scroll through previous commands |
| Ctrl+R | Search your command history as you type |
| Ctrl+C | Stop the running command |
| Ctrl+Z | Pause the running command (resume with fg) |
| Ctrl+D | Log out of the current shell |
| Ctrl+L | Clear the screen (same as clear) |
| Ctrl+A / Ctrl+E | Jump to the start / end of the line |
| Ctrl+S / Ctrl+Q | Freeze / unfreeze the terminal (if it “hangs” after Ctrl+S, press Ctrl+Q) |
11. Getting help
| Command | What it does | Example |
|---|---|---|
man | Full manual page; / to search, q to quit | man tail |
--help | Quick summary of a command’s options | grep --help |
whatis | One-line description of a command | whatis df |
apropos | Find commands related to a keyword | apropos compress |
Practice lab: 10 steps
Try this on any Linux machine, WSL on Windows, or the Mac Terminal (most commands are the same). It’s completely safe: everything happens in a practice folder.
- Go to your home directory and confirm where you are.
- Create a folder called
lab/logsin one command. - Inside it, create a file
app.logcontaining three lines: two with INFO and one with ERROR. - Show only the ERROR line.
- Count how many lines contain INFO.
- Make a dated backup copy of
app.log. - List the folder, newest file first, with human-readable sizes.
- Archive the
labfolder intolab.tar.gzand list its contents. - Check how much space the
labfolder uses. - Delete the
labfolder safely, then confirm it’s gone.
Show answers
cd ~ && pwd # 1
mkdir -p lab/logs # 2
cd lab/logs
echo "08:00 INFO service started" > app.log # 3
echo "08:01 INFO connected to db" >> app.log
echo "08:02 ERROR order rejected" >> app.log
grep ERROR app.log # 4
grep -c INFO app.log # 5 -> 2
cp app.log app.log.$(date +%Y%m%d) # 6
ls -lth # 7
cd ~ && tar czf lab.tar.gz lab && tar tzf lab.tar.gz # 8
du -sh lab # 9
ls lab && rm -r lab lab.tar.gz && ls # 10
Next steps
- Linux cheat sheet for production support engineers: triage, logs, processes, TLS, FIX and MQ.
- Linux networking commands: a troubleshooting ladder for “the app can’t connect”.
- Bash & Linux interview prep: how these commands come up in interviews.