Path | Description |
---|---|
~ or /home/username/ |
Your Linux home directory |
/usr/ |
Installed programs and libraries |
/etc/ |
System configuration files |
/var/ |
Logs, cache, and system files |
/mnt/c/Users/Merrick/ |
Your Windows user directory |
/mnt/c/ |
Mounted C: drive from Windows |
/mnt/d/ |
Mounted D: drive (if available) |
Terminal Prompt Format: username@hostname:~$
username
→ Your Linux user in WSLhostname
→ The name of your WSL instance~
(Tilde) → Home directory shortcut (/home/username
)$
→ Standard user (If you see #
, you are running as root)Command | Description |
---|---|
sudo do-release-upgrade |
Update Ubuntu |
pstree -p |
Show process tree |
ps aux |
Show process tree in table |
lsb_release -a |
Show Linux distribution details |
whoami |
Display the current username |
hostname |
Show the system hostname |
df -h |
Show disk usage in a human-readable format |
alias ls='ls -a --color=auto’ |
Make ls always show hidden files with color |
ls |
List files and directories in the current directory |
ls -a |
List all files, including hidden ones (.* ) |
ls -lah |
List files with details in a human-readable format |
ls -l |
List files with details |
pwd |
Print the current working directory. |
nano |
Open the nano text editor to create or edit files. |
Command | Description |
---|---|
touch filename |
Create an empty file |
mkdir foldername |
Create a new directory |
rm filename |
Remove files and directories (no recovery!) |
mv filename |
Move files |
echo "text” |
Print text to the terminal |
mkdir my_files |
Create a directory named my_files |
cd my_files |
Change to the my_files directory |
touch file1.txt file2.txt |
Create multiple empty files (file1.txt , file2.txt , etc.) |
echo "Hello World" > file.txt |
Create file.txt and write "Hello World" into it |
echo "New Line" >> file.txt |
Append "New Line" to file.txt |
Command | Description |
---|---|
wc -l file.txt |
Count the number of lines in file.txt |
chmod +x script.sh |
Give execute permission to script.sh |
./script.sh file1.txt file2.txt |
Run the script with file1.txt and file2.txt as arguments |
cat result.txt |
Display the contents of result.txt |
tee -a result.txt |
Append output to result.txt while displaying it on the screen |
bash script.sh |
Run script.sh using Bash |
bash
and sh
are shells, acting as interpreters for the terminal.Command | Description |
---|---|
echo $SHELL |
Show your default shell |
echo $0 |
Show the current shell |
echo $$ |
Show the process ID (PID) of your current shell |
cat /etc/shells |
List available shells |
ps -p $$ |
Display process information of the current shell |
Shortcut | Action |
---|---|
Ctrl + L |
Clear terminal screen |
Ctrl + C |
Stop a running process |
Ctrl + D |
Logout / exit the terminal |
Tab |
Auto-complete file/folder names |
!! |
Repeat the last command |
!<command> |
Run the most recent command that starts with <command> |
history |
grep <keyword> |
# Update & Upgrade Packages
sudo apt update # Update package lists (does not install updates)
sudo apt upgrade -y # Upgrade all installed packages
sudo apt full-upgrade -y # Upgrade packages and handle dependencies
sudo apt dist-upgrade -y # Similar to full-upgrade, but with different dependency handling
# Install & Remove Packages
sudo apt install <package> -y # Install a specific package
sudo apt remove <package> -y # Uninstall a package (keep config files)
sudo apt purge <package> -y # Completely remove a package (including config)
sudo apt autoremove -y # Remove unnecessary dependencies
# Clean Package Cache
sudo apt clean # Clear downloaded package cache
sudo apt autoclean # Remove old package files
# List Installed Packages
apt list --installed # Show all installed packages
dpkg --get-selections | grep -v deinstall # Alternative way to list installed packages
# Check a Specific Package
dpkg -l | grep <package> # Check if a package is installed
apt list --installed | grep <package> # Alternative method
apt show <package> # Show package details (description, version, dependencies)
# Show Manually & Automatically Installed Packages
apt-mark showmanual # List only manually installed packages
apt-mark showauto # List automatically installed packages
# Find User-Installed Packages from History
grep -E "Commandline: apt install" /var/log/apt/history.log # Show all manual apt install commands