10 Essential Linux Commands Every Beginner Should Know
Master 10 essential Linux commands every beginner and DevOps engineer should know to navigate the shell, manage files, and troubleshoot systems. Clear examples and quick tips help you gain command-line confidence fast.
A short introduction (2–3 sentences)
Linux is powerful because it gives you direct control over files, processes, and the system itself. This short guide covers 10 essential commands (grouped by task) that beginners should learn to become comfortable on the command line.
Navigating the filesystem: ls, cd, pwd
Knowing where you are and how to move around the filesystem is the first step.
- pwd — print working directory
- ls — list files and directories
- cd — change directory
Examples:
# Show the full path of your current directory
pwd
# List files, including hidden ones, with human-readable sizes
ls -lah
# Move into the Documents directory (relative) or to root (absolute)
cd Documents
cd /etc
# Go back to your home directory quickly
cd ~
Tips:
- Use ls -la to see hidden files (those beginning with a dot).
- Tab completion saves typing and avoids mistakes: start typing a name and press Tab to auto-complete.
Viewing and manipulating files: cat, less, head, tail, cp, mv, rm
Once you can navigate, you’ll frequently need to view and change files.
- cat — print a whole file to the terminal
- less — page through a file comfortably
- head/tail — view the start or end of a file
- cp — copy files or directories
- mv — move or rename
- rm — remove files (be careful)
Examples:
# Show the whole file (good for small files)
cat README.md
# Page through a long file interactively
less /var/log/syslog
# View first 10 lines or last 20 lines
head -n 10 file.txt
tail -n 20 file.txt
# Copy a file and a directory (-r for recursive)
cp file.txt file.backup.txt
cp -r project/ project_backup/
# Rename or move a file
mv oldname.txt newname.txt
# Remove a file (interactive prompt)
rm -i unwanted.tmp
# Remove a directory and its contents (dangerous)
rm -rf tmpdir/
Safety notes:
- Use rm -i to prompt before deletion.
- Prefer cp -r and double-check paths before destructive operations.
Working with permissions and privileges: chmod, chown, sudo
Linux enforces file permissions and user ownership. Understanding these prevents accidental lockouts and security problems.
- ls -l — shows permissions and ownership
- chmod — change file mode (permissions)
- chown — change file owner and group
- sudo — run commands with elevated privileges
Examples:
# See permissions (r=read, w=write, x=execute)
ls -l script.sh
# Make a script executable for the owner
chmod u+x script.sh
# Set exact permissions: owner rw, group r, others r (644)
chmod 644 file.txt
# Change owner to alice and group to staff
sudo chown alice:staff /var/www/html/index.html
# Run a command as root (be cautious)
sudo apt update
Quick rules:
- 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--
- Use sudo for commands that require root; avoid logging in as root long-term.
- Changing permissions to 777 (rwx for everyone) is usually a bad idea.
Searching and monitoring: grep, find, ps, top
Find files, search inside files, and watch processes and system resource use.
- grep — search text using patterns
- find — locate files by name, type, size, etc.
- ps/top/htop — view running processes and system load
Examples:
# Search for the string "error" in log files recursively
grep -R "error" /var/log/
# Search case-insensitively and show line numbers
grep -in "TODO" *.py
# Find all .txt files under current directory
find . -type f -name "*.txt"
# Find files larger than 100M
find / -type f -size +100M 2>/dev/null
# List processes and filter by name
ps aux | grep sshd
# Interactive process viewer (press q to quit)
top
# If available, htop is more user-friendly
htop
Practical patterns:
- Pipe output between commands: find . -name "*.log" | xargs grep "timeout"
- Use 2>/dev/null to hide permission-denied messages when scanning system directories.
Package management and getting help: apt/dnf/pacman, man, --help
Installing software and learning how commands work are everyday tasks.
- Different distributions use different package managers (apt for Debian/Ubuntu, dnf or yum for Fedora/CentOS, pacman for Arch).
- man pages and --help options explain usage.
Examples:
# Debian/Ubuntu: update package list and install git
sudo apt update
sudo apt install git
# Fedora: install a package using dnf
sudo dnf install git
# Arch: install a package using pacman
sudo pacman -S git
# Get help for commands
man ls
ls --help
# Read a man page and search inside it
man grep
# Within man: type /pattern and press n to navigate to next match
Notes:
- Always run sudo apt update (or equivalent) before installing to refresh package lists.
- man pages are authoritative and contain examples, options, and environment variables.
Common Pitfalls
- Running destructive commands without double-checking paths (e.g., rm -rf target) — always verify the path and consider using interactive flags.
- Confusing relative vs absolute paths — ./file and /file refer to very different locations; use pwd to confirm your current directory.
- Overly permissive permissions (chmod 777) or incorrect chown that locks out services — prefer least privilege and test changes on non-critical files first.
Next Steps
- Practice in a safe environment: use a virtual machine, Docker container, or WSL to try commands without risking your main system.
- Read more man pages and experiment with options: pick one command each day and learn two or three flags.
- Start automating small tasks with shell scripts: combine commands you use frequently into executable scripts.
This set of commands forms a practical foundation. As you become comfortable, explore shell scripting, networking tools (ssh, scp), and more advanced process and system management utilities.
👉 Explore more IT books and guides at dargslan.com.