Linux Command-Line (Bash Shell)
View this project on GitHub
The terminal + Bash give precise control over files, processes, networking, and more. Below are core commands with examples and screenshots.
Commands you type are small programs (e.g., /bin/ls, /bin/cp). The terminal sends your input to the shell, usually Bash (Bourne Again Shell), which parses and executes them.
How a Command Runs
- You type a command (e.g.,
ls -l).
- The terminal forwards it to the shell (Bash).
- Bash parses the command (syntax, expansions, variables).
- It resolves the executable (e.g.,
/bin/ls) and runs it.
- Output is printed back to the terminal.
1) Navigating & Managing Directories
Commands
- pwd — print current directory path
- cd — change directories
- mkdir / rmdir — create or remove (empty) directory
- ls — list directory contents
pwd
cd /Documents
mkdir new_folder
rmdir new_folder
ls -la
2) File Creation & Editing
Commands
- touch — create or update timestamp
- file — identify file type
- nano — beginner-friendly editor
- vi/vim — powerful modal editor
touch new_file.txt
file new_file.txt
nano new_file.txt
vi new_file.txt
3) Viewing & Searching File Content
Commands
- cat — print file contents
- ls -l — long listing (perms, owner, size, date)
- tree — directory tree view
- grep — pattern search
- head / tail — first/last lines
cat new_file.txt
ls -l /home/user
tree
grep "search_term" new_file.txt
head -n 5 new_file.txt
tail -n 5 new_file.txt
4) Archiving & Locating Files
Commands
- tar — create/extract archives
- locate — indexed filename search
- find — real-time search by name/size/time/etc.
tar -cvf archive.tar /home/user/documents
locate filename.txt
find /home -name "filename.txt"
5) Users & Permissions
Commands
- whoami — print current user
- sudo — run command with elevated privileges
- chmod — change permissions
- chown — change owner/group
- useradd / passwd / userdel — manage accounts
whoami
sudo apt update
chmod 755 new_file.txt
chown user:user new_file.txt
sudo useradd newuser
sudo passwd newuser
sudo userdel newuser
6) System Monitoring & Maintenance
Commands
- df -h — filesystem space (human-readable)
- du -sh — directory size summary
- top / htop — live process viewers
- uname -a — kernel/system info
df -h
du -sh /home/user
top
htop
uname -a
7) Package Management
Commands
- apt — Debian/Ubuntu package tool
- dnf — Fedora/RHEL package tool
- dpkg — low-level .deb installer
sudo apt install nano
sudo dnf update
sudo dpkg -i package.deb
8) Services & Processes
Commands
- systemctl — control system services (start/stop/enable/status)
- kill — send signals to processes by PID
sudo systemctl restart ssh
kill -9 <PID>
9) System Operations
Commands
- shutdown — safely power off
- reboot — restart the system
sudo shutdown now
sudo reboot
10) Networking & Data Retrieval
Commands
- wget — non-interactive downloader (HTTP/HTTPS/FTP)
- curl — flexible client for transfers, APIs, tests
wget http://example.com/file.zip
curl http://example.com/file.zip -o file.zip
11) Utilities & Time
Commands
- history — list your recent commands
- echo — print text/variables
- cal — calendar
- time — measure a command's runtime
- date — current date/time
history
echo "Hello World"
cal
time ls -la
date
Conclusion
The CLI isn't magic — it's a shell interpreting your input and running small programs. Mastering these commands builds a strong foundation for administration, scripting, and troubleshooting. Explore man <command> for deeper options.