Comparing Command Lines: Windows, Linux, and macOS

It’s been an exciting week since I got my new MacBook, and I’ve been eager to explore its capabilities. As a Windows user familiar with the Command Line Interface (CLI), I was curious to see how my skills would transfer to a UNIX-based system like macOS. While my experience with Linux helped ease the transition, I still encountered some differences that took some getting used to.

In this article, I’ve compiled my findings and experiences. Let’s dive in below for the differences

Networking Commands

Command/ToolWindowsLinuxmacOSExample
Pingpingpingpingping google.com
Trace Routetracerttraceroutetraceroutetracert google.com (Windows), traceroute google.com (Linux/macOS)
IP Configurationipconfigifconfig or ip aifconfigipconfig (Windows), ifconfig (Linux/macOS)
Display Networknetstatnetstatnetstatnetstat -an
DNS Lookupnslookupnslookupnslookupnslookup google.com
Network Diagnosticspathpingmtrmtrpathping google.com (Windows), mtr google.com (Linux/macOS)
Download Filesbitsadminwgetcurlbitsadmin /transfer jobname /download /priority foreground https://example.com/file.zip C:\file.zip (Windows), wget https://example.com/file.zip (Linux/macOS)
Check Listening Portsnetstat -anss -tulnnetstat -annetstat -an
SSH ConnectionPuTTYsshsshPuTTY (Windows), ssh user@hostname (Linux/macOS)
FTP Clientftpftpftpftp ftp.example.com

Security Commands

Command/ToolWindowsLinuxmacOSExample
User Managementnet useruseradd, usermod, userdeldscl . -createnet user username /add (Windows), useradd username (Linux), dscl . -create /Users/username (macOS)
Change Passwordnet userpasswdpasswdnet user username * (Windows), passwd username (Linux/macOS)
File Permissionsicaclschmod, chownchmod, chownicacls file.txt /grant user:F (Windows), chmod 755 file.txt (Linux/macOS)
Firewall Confignetsh advfirewalliptables, ufwpfctlnetsh advfirewall set allprofiles state off (Windows), ufw enable (Linux), sudo pfctl -e (macOS)
Encrypt FilesBitLockergpg, cryptsetupgpgBitLocker (GUI for Windows), gpg -c file.txt (Linux/macOS)
View LogsEvent Viewerdmesg, journalctllog showEvent Viewer (Windows), journalctl -xe (Linux), log show (macOS)
Disable Accountnet userusermod -Ldscl . -createnet user username /active:no (Windows), usermod -L username (Linux), dscl . -create /Users/username (macOS)
Enable Accountnet userusermod -Udscl . -createnet user username /active:yes (Windows), usermod -U username (Linux), dscl . -create /Users/username (macOS)
View Active Connectionsnetstat -anssnetstat -annetstat -an
Security UpdatesWindows Updateapt-get updateSoftware UpdateWindows Update (GUI for Windows), apt-get update (Linux), Software Update (GUI for macOS)

File Operations

Command/ToolWindowsLinuxmacOSExample
List Filesdirlslsdir (Windows), ls (Linux/macOS)
Change Directorycdcdcdcd C:\Users (Windows), cd /home/user (Linux/macOS)
Copy Filescopy or xcopycpcpcopy file.txt D:\ (Windows), cp file.txt /home/user (Linux/macOS)
Move/Rename Filesmovemvmvmove file.txt D:\ (Windows), mv file.txt /home/user (Linux/macOS)
Delete Filesdel or erasermrmdel file.txt (Windows), rm file.txt (Linux/macOS)
Create Directorymkdirmkdirmkdirmkdir newfolder
Remove Directoryrmdirrmdir or rm -rrmdir or rm -rrmdir newfolder
Display File Contentstypecatcattype file.txt (Windows), cat file.txt (Linux/macOS)
Find Text in Filesfindstrgrepgrepfindstr "text" file.txt (Windows), grep "text" file.txt (Linux/macOS)
Compare Filesfcdiffdifffc file1.txt file2.txt (Windows), diff file1.txt file2.txt (Linux/macOS)

System Information Commands

Command/ToolWindowsLinuxmacOSExample
System Infosysteminfouname -auname -asysteminfo (Windows), uname -a (Linux/macOS)
Disk Usagechkdskdf and dudf and duchkdsk (Windows), df -h (Linux/macOS)
Memory Usagesysteminfofreevm_statsysteminfo (Windows), free -h (Linux), vm_stat (macOS)
Uptimesysteminfouptimeuptimesysteminfo (Windows), uptime (Linux/macOS)
Hardware Infowmiclshwsystem_profilerwmic cpu get name (Windows), lshw (Linux), system_profiler (macOS)
List USB Deviceswmic path CIM_LogicalDevice where “Description like ‘USB%'” get /valuelsusbsystem_profiler SPUSBDataTypewmic path CIM_LogicalDevice where "Description like 'USB%'" get /value (Windows), lsusb (Linux), system_profiler SPUSBDataType (macOS)
Kernel MessagesEvent ViewerdmesgdmesgEvent Viewer (Windows), dmesg (Linux/macOS)
Check Date and Timedatedatedatedate /T (Windows), date (Linux/macOS)
Check Time Zonetzutiltimedatectlsystemsetuptzutil /g (Windows), timedatectl (Linux), systemsetup -gettimezone (macOS)
Installed Packageswmic product get namedpkg –list or rpm -qasystem_profiler SPInstallHistoryDataTypewmic product get name (Windows), dpkg --list (Debian-based Linux), rpm -qa (Red Hat-based Linux), system_profiler SPInstallHistoryDataType (macOS)

Process Management Commands

Command/ToolWindowsLinuxmacOSExample
List Processestasklistps or topps or toptasklist (Windows), ps aux (Linux/macOS)
Kill Processtaskkillkill or killallkill or killalltaskkill /PID <pid> (Windows), kill <pid> (Linux/macOS)
Prioritize Processwmic process where name=”processname” CALL setpriority “priority”renice, nicerenice, nicewmic process where name="notepad.exe" CALL setpriority "above normal" (Windows), renice +10 1234 (Linux/macOS)
Start a Processstart&, nohup, screenopenstart notepad.exe (Windows), ./program & (Linux), open -a "TextEdit" file.txt (macOS)
Stop a Servicenet stopsystemctl stoplaunchctl unloadnet stop servicename (Windows), systemctl stop servicename (Linux), launchctl unload service.plist (macOS)
Restart a Servicenet stop and net startsystemctl restartlaunchctl stopnet stop servicename and net start servicename (Windows), systemctl restart servicename (Linux), launchctl stop servicename and launchctl start servicename (macOS)
Check Process Activityperfmontop, htoptopperfmon (Windows), top (Linux/macOS)
Check Open Fileshandlelsoflsofhandle filename (Windows), lsof filename (Linux/macOS)
Background Processstart or start-process&, nohup, screen&, nohup, screenstart notepad.exe (Windows), ./program & (Linux), nohup command & (macOS)

Battery and Power Information Commands

Command/ToolWindowsLinuxmacOSExample
Battery Statuspowercfg /batteryreportacpi, upower, cat /sys/class/power_supply/BAT0/statussystem_profiler SPPowerDataTypepowercfg /batteryreport (Windows), acpi -b (Linux), system_profiler SPPowerDataType (macOS)
Power Plan Infopowercfg /lcat /sys/class/power_supply/AC/online, cat /sys/class/power_supply/BAT0/charge_nowpmset -gpowercfg /l (Windows), cat /sys/class/power_supply/AC/online (Linux), pmset -g (macOS)
Battery Healthpowercfg /batteryhealthreportupower -i /org/freedesktop/UPower/devices/battery_BAT0system_profiler SPPowerDataTypepowercfg /batteryhealthreport (Windows), upower -i /org/freedesktop/UPower/devices/battery_BAT0 (Linux), system_profiler SPPowerDataType (macOS)
Power Settingspowercfgpowertop, tlppmsetpowercfg (Windows), powertop (Linux), pmset (macOS)
Battery Usagepowercfg /batteryreportacpi, upower, cat /sys/class/power_supply/BAT0/charge_full_designsystem_profiler SPPowerDataTypepowercfg /batteryreport (Windows), acpi -b (Linux), system_profiler SPPowerDataType (macOS)
Charging Statuspowercfg /batteryreportacpi, upower, cat /sys/class/power_supply/BAT0/statussystem_profiler SPPowerDataTypepowercfg /batteryreport (Windows), acpi -b (Linux), system_profiler SPPowerDataType (macOS)

Scripting and Automation Commands Comparison

Scripting and automation are essential for streamlining tasks and enhancing productivity. Here’s a comparison of commonly used commands in batch scripting for Windows and shell scripting for Linux/macOS:

TaskBatch (Windows)Shell (Linux/macOS)Example
CommentREM#REM This is a comment (Windows), # This is a comment (Linux/macOS)
Assign VariableSETVAR=SET var=value (Windows), VAR=value (Linux/macOS)
Echo OutputECHOechoECHO Hello, World! (Windows), echo "Hello, World!" (Linux/macOS)
Run CommandCALL( )CALL command (Windows), (command) (Linux/macOS)
Conditional ExecutionIFifIF condition (command) (Windows), if [ condition ]; then command; fi (Linux/macOS)
LoopingFORforFOR /L %%variable IN (start,step,end) DO command (Windows), for variable in list; do command; done (Linux/macOS)
Check File ExistenceIF EXIST[ -e ]IF EXIST filename (command) (Windows), [ -e filename ] && command (Linux/macOS)
File OperationsCOPY, MOVE, DELcp, mv, rmCOPY source destination (Windows), cp source destination (Linux/macOS)
Text ProcessingFINDSTRgrepFINDSTR "pattern" filename (Windows), grep "pattern" filename (Linux/macOS)
Environment Variables%VAR%$VARECHO %VAR% (Windows), echo $VAR (Linux/macOS)
Run as AdministratorRun as administratorsudoRight-click and select “Run as administrator” (Windows), sudo command (Linux/macOS)
Copy FileCOPYcpCOPY C:\source\file.txt D:\destination\file.txt (Windows), cp /path/to/source/file.txt /path/to/destination/file.txt (Linux/macOS)

My exploration of command line interfaces has led me to the following conclusions:

  • Windows: Uses a different kernel (Windows NT), so its CLI commands are distinct, requiring a different set of skills.
  • Linux/macOS: Both are UNIX-based, making their terminal commands similar and familiar if you have experience with one.

Discover more from Data Engineer Journey

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Discover more from Data Engineer Journey

Subscribe now to keep reading and get access to the full archive.

Continue reading