Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 

Repository files navigation

🐧 Essential Linux Commands Cheat-Sheet [+100] πŸ’»πŸ›‘οΈ

Linux Commands Count Target Audience


πŸš€ Level Up Your Command Line Skills!

A comprehensive, well-structured, and categorized repository containing over 100 essential Linux commands. Whether you are a system administrator, a DevOps engineer, or a cybersecurity professional, this quick-reference guide has got you covered[cite: 1].


πŸ—ΊοΈ Quick Navigation

πŸ“‚ Categories πŸ“‚ Categories
πŸ“„ 1. File Operations πŸ’Ύ 9. Disk & System Usage
πŸ“ 2. Directory Operations ℹ️ 10. System Information
βš™οΈ 3. Process Operations πŸ› οΈ 11. Package Installations
πŸ”’ 4. File Permissions πŸ”„ 12. Version Control (Git)
🌐 5. Networking & Security ⏰ 13. Job Scheduling (Cron)
πŸ“¦ 6. Archives & Compression πŸ“œ 14. Shell Scripting
πŸ“ 7. Text Processing πŸ“Š 15. Performance & Utilities
⚠️ 8. Dangerous Commands πŸ’‘ Pro-Tip Section

πŸ“„ 1. File Operations

  • ls β€” Lists all files and directories in the present working directory[cite: 1].
  • ls -R β€” Lists files in sub-directories as well[cite: 1].
  • ls -a β€” Shows hidden files[cite: 1].
  • ls -al β€” Lists files and directories with detailed information (permissions, size, owner, etc.)[cite: 1].
  • cd directoryname β€” Changes the current directory[cite: 1].
  • cd .. β€” Moves one level up in the directory tree[cite: 1].
  • pwd β€” Displays the present working directory path[cite: 1].
  • cat > filename β€” Creates a new file quickly[cite: 1].
  • cat filename β€” Displays the contents of a file[cite: 1].
  • cat file1 file2 > file3 β€” Joins two files and stores the output in a new file[cite: 1].
  • touch filename β€” Creates an empty file or modifies file timestamps[cite: 1].
  • rm filename β€” Deletes a specific file[cite: 1].
  • cp source destination β€” Copies files from source to destination path[cite: 1].
  • mv source destination β€” Moves or renames files[cite: 1].
  • find / -name filename β€” Finds a file or directory starting from the root directory[cite: 1].
  • file filename β€” Determines the file type[cite: 1].
  • less filename β€” Views the file content interactively page by page[cite: 1].
  • head filename β€” Views the first ten lines of a file[cite: 1].
  • tail filename β€” Views the last ten lines of a file[cite: 1].
  • lsof β€” Shows which files are opened by which running processes[cite: 1].
  • du -h --max-depth=1 β€” Shows the size of directories up to current depth[cite: 1].
  • fdisk β€” Disk partition manipulation utility[cite: 1].

πŸ“ 2. Directory Operations

  • mkdir directoryname β€” Creates a new directory[cite: 1].
  • rmdir directoryname β€” Deletes an empty directory[cite: 1].
  • cp -r source destination β€” Copies directories recursively[cite: 1].
  • mv olddir newdir β€” Renames or moves directories[cite: 1].
  • find / -type d -name directoryname β€” Finds a specific directory starting from root[cite: 1].

βš™οΈ 3. Process Operations & Redirection

  • ps β€” Displays your currently active processes[cite: 1].
  • top β€” Displays all running system processes in real-time[cite: 1].
  • htop β€” An interactive, user-friendly process viewer (Modern alternative to top)[cite: 1].
  • kill pid β€” Kills a process using its Process ID (PID)[cite: 1].
  • pkill name β€” Kills a process by its name[cite: 1].
  • bg β€” Resumes suspended jobs without bringing them to the foreground[cite: 1].
  • fg β€” Brings the most recent background job to the foreground[cite: 1].
  • fg n β€” Brings a specific job n to the foreground[cite: 1].
  • renice +n [pid] β€” Changes the priority of a running process[cite: 1].
  • &>filename β€” Redirects both stdout and stderr to a file[cite: 1].
  • 1>filename β€” Redirects only standard output (stdout) to a file[cite: 1].
  • 2>filename β€” Redirects only standard error (stderr) to a file[cite: 1].

πŸ”’ 4. File Permissions

  • chmod octal filename β€” Changes file permissions using octal values (e.g., 755, 644)[cite: 1].
  • chown ownername filename β€” Changes the owner of a file[cite: 1].
  • chgrp groupname filename β€” Changes the group ownership of a file[cite: 1].

🌐 5. Networking & Security Scanner

  • ping host β€” Pings a host to check network connectivity and outputs results[cite: 1].
  • whois domain β€” Retrieves WHOIS information for a specific domain[cite: 1].
  • dig domain β€” Gathers DNS details and information for a domain[cite: 1].
  • netstat -pnltu β€” Displays active network connections, routing tables, and interface stats[cite: 1].
  • ss β€” Investigates sockets (A modern, faster alternative to netstat)[cite: 1].
  • ifconfig β€” Displays IP addresses and configurations of network interfaces[cite: 1].
  • ssh user@host β€” Securely logs into a remote host as a specified user[cite: 1].
  • scp β€” Securely transfers files between hosts over an SSH connection[cite: 1].
  • wget url β€” Downloads files directly from the web[cite: 1].
  • curl url β€” Sends a request to a URL and returns the server's response[cite: 1].
  • traceroute domain β€” Prints the path/route that packets take to reach a destination domain[cite: 1].
  • mtr domain β€” Combines traceroute and ping functionalities into one diagnostic tool[cite: 1].
  • nmap β€” Advanced network exploration tool and security scanner[cite: 1].

πŸ“¦ 6. Archives and Compression

  • tar -cvf archive.tar dirname/ β€” Creates a new tar archive from a directory[cite: 1].
  • tar xvf archive.tar β€” Extracts files from a standard .tar archive[cite: 1].
  • tar -jcvf archive.tar.bz2 dirname/ β€” Creates a highly compressed .bz2 archive[cite: 1].
  • tar -jxvf archive.tar.bz2 β€” Extracts files from a .bz2 compressed archive[cite: 1].
  • gzip file β€” Compresses a file and automatically renames it to file.gz[cite: 1].
  • gzip -d file.gz β€” Decompresses a .gz file back to its original state[cite: 1].
  • zip -r file.zip files β€” Creates a standard .zip compressed archive[cite: 1].
  • unzip file.zip β€” Extracts the contents of a .zip archive file[cite: 1].

πŸ“ 7. Text Processing

  • grep pattern files β€” Searches for a specific pattern inside files[cite: 1].
  • grep -r pattern dir β€” Recursively searches for a pattern within a directory[cite: 1].
  • command | grep pattern β€” Pipes the output of any command to grep for filtering[cite: 1].
  • echo 'text' β€” Prints the specified text line to the terminal[cite: 1].
  • sed 's/string1/string2/g' filename β€” Replaces string1 with string2 globally inside a file[cite: 1].
  • sed -i 's/string1/string2/g' filename β€” Replaces strings and saves changes directly in-place[cite: 1].
  • diff file1 file2 β€” Compares two text files and displays the structural differences[cite: 1].
  • wc filename β€” Counts lines, words, and total characters within a file[cite: 1].
  • awk β€” A highly versatile pattern-scanning and processing programming language[cite: 1].
  • cut -d':' -f1 /etc/passwd β€” Extracts specific fields from a line using a delimiter[cite: 1].

πŸ’Ύ 8. Disk & System Usage

  • df -h β€” Shows available disk space in human-readable formats (GB/MB)[cite: 1].
  • du -sh β€” Shows the summary of disk space used by the current directory[cite: 1].
  • free -m β€” Shows free and used physical memory (RAM) and swap space in MB[cite: 1].
  • whereis app β€” Locates the binary, source, and manual page files for an application[cite: 1].

ℹ️ 9. System Information

  • date β€” Displays the current system date and time[cite: 1].
  • cal β€” Displays the current month's calendar overview[cite: 1].
  • uptime β€” Shows how long the system has been continuously running[cite: 1].
  • w β€” Displays structural data about who is currently logged online[cite: 1].
  • whoami β€” Prints the exact username you are logged in as[cite: 1].
  • uname -a β€” Shows comprehensive system kernel and architecture information[cite: 1].

πŸ› οΈ 10. Package Installations (APT & Pip)

  • sudo apt-get update β€” Updates local package indexes for available upgrades[cite: 1].
  • sudo apt-get upgrade β€” Upgrades all upgradable system packages safely[cite: 1].
  • sudo apt-get install pkgname β€” Installs a specified package via APT repository[cite: 1].
  • sudo apt-get remove pkgname β€” Uninstalls a package while leaving configuration files[cite: 1].
  • pip install packagename β€” Installs a Python package from PyPI[cite: 1].
  • pip uninstall packagename β€” Uninstalls a specific Python package[cite: 1].
  • pip freeze > requirements.txt β€” Exports all installed Python packages into a text file[cite: 1].
  • pip install -r requirements.txt β€” Installs multiple Python packages listed in a file[cite: 1].

πŸ”„ 11. Version Control (Git Commands)

  • git init β€” Initializes a brand new local Git repository[cite: 1].
  • git clone url β€” Creates a local clone copy of a remote repository[cite: 1].
  • git add filename β€” Adds specific files to the staging area[cite: 1].
  • git commit -m "msg" β€” Commits staged changes with a descriptive log message[cite: 1].
  • git status β€” Checks the track status of the working tree directory[cite: 1].
  • git pull β€” Fetches from and integrates with another repository or branch[cite: 1].
  • git push β€” Updates remote refs using local references[cite: 1].
  • git branch β€” Lists all existing local branches[cite: 1].
  • git branch branchname β€” Creates a new local branch[cite: 1].
  • git checkout branchname β€” Switches execution focus to another branch[cite: 1].
  • git merge branchname β€” Merges target branch data into the current active branch[cite: 1].
  • git stash β€” Temporarily stashes modified tracked files to clear working directory[cite: 1].
  • git stash apply β€” Restores previously stashed changes back into focus[cite: 1].
  • git log β€” Views the complete commit history logs[cite: 1].
  • git reset β€” Resets your current HEAD pointer to a specified state/commit[cite: 1].
  • git rm filename β€” Removes a file from working index and version control[cite: 1].
  • git rebase β€” Reapplies local commits on top of another base tip[cite: 1].
  • git revert β€” Creates a new commit that safely rolls back changes of an older commit[cite: 1].
  • git cherry-pick commitID β€” Applies changes introduced by an existing specific commit[cite: 1].

βš™οΈ 12. Environment Variables & Logic Operators

  • env β€” Displays all current system environment variables[cite: 1].
  • echo $VARIABLE β€” Displays the exact evaluated value of an environment variable[cite: 1].
  • export VARIABLE=value β€” Sets or exports a new value to an environment variable[cite: 1].
  • alias new_cmd='old_cmd options' β€” Assigns a custom shortcut alias to a long command[cite: 1].
  • echo $PATH β€” Prints the complete executable system environment search PATH[cite: 1].
  • export PATH=$PATH:/new/path β€” Safely appends a new folder location to the system PATH variable[cite: 1].
  • cmd1; cmd2 β€” Sequence separator; runs command1 and then command2 sequentially[cite: 1].
  • cmd1 && cmd2 β€” Logical AND; runs command2 only if command1 terminates successfully[cite: 1].
  • cmd1 || cmd2 β€” Logical OR; runs command2 only if command1 execution fails[cite: 1].
  • cmd & β€” Runs the specified command task completely in the background[cite: 1].

⏰ 13. Job Scheduling (Cron Jobs)

  • crontab -l β€” Lists all scheduled cron automation tasks under your user[cite: 1].
  • crontab -e β€” Edits your personal crontab automation tasks configuration[cite: 1].
  • crontab -r β€” Removes all existing scheduled cron jobs entirely[cite: 1].
  • crontab -v β€” Displays the last time you verified or edited your cron configurations[cite: 1].
  • crontab file β€” Installs completely new cron schedules directly from a structured text file[cite: 1].
  • @reboot command β€” Schedules a specific command task to trigger automatically upon system startup[cite: 1].

πŸ“œ 14. Shell Scripting

  • #!/bin/bash β€” Shebang header instruction declaring Bash as the execution interpreter[cite: 1].
  • $0, $1, $9 β€” Positional parameters indicating positional input arguments passed to scripts[cite: 1].
  • if [ condition ]; then ... fi β€” Basic standard conditional logic block inside shell scripts[cite: 1].
  • for i in {1..10}; do ... done β€” Standard execution loop structure running specified increments[cite: 1].
  • while [ condition ]; do ... done β€” Runs script iteration loops continuously as long as condition evaluates true[cite: 1].
  • function name() {...} β€” Declares a reusable sub-routine function block inside scripts[cite: 1].

πŸ“Š 15. Performance, Search & Hard Drive Utilities

  • iostat β€” Reports breakdown metrics on central CPU and I/O utilization stats[cite: 1].
  • vmstat β€” Summarizes memory, active paging, kernel traps, block IO, and CPU activities[cite: 1].
  • locate filename β€” Rapidly searches files via system database indexing (Requires updatedb)[cite: 1].
  • whereis programname β€” Locates binary executables, sources, and manual pages for a tool[cite: 1].
  • which commandname β€” Returns the absolute system resolution path of an executable terminal app[cite: 1].
  • dd if=/dev/zero of=/tmp/output.img bs=8k count=256k β€” Creates custom block files to test storage read/write performance[cite: 1].
  • hdparm -Tt /dev/sda β€” Evaluates and measures raw sequential read speeds of your hard disk[cite: 1].

⚠️ 16. Others (Handle with Care!)

  • yes > /dev/null & β€” Pushes system processor load to peak capacity by sending endless inputs[cite: 1].
  • :(){ :|:& };: β€” Fork Bomb β€” Warning: Spawns recursive processes endlessly until memory exhaustion crashes the machine[cite: 1]. Do not execute on production servers[cite: 1].

πŸ’‘ Pro-Tip

You can append man before any command (e.g., man ls) to instantly access its native offline reference manual and documentation[cite: 1]!


⭐ If you found this cheat-sheet helpful, don't forget to give this repository a Star! ⭐

About

100+ Essential Linux Commands for developers, system administrators, and security specialists. πŸš€

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors