99

Concurrent visitors over the last 30 minutes. (~)

Peak concurrent visitors -
Yesterday: 0 / Today: 0

A Summary of Basic Terminal Commands

Terminal
3 months ago
0

Here are the basic terminal commands you'll use often in macOS (zsh/bash), Windows PowerShell, and CMD.

Purpose macOS PowerShell CMD
Show the current location pwd pwd cd
List items ls -al ls / dir dir
Go to a specific folder cd ~/apple/banana cd $HOME\apple\banana cd /d C:\apple\banana
Go to the parent folder cd .. cd .. cd ..
Go to the home folder cd ~ cd ~ cd %USERPROFILE%
Clear the screen clear cls cls
Create a folder mkdir -p apple/banana mkdir apple\banana mkdir apple\banana
Create an empty file touch cherry.md ni cherry.md type nul > cherry.md
Copy cp -r apple banana cp -r apple banana xcopy /E /I apple banana
Move and rename mv apple banana mv apple banana move apple banana
Delete a folder rm -rf apple rm -r -fo apple rmdir /s /q apple
Print contents cat cherry.md cat cherry.md type cherry.md
Command location which claude gcm claude where claude

If a path contains spaces, wrap it in quotes, like cd "C:\My Project".
type nul > cherry.md erases all the contents of a file with the same name if it already exists, leaving an empty file.

What the path symbols mean:

Symbol Meaning
~ Home folder (macOS, PowerShell)
$HOME Variable that holds the home folder path (PowerShell)
%USERPROFILE% Environment variable that holds the home folder path (CMD)
.. Parent folder of the current location

What the flags mean:

Flags start with - in macOS and PowerShell, and with / in CMD.
In macOS, you can combine ls -a -l into ls -al.

Flag Example Meaning
-a ls -a Shows all items, including hidden files
-l ls -l Shows details (Long) such as permissions, size, and modification date
-p mkdir -p apple/banana Also creates the intermediate folders (Parents) if they don't exist
-r cp -r, rm -rf Processes everything inside the folder recursively
-f rm -rf Deletes forcibly without asking for confirmation
-fo rm -r -fo Forced deletion; in PowerShell, -f is ambiguous with other options, so it's shortened to -fo
/d cd /d C:\apple\banana Needed to move to a drive other than the current drive
/E xcopy /E /I apple banana Copies all subfolders, including empty ones
/I xcopy /E /I apple banana Creates the destination folder if it doesn't exist, then copies
/s rmdir /s /q apple Deletes all subdirectories and files too
/q rmdir /s /q apple Quiet mode that doesn't ask for confirmation before deleting

Terminal shortcuts:

Key Action
Tab Autocomplete paths and commands
↑ / ↓ Recall previous commands
Ctrl + C Stop the running command