Linux Commands for Beginners: Your First 30 Commands
Learn the 30 Linux commands every engineer uses daily. Covers filesystem navigation, file manipulation, search, and getting help — no prior terminal experience needed.
Before you begin
- A Linux terminal, macOS Terminal, or WSL on Windows
- No prior command-line experience needed
Linux Commands for Beginners: Your First 30 Commands
Every engineer who works with servers, containers, or cloud infrastructure spends a significant portion of their day in a terminal. Kubernetes, CI/CD pipelines, SSH sessions, Docker — all of it assumes you're comfortable at the command line. This tutorial gets you there from scratch.
By the end you'll have 30 commands memorised, understand how the Linux filesystem works, and be able to find, create, move, and inspect files without touching a mouse.
Why the Terminal?
Three reasons the terminal beats a GUI for engineering work:
- Speed — A three-second CLI command replaces five minutes of clicking through a file manager.
- Scripting — You can chain commands together and automate repetitive tasks.
- Remote access — Servers don't have GUIs. SSH gives you a terminal and nothing else.
How Linux Organises Files
Linux uses a single tree rooted at / (called the root). Everything — disks, devices, processes — is a file somewhere under /.
/
├── bin/ # Essential system binaries (ls, cp, mv)
├── etc/ # Configuration files
├── home/ # User home directories (/home/ajeet)
├── var/ # Variable data — logs, caches
├── tmp/ # Temporary files (cleared on reboot)
├── usr/ # User programs and libraries
└── proc/ # Virtual filesystem — running kernel info
Your home directory is ~. It's shorthand for /home/yourusername (or /root if you're the root user).
1. Where Am I? — pwd
pwdprint working directory. Tells you where you are in the tree. Always run this if you're disoriented.
/home/ajeet/projects
2. What's Here? — ls
ls # List files in the current directory
ls /etc # List files in /etc
ls -l # Long format: permissions, owner, size, date
ls -la # Long format + hidden files (dotfiles)
ls -lh # Human-readable file sizes (KB, MB)The -l output looks like this:
-rw-r--r-- 1 ajeet ajeet 4096 Jun 1 10:00 config.yaml
drwxr-xr-x 3 ajeet ajeet 96 Jun 1 09:00 scripts/
The first character: - = file, d = directory, l = symlink.
3. Move Around — cd
cd /etc # Go to /etc (absolute path)
cd projects # Go into the projects/ subfolder (relative)
cd .. # Go up one level
cd ../.. # Go up two levels
cd ~ # Go home
cd - # Go back to previous directoryAbsolute paths start with /. Relative paths don't.
4. Create Directories — mkdir
mkdir logs # Create logs/
mkdir -p app/config/secrets # Create nested directories in one shot-p means "create parents as needed" — without it, mkdir app/config/secrets fails if app/ doesn't exist.
5. Create Empty Files — touch
touch app.log
touch notes.txt config.yamltouch creates an empty file if it doesn't exist. It also updates the modification timestamp if the file already exists — useful for triggering watches.
6. Copy Files and Directories — cp
cp config.yaml config.yaml.bak # Copy a file
cp -r src/ src-backup/ # Copy a directory recursivelyAlways make a backup before editing config files: cp nginx.conf nginx.conf.bak.
7. Move and Rename — mv
mv old-name.txt new-name.txt # Rename
mv config.yaml /etc/app/ # Move to a different directory
mv *.log /var/logs/archive/ # Move all .log filesmv is how you rename files. Linux does have a rename command but it's for batch renames with regex patterns — mv is simpler for single files.
8. Remove Files and Directories — rm
rm file.txt # Delete a file
rm -r old-project/ # Delete a directory and everything inside
rm -rf dist/ # Force delete without prompts (use with care)Warning: Linux has no Recycle Bin.
rmis permanent. Double-check paths before runningrm -rf.
9. View File Contents — cat, less, head, tail
cat config.yaml # Print entire file to terminal
less application.log # Paginated view (q to quit, / to search)
head -20 server.log # First 20 lines
tail -50 server.log # Last 50 lines
tail -f server.log # Follow live updates (great for log watching)Use less for large files — cat on a 500MB log will flood your terminal.
10. Search Inside Files — grep
grep "ERROR" app.log # Lines containing ERROR
grep -i "error" app.log # Case-insensitive
grep -r "database_url" ./config/ # Search recursively in a directory
grep -n "timeout" server.conf # Show line numbers
grep -v "DEBUG" app.log # Lines that do NOT contain DEBUGgrep is one of the most used commands in engineering work. Learn -r, -i, -n, and -v early.
11. Find Files — find
find . -name "*.yaml" # All YAML files under current dir
find /etc -name "nginx.conf" # Find nginx.conf in /etc
find . -type d -name "node_modules" # Find directories named node_modules
find . -mtime -1 # Files modified in the last 24 hours
find . -size +100M # Files larger than 100MBfind searches the actual filesystem — unlike locate which uses a cached index. It's slower but always current.
12. Get Help — man and --help
man ls # Full manual page for ls
man grep # Full manual page for grep
ls --help # Quick usage summary
grep --help # Quick usage summaryman opens a paginated reader. Press q to quit, / to search, n to jump to the next match.
If the man page is overwhelming, tldr (install with brew install tldr or apt install tldr) gives practical examples:
tldr tar # Shows the 5 most common tar uses
tldr find13. Who Am I and Where? — whoami, hostname, uname, date
whoami # Your current username
hostname # The machine's name
uname -a # Kernel name, version, architecture
date # Current date and timeUseful when you're SSH'd into multiple servers and need to confirm which one you're on.
Quick Reference: All 30 Commands
| Command | What it does |
|---|---|
pwd | Print working directory |
ls | List files |
ls -la | List all files with details |
cd <dir> | Change directory |
cd .. | Go up one level |
cd ~ | Go to home directory |
mkdir <dir> | Create directory |
mkdir -p <path> | Create nested directories |
touch <file> | Create empty file |
cp <src> <dst> | Copy file |
cp -r <src> <dst> | Copy directory |
mv <src> <dst> | Move or rename |
rm <file> | Delete file |
rm -r <dir> | Delete directory |
cat <file> | Print file contents |
less <file> | Paginated file view |
head -n <num> <file> | First n lines |
tail -n <num> <file> | Last n lines |
tail -f <file> | Follow live updates |
grep <pattern> <file> | Search inside file |
grep -r <pattern> <dir> | Search recursively |
grep -i | Case-insensitive search |
grep -v | Invert match |
find . -name <pattern> | Find files by name |
find . -type d | Find directories |
man <cmd> | Full manual |
<cmd> --help | Quick help |
whoami | Current username |
hostname | Machine name |
uname -a | Kernel and architecture |
Common Mistakes to Avoid
Mistake 1: rm -rf / or rm -rf ./*
Always double-check what * expands to. Run ls * before rm *.
Mistake 2: Paths without quotes
rm my file.txt deletes two files: my and file.txt. Use rm "my file.txt".
Mistake 3: Editing the original instead of a backup
Before editing any config: cp file.conf file.conf.bak. Takes two seconds.
What's Next
These 30 commands cover daily navigation and file work. The natural next steps:
- Linux Commands for Intermediate Users — pipes, text processing with
sed/awk, process management, SSH, andcron - Linux Commands for Advanced Engineers —
strace,systemd, container primitives, and performance tuning
This tutorial covers Stage 1 of the Platform Engineering Roadmap — Linux & Systems Fundamentals is the foundation every other skill in that roadmap builds on.
Next in Linux Foundations
Linux Commands for Intermediate Users: Processes, Pipes & Networking
We built Podscape to simplify Kubernetes workflows like this — logs, events, and cluster state in one interface, without switching tools.
Struggling with this in production?
We help teams fix these exact issues. Our engineers have deployed these patterns across production environments at scale.