List & Discover
Get-ChildItemList files and folders.
lsGet-ChildItem -ForceInclude hidden/system items.
ls -laGet-ChildItem -DirectoryList directories only.
find . -maxdepth 1 -type dGet-ChildItem -FileList files only.
find . -maxdepth 1 -type fGet-Command nodeFind the command PowerShell will run.
command -v nodeGet-Command node -AllShow all matching command definitions.
type -a nodeGet-Help Get-ChildItemOpen built-in command help.
man lsGet-Help command -ExamplesShow command examples.
man commandHistory & Screen
Get-HistoryShow commands from the current PowerShell session.
historyClear-HistoryClear PowerShell session history.
history -pClear-HostClear the terminal display.
clear$PSVersionTableShow PowerShell version and platform details.
zsh --version$HOMEShow the user's home-directory path.
echo $HOME$PWDRead the current PowerShell path object.
pwdOpen from Terminal
Invoke-Item .Open the current directory in the default file manager.
open .Invoke-Item file.pdfOpen a file with its default application.
open file.pdfStart-Process https://example.comOpen a URL with the default browser.
open https://example.comStart-Process code -ArgumentList '.'Launch an installed application/CLI with arguments.
code .Create, copy, move, rename, remove, inspect, and compare filesystem objects without leaving the terminal.
WINDOWS
PowerShell-first
PowerShell-first
PURPOSE
What the command does
What the command does
macOS
zsh / Terminal
zsh / Terminal
02 — Files & Directories
Create
New-Item -ItemType Directory folderCreate a directory.
mkdir folderNew-Item -ItemType Directory a/b -ForceCreate a nested directory path.
mkdir -p a/bNew-Item -ItemType File file.txtCreate an empty file.
touch file.txtSet-Content file.txt 'text'Create or replace a text file with content.
printf '%s\n' 'text' > file.txtAdd-Content file.txt 'text'Append text to a file.
printf '%s\n' 'text' >> file.txtCopy, Move & Rename
Copy-Item file.txt copy.txtCopy a file.
cp file.txt copy.txtCopy-Item folder dest -RecurseCopy a directory tree.
cp -R folder destMove-Item old newMove a file or folder.
mv old newRename-Item old.txt new.txtRename an item.
mv old.txt new.txtCopy-Item *.txt destCopy files matching a wildcard.
cp *.txt destRemove Carefully
Remove-Item file.txtDelete a file.
rm file.txtRemove-Item folder -RecurseDelete a directory tree.
rm -r folderRemove-Item folder -Recurse -ForceForce-remove a directory tree. Verify the path first.
rm -rf folderRemove-Item *.tmpDelete files matching a wildcard.
rm *.tmpGet-ChildItem pathInspect the target before a destructive command.
ls -la pathPaths & Names
Split-Path path -LeafReturn the final file/folder name.
basename pathSplit-Path path -ParentReturn the parent-directory path.
dirname pathResolve-Path pathResolve a path to its full provider path.
realpath pathTest-Path pathCheck whether a path exists.
test -e pathJoin-Path parent childBuild a path from components.
printf '%s/%s\n' "$parent" "$child"Inspect file content, search recursively, count and sort data, use pipelines, and redirect standard streams.
WINDOWS
PowerShell-first
PowerShell-first
PURPOSE
What the command does
What the command does
macOS
zsh / Terminal
zsh / Terminal
03 — Read, Search & Transform Text
Read Files
Get-Content file.txtPrint a text file.
cat file.txtGet-Content file.txt -Head 20Show the first 20 lines.
head -n 20 file.txtGet-Content file.txt -Tail 20Show the last 20 lines.
tail -n 20 file.txtGet-Content app.log -WaitFollow a growing log file.
tail -f app.logGet-Content file.txt -RawRead an entire text file as one string.
cat file.txtSearch Text
Select-String 'text' file.txtFind matching text and line information.
grep -n 'text' file.txtGet-ChildItem -Recurse -File | Select-String 'text'Search text recursively through files.
grep -Rni 'text' .Select-String 'error' *.log -CaseSensitiveSearch matching files with case sensitivity.
grep -n 'error' *.logSelect-String '^TODO' file.txtSearch with a regular expression.
grep -n '^TODO' file.txtFind Files
Get-ChildItem -Recurse -Filter *.js -FileFind files by name pattern.
find . -name '*.js' -type fGet-ChildItem -Recurse -DirectoryFind directories recursively.
find . -type dGet-ChildItem -File | Where-Object LastWriteTime -gt (Get-Date).AddDays(-1)Find files modified within the last day.
find . -type f -mtime -1Get-ChildItem -Recurse -File | Where-Object Length -gt 10MBFind files larger than a size threshold.
find . -type f -size +10MCount, Sort & Group
(Get-Content file.txt).CountCount lines in a text file.
wc -l file.txtGet-ChildItem | Measure-ObjectCount pipeline objects.
find . -maxdepth 1 | wc -lGet-Content file.txt | Sort-ObjectSort lines.
sort file.txtGet-Content file.txt | Sort-Object -UniqueSort and remove duplicate lines.
sort -u file.txtGet-Content file.txt | Group-ObjectGroup equal lines and count occurrences.
sort file.txt | uniq -cPipelines & Redirection
Get-Process | Sort-Object CPUPipe objects from one command into another.
ps aux | sortcommand > file.txtOverwrite a file with standard output.
command > file.txtcommand >> file.txtAppend standard output to a file.
command >> file.txtcommand 2> errors.txtRedirect the error stream.
command 2> errors.txtcommand *> all.txtPowerShell: redirect all streams to one file.
command > all.txt 2>&1PowerShell 7: a && bRun the second command only if the first succeeds.
a && bPowerShell 7: a || bRun the second command only if the first fails.
a || bClipboard
Get-ClipboardRead clipboard text.
pbpaste'text' | Set-ClipboardCopy pipeline text to the clipboard.
printf '%s' 'text' | pbcopyGet-Content file.txt | Set-ClipboardCopy file contents to the clipboard.
pbcopy < file.txtProcesses
Get-ProcessList running processes.
ps auxGet-Process -Id 1234Inspect one process by PID.
ps -p 1234Get-Process nodeFind processes by executable/process name.
pgrep -fl nodeStop-Process -Id 1234Request that a process stop.
kill 1234Stop-Process -Id 1234 -ForceForce-stop a process; use as a last resort.
kill -9 1234Start-Process app.exeStart a process.
open -a 'App Name'Jobs & Background Work
Start-Job { command }Start a PowerShell background job.
command &Get-JobList PowerShell background jobs.
jobsReceive-Job idRead output from a PowerShell job.
wait %jobStop-Job idStop a PowerShell background job.
kill %jobCtrl+CInterrupt the foreground command.
Ctrl+CPorts
Get-NetTCPConnection -LocalPort 3000Find TCP connections/listeners using a local port.
lsof -i :3000Get-NetTCPConnection -State ListenList listening TCP endpoints.
lsof -nP -iTCP -sTCP:LISTENGet-Process -Id PIDInspect the process after identifying its PID.
ps -p PIDStop-Process -Id PIDStop the process causing a local port conflict.
kill PIDSystem Information
Get-ComputerInfoDisplay broad operating-system and hardware information.
system_profiler SPSoftwareDataType SPHardwareDataTypesysteminfoShow Windows OS, memory, boot, and system details.
sw_vers$env:PROCESSOR_ARCHITECTUREShow the process architecture.
uname -mGet-DateShow the current local date and time.
dateGet-TimeZoneShow the configured time zone.
systemsetup -gettimezonehostnameShow the machine hostname.
hostnamewhoamiShow the current user identity.
whoamiDisk & Storage
Get-PSDrive -PSProvider FileSystemShow filesystem drives and free/used space.
df -hGet-VolumeShow Windows volume information.
diskutil listGet-ChildItem folder -Recurse -File | Measure-Object Length -SumCalculate total file bytes under a folder.
du -sh folderGet-ChildItem folder | Sort-Object Length -DescendingFind larger items in a directory.
du -sh folder/* | sort -hWork with environment variables, PATH, shell profiles, aliases, package managers, and terminal configuration.
WINDOWS
PowerShell-first
PowerShell-first
PURPOSE
What the command does
What the command does
macOS
zsh / Terminal
zsh / Terminal
05 — Environment, Shell & Packages
Environment Variables
$env:NAMERead one environment variable.
printenv NAME$env:NAME = 'value'Set an environment variable for the current shell session.
export NAME=valueRemove-Item Env:NAMERemove a session environment variable.
unset NAMEGet-ChildItem Env:List environment variables.
printenv | sort$env:PATHShow the executable search path.
echo $PATH$env:PATH -split ';'Display Windows PATH entries individually.
printf '%s\n' ${PATH//:/ }Profiles & Shell Configuration
$PROFILEShow the current PowerShell profile path.
echo ~/.zshrcTest-Path $PROFILECheck whether the PowerShell profile exists.
test -f ~/.zshrcnotepad $PROFILEEdit the PowerShell profile with Notepad.
nano ~/.zshrc. $PROFILEReload the PowerShell profile in the current session.
source ~/.zshrcpwshStart PowerShell 7 if installed.
exec zshAliases & Functions
Get-AliasList PowerShell aliases.
aliasGet-Alias lsSee which command an alias resolves to.
type lsSet-Alias ll Get-ChildItemCreate a session alias.
alias ll='ls -lah'Remove-Item Alias:llRemove a session alias.
unalias llfunction Name { ... }Define a reusable shell function.
Name() { ...; }Windows Package Manager / Homebrew
winget search packageSearch the OS package manager.
brew search packagewinget install IDInstall a package.
brew install packagewinget listList installed packages known to the package manager.
brew listwinget upgradeShow packages with upgrades available.
brew outdatedwinget upgrade --allUpgrade supported installed packages.
brew upgradewinget uninstall IDRemove a package.
brew uninstall packagewinget source updateRefresh package-source metadata.
brew updateCommand Resolution
Get-Command nameShow which executable/function/alias will run.
command -v nameGet-Command name -AllShow all command matches PowerShell can resolve.
type -a namewhere.exe nameSearch Windows PATH for matching executable files.
which -a nameGet-Command name | Format-List *Inspect command type, source, path, and metadata.
type nameDiagnose networking, test HTTP and ports, use SSH, compress files, and apply a fast terminal troubleshooting loop.
WINDOWS
PowerShell-first
PowerShell-first
PURPOSE
What the command does
What the command does
macOS
zsh / Terminal
zsh / Terminal
06 — Network, Remote, Archives & Recovery
Network Identity & DNS
ipconfigShow Windows IP configuration.
ifconfigGet-NetIPAddressList Windows IP addresses and interfaces.
ipconfig getifaddr en0Test-Connection hostSend ICMP echo requests.
ping hostResolve-DnsName example.comResolve DNS records.
dig example.comnslookup example.comRun a traditional DNS lookup.
nslookup example.comGet-NetRouteInspect the Windows routing table.
netstat -rnPorts & Connectivity
Test-NetConnection host -Port 443Test whether a TCP port is reachable.
nc -vz host 443Get-NetTCPConnection -LocalPort 5173Find the process endpoint using a development port.
lsof -i :5173Test-NetConnection host -TraceRouteTrace the network path where supported.
traceroute hostGet-NetAdapterList Windows network adapters.
networksetup -listallhardwareportsHTTP
curl.exe URLSend a basic HTTP GET request using curl.
curl URLcurl.exe -I URLRequest response headers only.
curl -I URLcurl.exe -L URLFollow HTTP redirects.
curl -L URLcurl.exe -o file URLDownload response content to a file.
curl -o file URLInvoke-WebRequest URLPowerShell-native web request with structured response information.
curl -i URLInvoke-RestMethod URLPowerShell-native request that parses common structured API responses.
curl URLSSH & Secure Copy
ssh user@hostOpen an SSH session when OpenSSH is installed.
ssh user@hostssh-keygen -t ed25519Create an Ed25519 SSH key pair.
ssh-keygen -t ed25519ssh-add path\to\keyAdd a private key to the SSH authentication agent.
ssh-add ~/.ssh/id_ed25519scp file user@host:/pathCopy a file over SSH.
scp file user@host:/pathscp -r folder user@host:/pathCopy a directory recursively over SSH.
scp -r folder user@host:/pathssh -T git@github.comTest SSH authentication to GitHub.
ssh -T git@github.comArchives
Compress-Archive -Path folder -DestinationPath archive.zipCreate a ZIP archive.
zip -r archive.zip folderExpand-Archive archive.zip -DestinationPath folderExtract a ZIP archive.
unzip archive.zip -d foldertar -czf archive.tar.gz folderCreate a gzip-compressed tar archive with modern Windows tar.
tar -czf archive.tar.gz foldertar -xzf archive.tar.gzExtract a gzip-compressed tar archive.
tar -xzf archive.tar.gztar -tf archive.tar.gzList archive contents without extracting.
tar -tf archive.tar.gzFast Troubleshooting Loop
Get-Location; Get-ChildItem -ForceConfirm the current project/location and visible files.
pwd && ls -laGet-Command toolConfirm a required command is installed and resolvable.
command -v tool$PSVersionTableConfirm shell/runtime environment when shell behavior is unexpected.
echo $SHELL; zsh --versionGet-ChildItem Env:Inspect environment configuration.
printenv | sortGet-NetTCPConnection -LocalPort PORTCheck for a local port conflict.
lsof -i :PORTTest-NetConnection localhost -Port PORTTest whether a local TCP service is reachable.
nc -vz localhost PORTcurl.exe -I http://localhost:PORTConfirm that a local HTTP server responds.
curl -I http://localhost:PORTHigh-Risk Commands
Remove-Item path -Recurse -ForceCan permanently delete a directory tree. Verify the exact path.
rm -rf pathStop-Process -Id PID -ForceForce termination can lose unsaved state; use only when normal stop fails.
kill -9 PIDicacls path /grant ...Permission changes can expose or lock out files; inspect ACLs first.
chmod / chownwinget upgrade --allBulk upgrades can change many installed tools; review before running.
brew upgradeElevated PowerShellAdministrator/root commands can alter the whole system.
sudo commandKeyboard Recall
Ctrl+CInterrupt the foreground command.
Ctrl+CTabComplete commands and paths.
TabUp / DownMove through command history.
Up / DownCtrl+LClear/redraw the screen in shells that support it.
Ctrl+LCtrl+RReverse-search history when PSReadLine/shell bindings support it.
Ctrl+R