Here’s a cheat sheet for common terminal commands and shortcuts:
Navigation
Change Directory:
cd directory_path
Go to Home Directory:
cd ~
Go to Previous Directory:
cd -
List Files and Directories:
ls
List All Files (Including Hidden):
ls -a
File and Directory Operations
Create Directory:
mkdir directory_name
Create Empty File:
touch filename
Copy File/Directory:
cp source destination
Move/Rename File or Directory:
mv source destination
Remove File:
rm filename
Remove Directory:
rm -r directory_name
File Viewing and Editing
Display File Content:
cat filename
View File Page by Page:
less filename
Open Text Editor (e.g., nano):
nano filename
Search Within File (grep):
grep "pattern" filename
Permissions
Change File Permissions:
chmod permissions filename
Change Owner:
chown owner:group filename
System Information
Display System Information:
uname -a
Check Disk Space:
df -h
Check Memory Usage:
free -m
Process Management
List Running Processes:
ps
Kill a Process:
kill process_id
Kill All Processes by Name:
pkill process_name
Shortcuts and Tips
Clear Terminal Screen:
clear
Cancel Current Command:
- Press
Ctrl + C
Repeat Last Command:
!!
View Command History:
history
Search Command History:
history | grep "pattern"
Auto-complete Path or Command:
- Press
Tab
Get Help for a Command:
man command_name
This cheat sheet covers essential terminal commands and shortcuts. Adjust the examples based on your operating system (Linux, macOS, or Windows with WSL) and specific use cases.