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].
| π 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 |
| π‘ Pro-Tip Section |
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].
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].
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 totop)[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 jobnto 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].
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].
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 tonetstat)[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β Combinestracerouteandpingfunctionalities into one diagnostic tool[cite: 1].nmapβ Advanced network exploration tool and security scanner[cite: 1].
tar -cvf archive.tar dirname/β Creates a new tar archive from a directory[cite: 1].tar xvf archive.tarβ Extracts files from a standard.tararchive[cite: 1].tar -jcvf archive.tar.bz2 dirname/β Creates a highly compressed.bz2archive[cite: 1].tar -jxvf archive.tar.bz2β Extracts files from a.bz2compressed archive[cite: 1].gzip fileβ Compresses a file and automatically renames it tofile.gz[cite: 1].gzip -d file.gzβ Decompresses a.gzfile back to its original state[cite: 1].zip -r file.zip filesβ Creates a standard.zipcompressed archive[cite: 1].unzip file.zipβ Extracts the contents of a.ziparchive file[cite: 1].
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 togrepfor filtering[cite: 1].echo 'text'β Prints the specified text line to the terminal[cite: 1].sed 's/string1/string2/g' filenameβ Replacesstring1withstring2globally 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].
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].
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].
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].
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].
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].
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].
#!/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].
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 (Requiresupdatedb)[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].
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].
You can append
manbefore 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! β