Windows CMD vs macOS Terminal: Essential Commands Side by Side
The command line looks intimidating at first, but it is one of the fastest ways to manage files, test a network and fix problems on a computer. Windows and macOS each have their own command line, and the commands are different. If you switch between a Windows laptop and a Mac, or support users on both, you need to know both sets. This guide shows the most useful Windows Command Prompt (CMD) commands and macOS Terminal commands side by side, with practical examples and safety tips.
How to open the command line
On Windows: press the Windows key, type cmd and press Enter. For tasks that change the system, right-click Command Prompt and choose Run as administrator. Windows 11 also includes Windows Terminal, an app that can hold CMD and PowerShell in separate tabs.
On macOS: press Command + Space, type Terminal and press Enter, or open Applications, then Utilities, then Terminal. Modern macOS uses the zsh shell, which is Unix-like, so many commands match the ones used on Linux servers. If you work with servers, my guide to essential Linux commands will feel familiar.
Key differences to know first
- Paths: Windows uses backslashes and drive letters such as C: and D:. macOS uses forward slashes and a single file tree that starts at the root folder, with your home folder written as
~. - Options: Windows commands usually take switches with a slash, such as
dir /a. macOS commands use a dash, such asls -a. - Case: Windows commands are not case-sensitive. On macOS, commands and options are:
lsworks, butLSdoes not. - Spaces: if a file or folder name contains spaces, wrap it in quotes on both systems.
- PowerShell: Windows also has PowerShell, a more powerful shell that understands aliases such as
lsandcat. This article focuses on classic CMD.
Side-by-side command table
Use this table as a quick reference. Commands on the same row do the same job.
| Task | Windows (CMD) | macOS (Terminal) |
|---|---|---|
| Navigation | ||
| Show current folder | cd | pwd |
| List files | dir or dir /a | ls or ls -la |
| Open a folder | cd Documents | cd Documents |
| Go up one level | cd .. | cd .. |
| Go to your home folder | cd %USERPROFILE% | cd ~ |
| Files and folders | ||
| Create a folder | mkdir projects | mkdir projects |
| Create an empty file | type nul > file.txt | touch file.txt |
| Copy a file | copy a.txt b.txt | cp a.txt b.txt |
| Copy a folder | xcopy src dest /E /I | cp -r src dest |
| Move or rename | move a.txt b.txt or ren a.txt b.txt | mv a.txt b.txt |
| Delete a file | del file.txt | rm file.txt |
| Delete a folder | rmdir /s /q folder | rm -r folder |
| Show file contents | type file.txt | cat file.txt |
| Searching | ||
| Search text in a file | findstr /i "error" log.txt | grep -i "error" log.txt |
| Find where a program lives | where python | which python3 |
| System and processes | ||
| OS version | ver | sw_vers |
| System details | systeminfo | uname -a |
| Current user | whoami | whoami |
| Computer name | hostname | hostname |
| Show the PATH variable | echo %PATH% | echo $PATH |
| List running processes | tasklist | ps aux |
| Stop a process | taskkill /PID 1234 /F | kill 1234 or kill -9 1234 |
| Live resource monitor | Task Manager (Ctrl+Shift+Esc) | top |
| Restart | shutdown /r /t 0 | sudo shutdown -r now |
| Shut down | shutdown /s /t 0 | sudo shutdown -h now |
| Network | ||
| Show your IP address | ipconfig | ipconfig getifaddr en0 |
| Ping a host | ping google.com | ping -c 4 google.com |
| Trace the route | tracert google.com | traceroute google.com |
| DNS lookup | nslookup google.com | nslookup google.com |
| Open ports and connections | netstat -ano | netstat -an or lsof -i |
| Flush the DNS cache | ipconfig /flushdns | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
| Test a web address | curl -I https://example.com | curl -I https://example.com |
| Handy extras | ||
| Clear the screen | cls | clear |
| Get help | help dir | man ls |
| Open the current folder in the file manager | start . | open . |
| Copy command output to the clipboard | dir | clip | ls | pbcopy |
| Install software | winget install name | brew install name |
Example 1: Set up a project folder
On Windows, run the following in Command Prompt:
cd %USERPROFILE%
mkdir projects
cd projects
type nul > notes.txt
dir
On macOS, the same job looks like this:
cd ~
mkdir projects
cd projects
touch notes.txt
ls -la
Both versions move to your home folder, create a folder called projects, enter it, create an empty file and list the contents.
Example 2: Troubleshoot a slow or broken internet connection
Network commands are where the command line really shines. Work through these steps in order:
- Check that you have an IP address with
ipconfigon Windows oripconfig getifaddr en0on macOS. On a Mac, Wi-Fi is usually en0, but yours may differ. - Ping a public IP address, such as
ping 8.8.8.8. If this works, your internet connection is fine. - Ping a domain name, such as
ping google.com. If the IP address works but the name fails, the problem is DNS. - Flush the DNS cache with the command from the table and try again.
Note that Windows sends four pings and stops, while macOS keeps pinging until you press Ctrl + C. Use ping -c 4 on a Mac to get the same result as Windows.
Example 3: Find and stop the program using a port
Developers often see an error that a port such as 3000 is already in use. On Windows, find the process ID and stop it:
netstat -ano | findstr :3000
taskkill /PID 1234 /F
On macOS, do the same with:
lsof -i :3000
kill 1234
Replace 1234 with the real process ID shown in the first command. On macOS, try the plain kill first. Use kill -9 only if the program refuses to stop.
Handy commands that exist on only one system
- macOS:
open .opens the current folder in Finder,pbcopyandpbpastework with the clipboard,caffeinatekeeps the Mac awake, andsoftwareupdate -llists available system updates. - Windows:
start .opens File Explorer,clipcopies output to the clipboard,wingetinstalls software, andsfc /scannowchecks system files when run as administrator.
Safety tips before you press Enter
- Deleting from the command line is permanent. There is no Recycle Bin or Trash, so
del,rmdir /sandrm -rcannot be undone. - List a folder with
dirorlsbefore you delete it, to be sure you are in the right place. - Avoid disk tools such as
formatanddiskpartunless you know exactly what they do. - Use administrator rights or
sudoonly when a task truly needs them. - Never paste commands from a website you do not trust. A single line can delete files or install malware.
Tips to work faster
Press Tab to complete file names and commands, and press the Up arrow to bring back earlier commands. Press Ctrl + C to stop a command that is still running. On both systems you can drag a file or folder into the window to paste its full path. When you forget an option, use help command on Windows or man command on macOS.
Summary
Windows CMD and macOS Terminal reach the same goals with different words: dir and ls, copy and cp, tasklist and ps, ipconfig and ifconfig. Learn the table above, practise on a test folder, and be careful with anything that deletes. Once you are comfortable, try connecting to servers with SSH keys, which works from both Windows and macOS, or read the cybersecurity roadmap for 2026 to see where these skills lead.