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/Tool Windows Linux macOS Example Ping ping ping ping ping google.com
Trace Route tracert traceroute traceroute tracert google.com
(Windows), traceroute google.com
(Linux/macOS)IP Configuration ipconfig ifconfig or ip a ifconfig ipconfig
(Windows), ifconfig
(Linux/macOS)Display Network netstat netstat netstat netstat -an
DNS Lookup nslookup nslookup nslookup nslookup google.com
Network Diagnostics pathping mtr mtr pathping google.com
(Windows), mtr google.com
(Linux/macOS)Download Files bitsadmin wget curl bitsadmin /transfer jobname /download /priority foreground https://example.com/file.zip C:\file.zip
(Windows), wget https://example.com/file.zip
(Linux/macOS)Check Listening Ports netstat -an ss -tuln netstat -an netstat -an
SSH Connection PuTTY ssh ssh PuTTY
(Windows), ssh user@hostname
(Linux/macOS)FTP Client ftp ftp ftp ftp ftp.example.com
Security Commands
Command/Tool Windows Linux macOS Example User Management net user useradd, usermod, userdel dscl . -create net user username /add
(Windows), useradd username
(Linux), dscl . -create /Users/username
(macOS)Change Password net user passwd passwd net user username *
(Windows), passwd username
(Linux/macOS)File Permissions icacls chmod, chown chmod, chown icacls file.txt /grant user:F
(Windows), chmod 755 file.txt
(Linux/macOS)Firewall Config netsh advfirewall iptables, ufw pfctl netsh advfirewall set allprofiles state off
(Windows), ufw enable
(Linux), sudo pfctl -e
(macOS)Encrypt Files BitLocker gpg, cryptsetup gpg BitLocker (GUI for Windows), gpg -c file.txt
(Linux/macOS)View Logs Event Viewer dmesg, journalctl log show Event Viewer (Windows), journalctl -xe
(Linux), log show
(macOS)Disable Account net user usermod -L dscl . -create net user username /active:no
(Windows), usermod -L username
(Linux), dscl . -create /Users/username
(macOS)Enable Account net user usermod -U dscl . -create net user username /active:yes
(Windows), usermod -U username
(Linux), dscl . -create /Users/username
(macOS)View Active Connections netstat -an ss netstat -an netstat -an
Security Updates Windows Update apt-get update Software Update Windows Update (GUI for Windows), apt-get update
(Linux), Software Update (GUI for macOS)
File Operations
Command/Tool Windows Linux macOS Example List Files dir ls ls dir
(Windows), ls
(Linux/macOS)Change Directory cd cd cd cd C:\Users
(Windows), cd /home/user
(Linux/macOS)Copy Files copy or xcopy cp cp copy file.txt D:\
(Windows), cp file.txt /home/user
(Linux/macOS)Move/Rename Files move mv mv move file.txt D:\
(Windows), mv file.txt /home/user
(Linux/macOS)Delete Files del or erase rm rm del file.txt
(Windows), rm file.txt
(Linux/macOS)Create Directory mkdir mkdir mkdir mkdir newfolder
Remove Directory rmdir rmdir or rm -r rmdir or rm -r rmdir newfolder
Display File Contents type cat cat type file.txt
(Windows), cat file.txt
(Linux/macOS)Find Text in Files findstr grep grep findstr "text" file.txt
(Windows), grep "text" file.txt
(Linux/macOS)Compare Files fc diff diff fc file1.txt file2.txt
(Windows), diff file1.txt file2.txt
(Linux/macOS)
System Information Commands
Command/Tool Windows Linux macOS Example System Info systeminfo uname -a uname -a systeminfo
(Windows), uname -a
(Linux/macOS)Disk Usage chkdsk df and du df and du chkdsk
(Windows), df -h
(Linux/macOS)Memory Usage systeminfo free vm_stat systeminfo
(Windows), free -h
(Linux), vm_stat
(macOS)Uptime systeminfo uptime uptime systeminfo
(Windows), uptime
(Linux/macOS)Hardware Info wmic lshw system_profiler wmic cpu get name
(Windows), lshw
(Linux), system_profiler
(macOS)List USB Devices wmic path CIM_LogicalDevice where “Description like ‘USB%'” get /value lsusb system_profiler SPUSBDataType wmic path CIM_LogicalDevice where "Description like 'USB%'" get /value
(Windows), lsusb
(Linux), system_profiler SPUSBDataType
(macOS)Kernel Messages Event Viewer dmesg dmesg Event Viewer (Windows), dmesg
(Linux/macOS)Check Date and Time date date date date /T
(Windows), date
(Linux/macOS)Check Time Zone tzutil timedatectl systemsetup tzutil /g
(Windows), timedatectl
(Linux), systemsetup -gettimezone
(macOS)Installed Packages wmic product get name dpkg –list or rpm -qa system_profiler SPInstallHistoryDataType wmic product get name
(Windows), dpkg --list
(Debian-based Linux), rpm -qa
(Red Hat-based Linux), system_profiler SPInstallHistoryDataType
(macOS)
Process Management Commands
Command/Tool Windows Linux macOS Example List Processes tasklist ps or top ps or top tasklist
(Windows), ps aux
(Linux/macOS)Kill Process taskkill kill or killall kill or killall taskkill /PID <pid>
(Windows), kill <pid>
(Linux/macOS)Prioritize Process wmic process where name=”processname” CALL setpriority “priority” renice, nice renice, nice wmic process where name="notepad.exe" CALL setpriority "above normal"
(Windows), renice +10 1234
(Linux/macOS)Start a Process start &, nohup, screen open start notepad.exe
(Windows), ./program &
(Linux), open -a "TextEdit" file.txt
(macOS)Stop a Service net stop systemctl stop launchctl unload net stop servicename
(Windows), systemctl stop servicename
(Linux), launchctl unload service.plist
(macOS)Restart a Service net stop and net start systemctl restart launchctl stop net stop servicename
and net start servicename
(Windows), systemctl restart servicename
(Linux), launchctl stop servicename
and launchctl start servicename
(macOS)Check Process Activity perfmon top, htop top perfmon
(Windows), top
(Linux/macOS)Check Open Files handle lsof lsof handle filename
(Windows), lsof filename
(Linux/macOS)Background Process start or start-process &, nohup, screen &, nohup, screen start notepad.exe
(Windows), ./program &
(Linux), nohup command &
(macOS)
Battery and Power Information Commands
Command/Tool Windows Linux macOS Example Battery Status powercfg /batteryreport acpi, upower, cat /sys/class/power_supply/BAT0/status system_profiler SPPowerDataType powercfg /batteryreport
(Windows), acpi -b
(Linux), system_profiler SPPowerDataType
(macOS)Power Plan Info powercfg /l cat /sys/class/power_supply/AC/online, cat /sys/class/power_supply/BAT0/charge_now pmset -g powercfg /l
(Windows), cat /sys/class/power_supply/AC/online
(Linux), pmset -g
(macOS)Battery Health powercfg /batteryhealthreport upower -i /org/freedesktop/UPower/devices/battery_BAT0 system_profiler SPPowerDataType powercfg /batteryhealthreport
(Windows), upower -i /org/freedesktop/UPower/devices/battery_BAT0
(Linux), system_profiler SPPowerDataType
(macOS)Power Settings powercfg powertop, tlp pmset powercfg
(Windows), powertop
(Linux), pmset
(macOS)Battery Usage powercfg /batteryreport acpi, upower, cat /sys/class/power_supply/BAT0/charge_full_design system_profiler SPPowerDataType powercfg /batteryreport
(Windows), acpi -b
(Linux), system_profiler SPPowerDataType
(macOS)Charging Status powercfg /batteryreport acpi, upower, cat /sys/class/power_supply/BAT0/status system_profiler SPPowerDataType powercfg /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:
Task Batch (Windows) Shell (Linux/macOS) Example Comment REM # REM This is a comment
(Windows), # This is a comment
(Linux/macOS)Assign Variable SET VAR= SET var=value
(Windows), VAR=value
(Linux/macOS)Echo Output ECHO echo ECHO Hello, World!
(Windows), echo "Hello, World!"
(Linux/macOS)Run Command CALL ( ) CALL command
(Windows), (command)
(Linux/macOS)Conditional Execution IF if IF condition (command)
(Windows), if [ condition ]; then command; fi
(Linux/macOS)Looping FOR for FOR /L %%variable IN (start,step,end) DO command
(Windows), for variable in list; do command; done
(Linux/macOS)Check File Existence IF EXIST [ -e ] IF EXIST filename (command)
(Windows), [ -e filename ] && command
(Linux/macOS)File Operations COPY, MOVE, DEL cp, mv, rm COPY source destination
(Windows), cp source destination
(Linux/macOS)Text Processing FINDSTR grep FINDSTR "pattern" filename
(Windows), grep "pattern" filename
(Linux/macOS)Environment Variables %VAR% $VAR ECHO %VAR%
(Windows), echo $VAR
(Linux/macOS)Run as Administrator Run as administrator sudo Right-click and select “Run as administrator” (Windows), sudo command
(Linux/macOS) Copy File COPY cp COPY 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.
Post Views: 189
Like this: Like Loading...
Related
Discover more from Data Engineer Journey
Subscribe to get the latest posts sent to your email.