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 -a
Show system and kernel
head -n1 /etc/issue
Show distri­bution
mount
List mounted filesy­stems
df -aTh
Show Mounted Hard Drives Partition
date
Show system date
uptime
Show uptime
whoami
Show your username
man cat
Show manual for command

Bash Shortcuts

Bash Keyboard Shortcuts
q
Exit from commands - man
CTRL-c
Stop current command
CTRL-z
Sleep 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-u
Delete from start of line
CTRL-k
Delete to end of line
CTRL-r
Search history ( write string and press CTRL-r again to search)
!!
Repeat last command
!cat
Run last command starting with cat
!cat:p
Print 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
env
Display all enviro­nment variables
echo $NAME
Show value of $DISPLAY variable
export NAME=value
Set $NAME to value
$PATH
Executable search path
$HOME
Home directory
$SHELL
Current shell

Process Management

Commands for Process Management in Linux
ps
Show snapshot of processes
top
Show real time processes (typing capital E for memory units (KiB, MiB, GiB, etc.,)
htop
Display all processes ( install by sudo apt-get install htop )
kill pid
Kill process with id pid
pkill name
Kill process with name name
killall name
Kill all processes with names beginning name
kill -9 pid
Effectively kill process
pkill -U user .
Kill all process to a given user

Directory Operations

Working with files and directories in Linux
pwd
Show current directory
mkdir dir
Create new directory temp
cd dir
Move to directory temp
cd ..
Go up one directory
ls
List 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.
-a
Show all (including hidden)
-R
Recursive list
-r
Reverse order
-t
Sort by last modified
-S
Sort by file size
-l
Long listing format
-1
One file per line
-m
Comma-­sep­arated output

Search Files

Find, locate and search by patterns - files In Linux from the command line
grep 'word' filename
Search for pattern in files
grep -i
Case insens­itive search
grep -r
Recursive search
grep -v
Inverted search
grep -o
Show 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 name
Find files owned by name in dir
find /dir/ -mmin num
Find files modifed less than num minutes ago in dir
whereis cat
Locate command
which cat
Locate command
locate some_file.txt
Find file based on system index

Nano Shortcuts

Most used Nano Text editor commands
Ctrl-S
Save current file
Ctrl-O
Offer to write file (Save as)
Ctrl-X
Close buffer, exit from nano
Ctrl-R
Insert a file into current one
ALT-A
Turn the mark on/off (text selection)
CTRL-K
Cut marked text or line
CTRL-U
Paste text
ALT-/
End of file (Alt+\ - start)
CTRL-A
To start of line
CTRL-E
To end of line
CTRL-C
Show line number
Alt+G
Go to line number
CTRL-W
Start forward search
ALT-W
Find next occurrence forward
CTRL-\
Search to replace

File Permis­sions

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.txt
Change permissions of file to 775
chmod -R 777 temp
Recurs­ively chmod folder temp to 777
chown user:group file
Change file owner and group
sudo chown -R user:user ./content
Change 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
0
No Permission
1
Execute
2
Write
3
Execute + Write
4
Read
5
Read + Execute
6
Read + Write
7
Read + Write + Execute

Chain & Pipe commands

Linux command chaining is a technique of merging several commands
cmd1 ; cmd2
Run cmd1 then cmd2
cmd1 && cmd2
Run cmd2 if cmd1 is successful
cmd1 || cmd2
Run cmd2 if cmd1 is not successful
cmd &
Run cmd in a subshell
cmd1 | cmd2
Pipe two commands (stdout of cmd1 to cmd2)
cmd1 |& cmd2
stderr of cmd1 to cmd2
(echo zz; echo aa; echo kk) | sort
Pipe multiple commands

File Operations

Most used file operations commands in Linux
touch file.txt
Create new file file.txt
cat file1.txt file2.txt
Concatenate two files
less file.txt
Display and paginate file1 ( escape - q )
file file.txt
Get file type
cp file.txt new_file.txt
copy file.txt to new_file.txt
cp ./temp/file.txt ./new_folder
copy file to new folder
mv file1.txt file2.txt
Move file1.txt to file2.txt
rm file1.txt
Delete file
head file1.txt
Show first 10 lines of file1.txt
tail file1.txt
Show last 10 lines of file1
tail -F file1.txt
Output last lines of file1 as it changes
tail -n 15 -F logfile.txt
Last 15 lines of file when it changes

IO Redire­ction

Most used file operations commands in Linux
cmd < file
Input of cmd from file
cmd > file
Standard output (stdout) of cmd to file
cmd > /dev/null
Discard stdout of cmd
cmd >> file
Append stdout to file
cmd 2> file
Error output (stderr) of cmd to file

Hardware

Best commands to check hardware information on Linux
sudo lshw
Hardware info
sudo lshw | less
Short version of lshw
lspci
Hardware info in human way
lspci -nnk | grep VGA -A1
Graphics
lspci -v | grep -A7 -i 'audio'
Audio
lspci -nnk | grep net -A2
Networking
inxi -Fxxxrz
System information tool
free -g
Show free RAM in GB
df –h
Check free disk space

Update & Clean

Update, Upgrade, Clean and Remove in Linux
sudo apt-get update
Show all availble updates
sudo apt-get upgrade
Download and install available updates
sudo apt-get upgrade -y
Confirmation for updates
sudo apt-get autoclean
Removes all stored archives in your cache for packages
sudo apt-get autoremove
Clean up unused dependencies
sudo apt-get autoclean && sudo apt-get autoremove
Clean cache & dependencies