└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # Linux-Commands-Cheat-Sheet 2 | 3 | A collection of common Linux commands for system navigation, file management, networking, and more. 4 | 5 | ## Table of Contents 6 | 1. [Basic Commands](#basic-commands) 7 | 2. [Operators](#operators) 8 | 3. [File and Directory Management](#file-and-directory-management) 9 | 4. [File Permissions](#file-permissions) 10 | 5. [Screen](#screen) 11 | 6. [Shutdown and Sleep](#shutdown_and_sleep) 12 | 7. [User Management](#user-management) 13 | 8. [Package Management](#package-management) 14 | 9. [Cron Jobs and Scheduling](#cron-jobs-and-scheduling) 15 | 10. [Process Management](#process-management) 16 | 11. [System Monitoring](#system-monitoring) 17 | 12. [Systemd Management](systemd-management) 18 | 13. [Networking](#networking) 19 | 14. [SSH Management](#ssh-management) 20 | 15. [Mail Management](mail-management) 21 | 16. [Kernel and Modules Management](#kernel-and-modules-management) 22 | 17. [Boot, Bootloader (GRUB), and EFI Firmware](#boot-bootloader-grub-and-efi-firmware) 23 | 24 | --- 25 | 26 | ## Basic Commands 27 | 28 | | Command | Description | 29 | |--------------------|-------------------------------------| 30 | | `pwd` | Print the current working directory | 31 | | `ls` | List files in the directory | 32 | | `cd ` | Change directory | 33 | | `whoami` | Display current user | 34 | | `echo ` | Print text to terminal | 35 | | `history` | Show command history | 36 | 37 | --- 38 | 39 | ### System Information 40 | 41 | | Command | Description | 42 | |----------------------------------------------|-----------------------------------------------------------------------------| 43 | | `uname -a` | Display detailed system information (kernel, hostname, etc.) | 44 | | `uname -r` | Show the kernel version | 45 | | `hostname` | Show or set the system hostname | 46 | | `hostnamectl` | Display or set the system's hostname and related settings | 47 | | `uptime` | Show how long the system has been running and system load | 48 | | `whoami` | Display the current user | 49 | | `id` | Show the current user’s ID and group information | 50 | | `who` | Show who is currently logged into the system | 51 | | `w` | Display who is logged in and what they are doing | 52 | | `date` | Show or set the system date and time | 53 | | `cal` | Display a calendar for the current month | 54 | | `df -h` | Show disk space usage in human-readable format | 55 | | `du -h ` | Display the disk usage of files and directories in human-readable format | 56 | | `du -sh ` | Display the total size of a directory | 57 | | `top` | Display real-time system resource usage and processes | 58 | | `free -h` | Show memory usage in human-readable format | 59 | | `lscpu` | Display CPU architecture information | 60 | | `lsblk` | List information about block devices (disks, partitions) | 61 | | `dmesg` | Display messages from the kernel ring buffer | 62 | | `lsusb` | List information about USB devices | 63 | | `lspci` | List information about PCI devices | 64 | | `uptime` | Display the system’s uptime and load averages | 65 | | `last` | Show the last logins of users | 66 | | `uname -m` | Show the machine hardware name (e.g., x86_64) | 67 | 68 | --- 69 | 70 | ## Operators 71 | 72 | | Operator | Description | 73 | |-----------------|-----------------------------------------------------------------------------| 74 | | `|` (Pipe) | Pass the output of one command as input to another command (`ls | grep txt`) | 75 | | `>` | Redirect output to a file, overwriting the file if it exists (`echo "Hello" > file.txt`) | 76 | | `>>` | Redirect output to a file, appending if the file exists (`echo "Hello" >> file.txt`) | 77 | | `<` | Redirect input from a file to a command (`sort < file.txt`) | 78 | | `2>` | Redirect error output to a file (`command 2> error.log`) | 79 | | `2>&1` | Redirect error output to standard output (`command > file.txt 2>&1`) | 80 | | `&` | Run a command in the background (`command &`) | 81 | | `&&` | Run the next command only if the previous command succeeds (`command1 && command2`) | 82 | | `||` | Run the next command only if the previous command fails (`command1 || command2`) | 83 | | `;` | Run multiple commands in sequence (`command1; command2; command3`) | 84 | | `$(command)` | Command substitution: use the output of a command as an argument (`echo $(date)`) | 85 | | `&>` | Redirect both standard output and error output to a file (`command &> output.log`) | 86 | 87 | ___ 88 | 89 | ## File and Directory Management 90 | 91 | | Command | Description | 92 | |----------------------------------------------|-----------------------------------------------------------------------------| 93 | | `ls` | List files and directories in the current directory | 94 | | `ls -l` | List files and directories with detailed information | 95 | | `ls -a` | List all files, including hidden files | 96 | | `cd ` | Change to a specific directory | 97 | | `cd ..` | Move up one directory level | 98 | | `pwd` | Display the current working directory | 99 | | `mkdir ` | Create a new directory | 100 | | `rmdir ` | Remove an empty directory | 101 | | `rm ` | Delete a file | 102 | | `rm -r ` | Remove a directory and its contents recursively | 103 | | `rm -rf ` | Forcefully remove a directory and its contents | 104 | | `cp ` | Copy files or directories | 105 | | `cp -r ` | Copy directories recursively | 106 | | `mv ` | Move or rename files and directories | 107 | | `touch ` | Create an empty file or update the timestamp of an existing file | 108 | | `ln -s ` | Create a symbolic link (soft link) | 109 | | `ln ` | Create a hard link | 110 | | `cat ` | Display the contents of a file | 111 | | `less ` | View the contents of a file page by page | 112 | | `more ` | View the contents of a file page by page (older than `less`) | 113 | | `head ` | Display the first 10 lines of a file | 114 | | `tail ` | Display the last 10 lines of a file | 115 | | `tail -f ` | Display the contents of a file in real-time (follow the file as it grows) | 116 | | `find -name ` | Search for a file or directory by name | 117 | | `find -type d -name ` | Find directories matching a specific name | 118 | | `find -type f -name ` | Find files matching a specific name | 119 | | `grep "" ` | Search for a specific pattern in a file | 120 | | `grep -r "" ` | Search for a pattern recursively in a directory | 121 | 122 | --- 123 | 124 | ## File Permissions 125 | 126 | | Command | Description | 127 | |----------------------------------------------|-----------------------------------------------------------------------------| 128 | | `ls -l` | List files and show their permissions, owner, and group | 129 | | `chmod ` | Change the permissions of a file or directory | 130 | | `chmod 644 ` | Set read/write for owner and read-only for group and others | 131 | | `chmod 755 ` | Set read/write/execute for owner, read/execute for group and others | 132 | | `chown : ` | Change the owner and group of a file or directory | 133 | | `chown ` | Change the owner of a file | 134 | | `chgrp ` | Change the group of a file | 135 | 136 | --- 137 | 138 | ## Screen 139 | 140 | | Command | Description | 141 | |------------------------------|-----------------------------------------------------| 142 | | `screen` | Start a new screen session | 143 | | `screen -S ` | Start a new screen session with a custom name | 144 | | `screen -ls` | List all active screen sessions | 145 | | `screen -r ` | Reattach to a detached screen session | 146 | | `Ctrl + a + d` | Detach from the current screen session | 147 | | `screen -X -S quit` | Force quit a screen session | 148 | | `Ctrl + a + k` | Kill the current screen | 149 | | `screen -x ` | Attach to a running session shared by multiple users| 150 | | `Ctrl + a + n` | Switch to the next window in the screen session | 151 | | `Ctrl + a + p` | Switch to the previous window in the screen session | 152 | | `Ctrl + a + c` | Create a new window in the current screen session | 153 | | `Ctrl + a + "` | List all windows in the current session | 154 | 155 | ___ 156 | 157 | ## Shutdown and Sleep 158 | 159 | | Command | Description | 160 | |------------------------------|-------------------------------------------------------| 161 | | `shutdown now` | Shut down the system immediately | 162 | | `shutdown -h now` | Halt the system immediately | 163 | | `shutdown -r now` | Restart the system immediately | 164 | | `shutdown -h +