NAWAZ SHARIF
October 17, 2026 · Command Line · By Nawaz Sharif

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

Side-by-side command table

Use this table as a quick reference. Commands on the same row do the same job.

TaskWindows (CMD)macOS (Terminal)
Navigation
Show current foldercdpwd
List filesdir or dir /als or ls -la
Open a foldercd Documentscd Documents
Go up one levelcd ..cd ..
Go to your home foldercd %USERPROFILE%cd ~
Files and folders
Create a foldermkdir projectsmkdir projects
Create an empty filetype nul > file.txttouch file.txt
Copy a filecopy a.txt b.txtcp a.txt b.txt
Copy a folderxcopy src dest /E /Icp -r src dest
Move or renamemove a.txt b.txt or ren a.txt b.txtmv a.txt b.txt
Delete a filedel file.txtrm file.txt
Delete a folderrmdir /s /q folderrm -r folder
Show file contentstype file.txtcat file.txt
Searching
Search text in a filefindstr /i "error" log.txtgrep -i "error" log.txt
Find where a program liveswhere pythonwhich python3
System and processes
OS versionversw_vers
System detailssysteminfouname -a
Current userwhoamiwhoami
Computer namehostnamehostname
Show the PATH variableecho %PATH%echo $PATH
List running processestasklistps aux
Stop a processtaskkill /PID 1234 /Fkill 1234 or kill -9 1234
Live resource monitorTask Manager (Ctrl+Shift+Esc)top
Restartshutdown /r /t 0sudo shutdown -r now
Shut downshutdown /s /t 0sudo shutdown -h now
Network
Show your IP addressipconfigipconfig getifaddr en0
Ping a hostping google.comping -c 4 google.com
Trace the routetracert google.comtraceroute google.com
DNS lookupnslookup google.comnslookup google.com
Open ports and connectionsnetstat -anonetstat -an or lsof -i
Flush the DNS cacheipconfig /flushdnssudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Test a web addresscurl -I https://example.comcurl -I https://example.com
Handy extras
Clear the screenclsclear
Get helphelp dirman ls
Open the current folder in the file managerstart .open .
Copy command output to the clipboarddir | clipls | pbcopy
Install softwarewinget install namebrew 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:

  1. Check that you have an IP address with ipconfig on Windows or ipconfig getifaddr en0 on macOS. On a Mac, Wi-Fi is usually en0, but yours may differ.
  2. Ping a public IP address, such as ping 8.8.8.8. If this works, your internet connection is fine.
  3. Ping a domain name, such as ping google.com. If the IP address works but the name fails, the problem is DNS.
  4. 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

Safety tips before you press Enter

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.

← All articles