Are you an enthusiastic Linux user? Well, if you are, then I think you can make use of this Linux Cheat Sheet. Linux is well known for its terminal and commands. Sometimes, memorizing them becomes a little tricky. So, here you can find best Linux Cheat Sheet for 2023.
This cheat sheet has multiple sections organized by topics. It includes most popular bash commands, displaying hardware information or just working with files. It's simplicity make it perfect for everyday Linux users.
Bash Commands
Basic bash commands
uname -aShow system and kernel
head -n1 /etc/issueShow distribution
mountList mounted filesystems
df -aThShow Mounted Hard Drives Partition
dateShow system date
uptimeShow uptime
whoamiShow your username
man catShow manual for command
Bash Shortcuts
Bash Keyboard Shortcuts
qExit from commands - man
CTRL-cStop current command
CTRL-zSleep program
CTRL-a (Home)Moves the cursor to the start of a line
CTRL-e (End)Moves the cursor to the end of a line
CTRL-uDelete from start of line
CTRL-kDelete to end of line
CTRL-rSearch history ( write string and press CTRL-r again to search)
!!Repeat last command
!catRun last command starting with cat
!cat:pPrint last command starting with cat
!*All arguments of previous command
Bash Variables
A variable in bash can contain a number, a character, a string of characters
envDisplay all environment variables
echo $NAMEShow value of $DISPLAY variable
export NAME=valueSet $NAME to value
$PATHExecutable search path
$HOMEHome directory
$SHELLCurrent shell
Process Management
Commands for Process Management in Linux
psShow snapshot of processes
topShow real time processes (typing capital E for memory units (KiB, MiB, GiB, etc.,)
htopDisplay all processes ( install by sudo apt-get install htop )
kill pidKill process with id pid
pkill nameKill process with name name
killall nameKill all processes with names beginning name
kill -9 pidEffectively kill process
pkill -U user .Kill all process to a given user
Directory Operations
Working with files and directories in Linux
pwdShow current directory
mkdir dirCreate new directory temp
cd dirMove to directory temp
cd ..Go up one directory
lsList files
cd ~Go to home ( ~ - home directory)
ls .List current folder ( . - current directory )
ls command
The ls command is used to show the list of a folder.
-aShow all (including hidden)
-RRecursive list
-rReverse order
-tSort by last modified
-SSort by file size
-lLong listing format
-1One file per line
-mComma-separated output
Search Files
Find, locate and search by patterns - files In Linux from the command line
grep 'word' filenameSearch for pattern in files
grep -iCase insensitive search
grep -rRecursive search
grep -vInverted search
grep -oShow matched part of file only
find . -name 'yo*'Find files starting with name in current dir
find temp -name 'yo*'Find files starting with name in folder temp
find /dir/ -user nameFind files owned by name in dir
find /dir/ -mmin numFind files modifed less than num minutes ago in dir
whereis catLocate command
which catLocate command
locate some_file.txtFind file based on system index
Nano Shortcuts
Most used Nano Text editor commands
Ctrl-SSave current file
Ctrl-OOffer to write file (Save as)
Ctrl-XClose buffer, exit from nano
Ctrl-RInsert a file into current one
ALT-ATurn the mark on/off (text selection)
CTRL-KCut marked text or line
CTRL-UPaste text
ALT-/End of file (Alt+\ - start)
CTRL-ATo start of line
CTRL-ETo end of line
CTRL-CShow line number
Alt+GGo to line number
CTRL-WStart forward search
ALT-WFind next occurrence forward
CTRL-\Search to replace
File Permissions
The permissions on a file can be changed by 'chmod' command. The 'chown' command can change the ownership of a file/directory
chmod 775 file.txtChange permissions of file to 775
chmod -R 777 tempRecursively chmod folder temp to 777
chown user:group fileChange file owner and group
sudo chown -R user:user ./contentChange file owner and group recursively of folder
find ./ ! -path './content/*' -type f -exec chmod 664 {} \;Search and change permissions of files
File Permission codes
List of all permission types used in Linux
0No Permission
1Execute
2Write
3Execute + Write
4Read
5Read + Execute
6Read + Write
7Read + Write + Execute
Chain & Pipe commands
Linux command chaining is a technique of merging several commands
cmd1 ; cmd2Run cmd1 then cmd2
cmd1 && cmd2Run cmd2 if cmd1 is successful
cmd1 || cmd2Run cmd2 if cmd1 is not successful
cmd &Run cmd in a subshell
cmd1 | cmd2Pipe two commands (stdout of cmd1 to cmd2)
cmd1 |& cmd2stderr of cmd1 to cmd2
(echo zz; echo aa; echo kk) | sortPipe multiple commands
File Operations
Most used file operations commands in Linux
touch file.txtCreate new file file.txt
cat file1.txt file2.txtConcatenate two files
less file.txtDisplay and paginate file1 ( escape - q )
file file.txtGet file type
cp file.txt new_file.txtcopy file.txt to new_file.txt
cp ./temp/file.txt ./new_foldercopy file to new folder
mv file1.txt file2.txtMove file1.txt to file2.txt
rm file1.txtDelete file
head file1.txtShow first 10 lines of file1.txt
tail file1.txtShow last 10 lines of file1
tail -F file1.txtOutput last lines of file1 as it changes
tail -n 15 -F logfile.txtLast 15 lines of file when it changes
IO Redirection
Most used file operations commands in Linux
cmd < fileInput of cmd from file
cmd > fileStandard output (stdout) of cmd to file
cmd > /dev/nullDiscard stdout of cmd
cmd >> fileAppend stdout to file
cmd 2> fileError output (stderr) of cmd to file
Hardware
Best commands to check hardware information on Linux
sudo lshwHardware info
sudo lshw | lessShort version of lshw
lspciHardware info in human way
lspci -nnk | grep VGA -A1Graphics
lspci -v | grep -A7 -i 'audio'Audio
lspci -nnk | grep net -A2Networking
inxi -FxxxrzSystem information tool
free -gShow free RAM in GB
df –hCheck free disk space
Update & Clean
Update, Upgrade, Clean and Remove in Linux
sudo apt-get updateShow all availble updates
sudo apt-get upgradeDownload and install available updates
sudo apt-get upgrade -yConfirmation for updates
sudo apt-get autocleanRemoves all stored archives in your cache for packages
sudo apt-get autoremoveClean up unused dependencies
sudo apt-get autoclean && sudo apt-get autoremoveClean cache & dependencies