Linux and BSD Cheat Sheet

Moving from Linux (Debian) to BSD (NetBSD) meant relearning a lot of commands. While the most basic of commands work, a lot of management tools for block devices, networking and the like are different enough that they require some “translating”. FreeBSD has a good Quickstart guide on this, but NetBSD/OpenBSD seem not to, so I’ve begun compiling my own quick lookup for BSD and Linux equivalent commands.

This list is by no means exhaustive, but these commands cover about 95% of the common use cases. I do not have much experience with FreeBSD  or OpenBSD, but OpenBSD and NetBSD might be similar enough that the NetBSD commands apply.

See a wrong command? Did I miss a useful tidbit? Contact me or post a comment below, and I’d much appreciate it! Printable version here.

Linux

NetBSD (OpenBSD?)

FreeBSD

Notes

smartctl -a /dev/sda

atactl /dev/wd0 smart status

?

Get HDD SMART info

ifconfig

netstat -b -I ale0

?

To show RX/TX info on the interface

NetBSD: Only shows in bytes, AFAIK

yum install <pkg> / apt-get install <pkg>

pkgin install <pkg>

pkg install <pkg>

Install binary package

rpm -qa / dpkg -l

pkg_info -a

pkg info

List all installed packages

yum update / apt-get update

pkgin update

?

Update package list

yum upgrade / apt-get upgrade

pkgin upgrade / pkgin full-upgrade

pkg upgrade

Upgrade system packages

On BSD: this will not upgrade the ‘base’ system. Linux does not have this concept, so the system is effectively upgraded in one shot.

lspci

pcictl /dev/pci1 list

pciconf

On NetBSD: To list all devices (if the PC has many PCI lines):
for BUS in /dev/pci*; do pcictl $BUS list; done

lsusb

usbdevs

?

 List USB devices

acpi -i

envstat

?

Get battery info / power state

modprobe

modload

kldload

Load kernel module

modprobe -r

modunload

kldunload

Unload kernel module

lsmod

modstat

kldstat

List kernel modules

strace

ktrace / ktruss

truss

Kernel trace logging

sensors

envstat

?

List monitored temps + other sensors’ information

vmstat / free

vmstat / free

vmstat

List memory + swap information

On NetBSD: `free` is not included in the base install, but is installable via pkgin. Recommended if familiar to Linux.

lsblk / fdisk -l

sysctl hw.disknames

?

List block devices attached

On NetBSD: fdisk -l shows valid FS ID numbers, and does not list devices (as it does in Linux)

ifconfig eth0 hw ether 00:11:22:33:44:55

ifconfig ale0 link 00:11:22:33:44:55

?

Change or clone MAC/Ethernet hardware address

ethtool -s eth0 speed 1000 duplex full

ifconfig ale0 media 1000baseTX

ifconfig em0 media 1000baseTX

Change network interface duplex / speed / type. Replace `1000baseTX` with correct speed/duplex, where appropriate.

Leave a Reply

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