Terminal Commands I Keep Looking Up

I started fiddling with Raspberry Pis more often. I had a cooling fan that wouldn’t fire up, an SD card slot that turned out to be fried, and a newly bought board I needed to verify was actually working.

Every time, I’d end up googling or asking AI the same vcgencmd flags or dmesg grep patterns. So I’m putting them all here mostly for myself. So I can come back and take what I need without memorizing any of this.

These cover Raspberry Pi OS, general Linux, and macOS. Where a command doesn’t exist on macOS, I’ve listed the equivalent. Hope this list is helpful for anyone. Even though I find it easier, Asking an AI would be easier..


Compatibility key: Y = works as-is | D = different syntax, see macOS column | N = not available


System Information

CommandWhat it doesLinuxmacOSmacOS equivalent
uname -aKernel, architecture, hostnameYY
hostnameCurrent hostnameYY
cat /etc/os-releaseOS name, version, codenameYNsw_vers
cat /proc/cpuinfoCPU model, cores, revisionYNsysctl -n machdep.cpu.brand_string
free -hRAM usageYNvm_stat or top -l 1 | head -n 10
uptimeUptime and load averagesYY
df -hDisk usage per filesystemYY
lsblkBlock devices and partitionsYNdiskutil list
du -sh *Size of items in current dirYY
ncduInteractive disk usageYYinstall via brew install ncdu

Temperature, Voltage & Throttling

If your Pi is acting up, start here. Fan not spinning, board throttling under load, random reboots. These commands tell you what’s going on.

CommandWhat it doesLinuxmacOSmacOS equivalent
vcgencmd measure_tempSoC temperature (Pi only)NN
vcgencmd measure_voltsCore voltage (Pi only)NN
vcgencmd measure_clock armARM clock speed (Pi only)NN
vcgencmd get_throttledThrottling flags (Pi only)NN
vcgencmd get_mem armMemory split, ARM (Pi only)NN
vcgencmd get_mem gpuMemory split, GPU (Pi only)NN
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freqCPU freq in kHzYNsysctl hw.cpufrequency
cat /sys/class/thermal/thermal_zone0/tempSoC temp in millidegreesYNsudo powermetrics --samplers smc -n 1

Decoding get_throttled

vcgencmd get_throttled returns a hex value. 0x0 means everything is fine. Anything else, check against this table:

BitHexMeaning
00x1Under-voltage detected
10x2ARM frequency capped
20x4Currently throttled
30x8Soft temperature limit active
160x10000Under-voltage has occurred (since boot)
170x20000ARM frequency capping has occurred
180x40000Throttling has occurred
190x80000Soft temperature limit has occurred

Bits 0-3 tell you what’s happening right now. Bits 16-19 tell you what happened at some point since boot. If you see 0x50000, your Pi has been both throttled and under-voltage. Check your power supply and cooling.


Hardware & Peripherals

These help you figure out if the system actually sees your hardware. When my SD card slot was fried, dmesg | grep -i mmc returning nothing was how I found out.

CommandWhat it doesLinuxmacOSmacOS equivalent
lsusbList USB devicesYNsystem_profiler SPUSBDataType
lspciList PCIe devicesYNsystem_profiler SPPCIDataType
lsmodLoaded kernel modulesYNkextstat
i2cdetect -y 1Scan I2C bus 1YN
pinoutGPIO pinout diagram (Pi only)NN
gpio readallGPIO pin states, wiringpi (Pi only)NN
v4l2-ctl --list-devicesList camera devicesYNsystem_profiler SPCameraDataType
aplay -lAudio playback devicesYNsystem_profiler SPAudioDataType
arecord -lAudio capture devicesYNsystem_profiler SPAudioDataType
sudo fdisk -lDetailed disk/partition infoYNdiskutil list

dmesg — your best friend for hardware issues

dmesg dumps the kernel ring buffer. Hardware detection, disconnects, errors, it all ends up here. Pipe it through grep to narrow things down:

CommandWhat to look for
dmesg | tail -50Last 50 kernel messages
dmesg -wLive stream — plug something in and watch
dmesg | grep -i usbUSB device detection and errors
dmesg | grep -i nvmeNVMe drive detection and init
dmesg | grep -i pciAll PCIe device enumeration
dmesg | grep -i voltageUnder-voltage warnings (weak PSU or cable)
dmesg | grep -i eth|wlanNetwork interface init, link up/down
dmesg | grep -i hailoHailo AI accelerator PCIe detection (Pi only)
dmesg | grep -i errorQuick scan for kernel-level errors
dmesg | grep -i fail|warnFailures and warnings across all subsystems

On macOS, dmesg requires sudo and the output is more limited. Use log stream --source kernel for live kernel events.


Networking

CommandWhat it doesLinuxmacOSmacOS equivalent
ip aAll interfaces and IPsYNifconfig
ip routeRouting tableYNnetstat -rn
ss -tulnpOpen ports / listening servicesYNlsof -iTCP -sTCP:LISTEN -nP
ping -c 4 <host>Test connectivityYY
curl ifconfig.mePublic IP addressYY
iwconfigWi-Fi detailsYNairport -I
nmcli device statusNetworkManager summaryYNnetworksetup -listallhardwareports
nmcli connection showSaved network profilesYNnetworksetup -listpreferredwirelessnetworks en0
cat /etc/resolv.confDNS resolver configYY
nmap -sn 192.168.1.0/24Scan local networkYYinstall via brew install nmap
traceroute <host>Trace packet routeYY
sudo iftopLive bandwidth monitorYYinstall via brew install iftop

Processes & Services

CommandWhat it doesLinuxmacOSmacOS equivalent
htopInteractive process viewerYYinstall via brew install htop
topBasic process viewerYY
ps auxAll running processesYY
ps aux | grep <name>Find a specific processYY
kill <pid>Terminate process by PIDYY
kill -9 <pid>Force killYY
systemctl status <svc>Service status and logsYNlaunchctl list
systemctl list-units --type=serviceAll loaded servicesYNlaunchctl list
journalctl -u <svc> -fFollow live service logsYNlog stream --predicate 'subsystem == "<svc>"'
journalctl -bLogs since last bootYNlog show --last boot

Package Management

CommandWhat it doesLinuxmacOSmacOS equivalent
sudo apt updateRefresh package indexYNbrew update
sudo apt upgradeUpgrade installed packagesYNbrew upgrade
sudo apt install <pkg>Install a packageYNbrew install <pkg>
sudo apt remove <pkg>Remove a packageYNbrew uninstall <pkg>
sudo apt autoremoveClean unused dependenciesYNbrew autoremove
apt list --installedAll installed packagesYNbrew list
apt search <keyword>Search packagesYNbrew search <keyword>
apt show <pkg>Package detailsYNbrew info <pkg>
dpkg -lList installed .deb packagesYN
dpkg -L <pkg>Files installed by a packageYNbrew list <pkg>

apt/dpkg is Debian-based. If you’re on Fedora, Arch, or openSUSE you want dnf, pacman, or zypper respectively.


File & Directory Operations

CommandWhat it doesLinuxmacOSmacOS equivalent
ls -lahDetailed listing with hidden filesYY
find / -name "filename"Search by filenameYY
find . -name "*.log" -mtime -7Files modified in last 7 daysYY
file <filename>Identify file typeYY
stat <filename>Detailed file metadataYDoutput format differs
tree -L 2Directory tree, 2 levels deepYYinstall via brew install tree
tail -f /var/log/syslogFollow system log liveYNlog stream
cat, less, head, tailView file contentsYY
chmod, chownChange permissions / ownershipYY
rsync -avz <src> <dst>Sync files (local or remote)YY

Pi Configuration

CommandWhat it does
sudo raspi-configInteractive config tool (interfaces, boot, display, etc.)
cat /boot/firmware/config.txtBoot and hardware config
cat /boot/firmware/cmdline.txtKernel boot parameters
sudo rpi-updateUpdate firmware — use with caution, can break things
sudo rebootReboot (works everywhere)
sudo shutdown -h nowShutdown immediately (works everywhere)

Stress Testing with stress-ng

Not a built-in command, but worth installing. Good for testing if a new board can handle sustained load without throttling or crashing. sudo apt install stress-ng on Debian/Pi OS, brew install stress-ng on macOS.

CommandWhat it does
stress-ng --cpu 4 --timeout 60sHammer all 4 CPU cores for 60 seconds
stress-ng --cpu 4 --cpu-method matrixprod --timeout 5mHeavier CPU load using matrix multiplication
stress-ng --vm 2 --vm-bytes 512M --timeout 60sStress test memory (2 workers, 512MB each)
stress-ng --hdd 1 --timeout 60sStress test disk I/O
stress-ng --cpu 4 --vm 2 --vm-bytes 256M --hdd 1 --timeout 5mHit CPU, memory, and disk all at once

Run vcgencmd measure_temp and vcgencmd get_throttled in another terminal while this runs to see how the board handles it. If the fan doesn’t spin up during a full CPU stress test, something is wrong.


Quick Diagnostics

Paste these one-liners to get a quick health check.

Pi / Linux

echo "--- OS ---" && cat /etc/os-release | grep PRETTY && \
echo "--- Kernel ---" && uname -r && \
echo "--- Temp ---" && vcgencmd measure_temp && \
echo "--- Throttle ---" && vcgencmd get_throttled && \
echo "--- CPU MHz ---" && echo "$(($(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)/1000)) MHz" && \
echo "--- RAM ---" && free -h | grep Mem && \
echo "--- Disk ---" && df -h / | tail -1 && \
echo "--- Uptime ---" && uptime -p

macOS

echo "--- OS ---" && sw_vers && \
echo "--- Kernel ---" && uname -r && \
echo "--- CPU ---" && sysctl -n machdep.cpu.brand_string && \
echo "--- RAM ---" && top -l 1 | head -n 10 | grep PhysMem && \
echo "--- Disk ---" && df -h / | tail -1 && \
echo "--- Uptime ---" && uptime