ZSH Terminal Language Notes/Cheat Sheet
ZSH Terminal Language Notes/Cheat Sheet
Table of Contents
1. Basic Navigation and File Operations
3. File Manipulation
5. Process Management
6. System Information
7. Network Commands
9. Text Processing
Common Options:
cd ~ - Go to home directory
cd - - Go to previous directory
Example:
cd ~/Documents/Projects
Common Options:
r - Reverse order
Example:
ls -lah ~/Documents
Example:
pwd
Common Options:
Example:
mkdir -p Projects/webapp/src
Example:
rmdir old_project
Common Options:
Example:
cat -n ~/.zshrc
Common Options:
i - Case-insensitive search
Example:
less -N /var/log/system.log
Common Options:
Example:
head -n 20 document.txt
Common Options:
Example:
tail -f -n 50 /var/log/system.log
Example:
nano ~/.zshrc
vim script.sh
File Manipulation
cp - Copy Files and Directories
Purpose: Copy files/directories
Common Options:
v - Verbose output
Example:
Common Options:
i - Interactive mode
v - Verbose output
f - Force move
Example:
mv -v oldname.txt newname.txt
mv project_files/ ~/Documents/
Common Options:
i - Interactive mode
Example:
rm -i unnecessary_file.txt
rm -rf old_directory/
touch newfile.txt
touch -a fileToUpdateAccessTime.log
Common Options:
Example:
ln -s /path/to/original/file linkname
Common Options:
R - Recursive
Example:
chmod +x script.sh
chmod -R 755 directory/
Common Options:
Example:
Process Management
ps - Process Status
Purpose: Display running processes
Common Options:
Example:
Example:
top
Common Options:
kill -9 1234
Example:
jobs
fg %1
bg %2
System Information
uname - Print System Information
Purpose: Display system information
Common Options:
a - All information
s - Kernel name
Example:
uname -a
Common Options:
h - Human-readable sizes
Example:
du - Disk Usage
Purpose: Display file/directory space usage
Common Options:
h - Human-readable
s - Summary
c - Grand total
Example:
du -sh ~/Documents/*
Common Options:
h - Human-readable
Example:
free -h
Network Commands
ping - Network Connectivity Test
Purpose: Check network connectivity
Common Options:
Example:
Example:
ifconfig en0
Common Options:
a - All connections
n - Numeric addresses
p - Program/PID
Example:
Common Options:
Example:
Common Options:
r - Recursive copy
Example:
Common Options:
Example:
Text Processing
grep - Search Text Patterns
Purpose: Search for patterns in text
Common Options:
i - Case-insensitive
n - Line numbers
v - Invert match
E - Extended regex
Example:
Example:
Common Options:
Example:
wc - Word Count
Purpose: Count lines, words, characters
Common Options:
l - Lines
w - Words
Example:
wc -l file.txt
Common Options:
n - Numeric sort
r - Reverse order
k - Sort by field
Example:
Common Options:
c - Count occurrences
Example:
ZSH-Specific Features
Globbing (Pattern Matching)
Purpose: Advanced file pattern matching
# All directories
ls -d */
# Case-insensitive glob
ls (#i)*.txt
# Recursive globbing
ls **/*.txt
History Expansion
Purpose: Reuse commands from history
Examples:
# Last command
!!
Examples:
# Define alias
alias ll='ls -la'
# Define function
mcd() {
mkdir -p "$1" && cd "$1"
}
Directory Stack
Purpose: Navigate through directory history
Commands:
Example:
pushd /var/log
pushd ~/Documents
dirs -v # View stack
popd # Go back to previous directory
Command Substitution
Examples:
Process Substitution
Purpose: Feed command output as file
Example:
Autocompletion
Purpose: Tab completion for commands and arguments
Example:
Oh My Zsh
Installation:
Theme Configuration:
Plugin Management:
Examples:
# Set path
export PATH=$HOME/bin:/usr/local/bin:$PATH
# History settings
export HISTSIZE=10000
export HISTFILESIZE=10000
export HISTCONTROL=ignoreboth
# Default editor
export EDITOR='nano'