title: Linux Examples breadcrumbs:
htop
:
top
, but prettier and more interactive.apt install htop
htop
(interactive)glances
:
pip3 install glances
glances
(interactive)dstat
:
dstat <options> [interval] [count]
-C <>
: Comma-separated list of CPUs/cores to show for, including total
.-D <>
: Same but for disks.-N <>
: Same but for NICs.-f
: Show stats for all devices (not aggregated).-t
: Current time.-p
: Process stats (by runnable, uninterruptible, new) (changes per second).-y
: Total interrupt and context switching stats (by interrupts, context switches) (events per second).-l
: Load average stats (1 min, 5 mins, 15 mins) (total system load multiplied by number of cores).-c
: CPU stats (by system, user, idle, wait) (percentage of total).--cpu-use
: Per-CPU usage (by CPU) (percentage).-m
: Memory stats (by used, buffers, cache, free) (bytes).-g
: Paging stats (by in, out) (count per second).-s
: Swap stats (by used, free) (total).-r
: Storage request stats (by read, write) (requests per second).-d
: Storage throughput stats (by read, write) (bytes per second).-n
: Network throughput stats (by recv, send) (bytes per second).--socket
: Network socket stats (by total, tcp, udp, raw, ip-fragments)--net-packets
: Network request stats (by recv, send) (packets per second).dstat -tcmyrdn --net-packets 60
dstat -tcyn --net-packets 60
dstat -tcmygp --socket 60
gdisk <dev>
or fdisk <dev>
mkfs.<fs> <dev>
mount -a
to make sure it doesn't have errors that may cause boot to fail.systemctl daemon-reload
to avoid having systemd remount stuff that was removed from fstab or other weird shit.apt install iozone3
iozone -a
iozone -t1
(1 thread)find / -user <UID>
find / -nouser
find / -perm /4000
find <dir> \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i 's/123/456/g'
-type d -name .git -prune
skips .git
directories and can be excluded outside of git repos.du -sh <dirs>
k4dirstat
)shred --remove --zero <file>
lolcat
cowsay
fortune
lshw
-X
to show GUI (requires lshw-gtk
).lstopo
(requires hwloc)
lstopo
will try to present as a GUI. Use lstopo-no-graphics
to force console output.lspci
lsblk
lsusb
lscpu
apt rdepends --installed <package>
add-apt-repository <repo-line
/etc/apt/sources.list
, where you can manually remove it again.apt-key list
apt-key del <key-id>
pub
line or as the last 8 hex digits on the continuation line.nload <if>
iftop -i <if>
speedometer -t <if> -r <if> [...]
dstat -tcyn --net-packets 60
nethog
speedtest
(from speedtest.net)iperf3
ip
):
ip [-c] [-46] [-s] {l[ink]|a[ddress]} [-br] [sh [if]]
-c
: Color.{-4|-6}
: IPv4 or IPv6 only.-s
: Show stats (bytes, packets, errors, dropped, etc. for RX and TX).-br
: One line per interface (MAC address and status for link
, addresses for address
).scope global
: Only global addresses (excludes localhost/host
, link-local/link
, etc.).ip
):
ip [-c] [-46] n[eighbor]
-c
: Color.{-4|-6}
: IPv4 or IPv6 only.ip
):
ip [-c] [-46] r[oute]
-c
: Color.{-4|-6}
: IPv4 or IPv6 only.ip
):
ip [-c] [-46] ma[ddress]
-c
: Color.{-4|-6}
: IPv4 or IPv6 only.ip
):
ip [-c] [-46] mr[oute]
-c
: Color.{-4|-6}
: IPv4 or IPv6 only.ss
):
ss -tulpn
ss
replaces netstat
and is mostly option compatible.tu
: Include TCP and UDP sockets (no UNIX sockets).l
: Include listening sockets (no client sockets).p
: Show protocol (requires root).n
: Don't translate port numbers to common service names.nstat
netstat -s
ip link set dev <if> {up|down}
tc
to simulate e.g. random packet drop, random latencies, limited bandwidth etc.tcpdump -i <interface> -nn -v [filter]
-w <>.pcap
: Write to capture file instead of formatted to STDOUT.-i <if>
: Interface to listen on. Defaults to a random-ish interface.-nn
: Don't resolve hostnames or ports.-s<n>
: How much of the packets to capture. Use 0 for unlimited (full packet).-v
/-vv
: Details to show about packets. More V's for more details.-l
: Line buffered more, for better stability when piping to e.g. grep.not
/!
, and
/&&
and or
/||
. Make sure to quote the filter to avoid interference from the shell.ip
, ip6
, icmp
, icmp6
, tcp
, udp
, ``port <n>
host <addr>
, dst <addr>
, src <addr>
icmp6 and (ip6[40] = 133 or ip6[40] = 134)
(133 for RS and 134 for RA)icmp6 and (ip6[40] = 135 or ip6[40] = 136)
(135 for NS and 136 for NA)ip and udp and (port 67 and port 68)
ip6 and udp and (port 547 and port 546)
numastat
(from package numactl
)echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
echo powersave | ...
grep "cpu MHz" /proc/cpuinfo | cut -d' ' -f3
time
(timing commands):
time
and as /usr/bin/time
, use the latter./usr/bin/time -p <command>
-p
for POSIX output (one line per time)-v
for interesting system info about the process.strace
(trace system calls and signals):
strace [options] <command>
-c
: Show summary/overview only. (Hints at which syscalls are worth looking more into.)-f
: Trace forked child processes too.-e trace=<syscalls>
: Only trace the specified comma-separated list of syscalls.tail -n +1 /sys/devices/system/cpu/vulnerabilities/*
hdparm -t <dev>
(safe)iostat [-dxpm] [-t] [interval]
-d
: Show only device usage.-x
and -p
: Include extended attributes and partitions.-t
and interval: Show timestamp and repeat every x seconds.iotop -o [-a]
/etc/debian_version
/etc/redhat-release
/etc/centos-release
uname -a
lsb_release -a
uptime
iostat [-c] [-t] [interval]
ps
(e.g. ps aux
or ps ax o uid,user:12,pid,comm
)irqtop
watch -n0.1 /proc/interrupts
apt install stress-ng
stress-ng -c $(nproc) -t 600
woeusb
from ppa:nilarimogard/webupd8
.{% include footer.md %}