Terminal Commands
Linux, macOS and PowerShell — every command with a real-world example and the mistake everyone makes.
OS
Category
39 results
ls -laList all files and directories, including hidden ones, with detailed info
Get-ChildItem -ForceList all files including hidden ones in PowerShell (alias: ls or dir)
cd <directory>Change into a directory. Use ~ for home, .. for parent, - to go back
pwdPrint the full path of your current working directory
find <path> -name "<pattern>"Recursively search for files matching a pattern
grep -rn "<pattern>" <path>Search for a text pattern inside files recursively, showing line numbers
Select-String -Path "<pattern>" -Recurse "<text>"PowerShell equivalent of grep — searches for text within files
mkdir -p <path>Create a directory and all its parents in one command
touch <filename>Create an empty file or update its last-modified timestamp
cp -r <source> <destination>Copy a file or directory (-r for recursive)
mv <source> <destination>Move or rename a file or directory
rm -rf <path>Delete a file or directory permanently. No trash bin — gone forever
cat <file>Print a file's contents to the terminal
less <file>View a file with scrolling. Press q to quit, / to search inside
tail -f <file>Watch a file's new content in real time. Essential for logs
chmod <permissions> <file>Change file permissions. 755 for executables, 644 for files, 600 for secrets
sudo <command>Run a command as the superuser (root). Required for system-level tasks
curl -X <METHOD> <url>Make HTTP requests from the terminal. Perfect for testing APIs
ssh <user>@<host>Connect to a remote server securely over SSH
scp <file> <user>@<host>:<path>Securely copy files to or from a remote server
ps aux | grep <name>List all running processes and filter by name
kill -9 <PID>Force-kill a process by its PID. Get the PID from ps or lsof
lsof -i :<port>Find what process is using a specific network port
htopInteractive process viewer — better than top. Shows CPU, memory, per-process
sed -i 's/<old>/<new>/g' <file>Find and replace text in a file in-place
awk '{print $<N>}' <file>Extract specific columns from structured text output
sort <file> | uniq -c | sort -rnCount occurrences of each unique line, sorted by most common
wc -l <file>Count lines (-l), words (-w), or characters (-c) in a file
tar -czf <output.tar.gz> <folder>Create a compressed tar archive. -c create, -z gzip, -f filename
<command1> | <command2>Pipe output of one command as input to another. The | is one of the most powerful shell features
alias <name>='<command>'Create a shortcut for a long command. Add to ~/.bashrc or ~/.zshrc to persist
printenv | grep <name>Print environment variables, optionally filtered by name
history | grep <keyword>Search your command history. Press Ctrl+R to interactively search
which <command>Find where a command's binary lives on your system
df -hShow disk usage of all mounted filesystems in human-readable format
du -sh <folder>Show total size of a directory in human-readable format
<command> | xargs <command>Pass output of one command as arguments to another
crontab -eEdit your cron jobs to schedule commands at specific times
nohup <command> &Run a command that keeps going after you close the terminal