Linux Commands Guide
This guide is designed to help you learn and master commonly used Linux commands. Commands
are grouped by categories for easier understanding.
1. File and Directory Commands
- ls: List files and directories.
Example: ls -l
- cd: Change directory.
Example: cd /home/user/Documents
- pwd: Print current directory.
Example: pwd
- mkdir: Create a directory.
Example: mkdir new_folder
- rmdir: Remove an empty directory.
Example: rmdir empty_folder
- rm: Remove files or directories.
Example: rm [Link], rm -r folder_name
- touch: Create an empty file or update timestamp.
Example: touch [Link]
- cp: Copy files or directories.
Example: cp [Link] [Link]
- mv: Move or rename files/directories.
Example: mv [Link] [Link]
- find: Search files and directories.
Example: find /home -name "*.txt"
- locate: Quickly find files using a prebuilt database.
Example: locate [Link]
2. File Viewing and Editing
- cat: View file contents.
Example: cat [Link]
- less / more: View file contents one screen at a time.
Example: less [Link]
- head: Show first N lines.
Example: head -n 10 [Link]
- tail: Show last N lines.
Example: tail -n 20 [Link]
- nano, vi, vim: Command-line text editors.
Example: nano [Link], vi [Link]
3. Permissions and Ownership
- chmod: Change file permissions.
Example: chmod 755 [Link]
- chown: Change file owner and group.
Example: chown user:group [Link]
- umask: Show or set default permission mask.
Example: umask, umask 022
4. System Information
- uname: Show system info.
Example: uname -a
- top: Show active processes.
Example: top
- htop: Enhanced version of top.
Example: htop
- df: Disk space usage.
Example: df -h
- du: Directory/file size usage.
Example: du -sh folder/
- free: Memory usage.
Example: free -m
- uptime: System running time.
Example: uptime
5. Package Management (Ubuntu/Debian)
- apt update: Refresh package database.
Example: sudo apt update
- apt upgrade: Upgrade installed packages.
Example: sudo apt upgrade
- apt install: Install a package.
Example: sudo apt install git
- apt remove: Uninstall a package.
Example: sudo apt remove package_name
6. Networking
- ping: Check network connectivity.
Example: ping [Link]
- ifconfig / ip a: Show network interfaces.
Example: ip a
- netstat: Show network stats.
Example: netstat -tuln
- curl: Fetch URL contents.
Example: curl [Link]
- wget: Download files.
Example: wget [Link]
7. User Management
- whoami: Current user.
Example: whoami
- id: Show user ID and groups.
Example: id
- adduser: Add a user.
Example: sudo adduser newuser
- passwd: Change password.
Example: passwd
- su: Switch user.
Example: su username
- sudo: Run command with superuser rights.
Example: sudo apt update
8. Process Management
- ps: View running processes.
Example: ps aux
- kill: Terminate a process.
Example: kill PID
- killall: Kill process by name.
Example: killall firefox
9. Archive and Compression
- tar: Archive files.
Example: tar -czvf [Link] folder/
- unzip: Extract zip files.
Example: unzip [Link]
- gzip / gunzip: Compress and decompress files.
Example: gzip [Link], gunzip [Link]
10. Miscellaneous
- history: Show command history.
Example: history
- alias: Create command shortcuts.
Example: alias ll='ls -la'
- clear: Clear terminal screen.
Example: clear
- echo: Print text.
Example: echo Hello World
- date: Show current date and time.
Example: date
- cal: Display calendar.
Example: cal
Tips:
- Use man command_name to read the manual page of any command.
- Combine commands using pipes (|) and redirection (> >> <).
Example: cat [Link] | grep "keyword" > [Link]