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 |
---|---|
pstree -p |
Show process tree |
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 |
Command | Description |
---|---|
touch filename |
Create an empty file |
mkdir foldername |
Create a new directory |
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 |
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>` |
bash
和 sh
都是 shell, shell 是 terminal 的解释器
pwd