title: Linux General breadcrumbs:
nobody:nogroup
/etc/debian_version
nobody:nobody
/etc/redhat-release
or /etc/centos-release
urandom
VS random
: random
blocks when running out of entropy while urandom
does not. For all practical purposes, urandom
will almost never be less random than random
and random
may block at inappropriate times, so always use urandom
.*/environment.d/*.conf
aren't visible for login sessions when using systemd. */environment.conf
works, though. See systemd#7641.sudo -l
file <executable>
ldd <executable>
LD_TRACE_LOADED_OBJECTS=1
set instruct glibc to print dependencies and exit. This is basically how ldd
works internally, but with more options.strings -a <executable>
ltrace <executable> [args]
strace <executable> [args]
strip <executable>
gensymtab
.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)shred
:
shred -n2 -v <file>
-n<n>
speficied the number of passes. This takes ages to begin with for large disks, so keep it as low as appropriate. 1 pass is generally enough, 2 to be sure.--zero
adds an extra, final pass to write all zeroes.-v
shows progress.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 -v <file>
lolcat
cowsay
fortune
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
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.pacman -Syu
pacman -Ss <package-name>
pacman -Si <package>
pacman -S <packages>
-Sy
to avoid partial upgrades.pacman -R <packages>
-s
-n
nload <if>
iftop -i <if>
speedometer -t <if> -r <if> [...]
dstat -tcyn --net-packets 60
nethog
speedtest
(from speedtest.net)iperf3
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.ip a
instead of ip address
)address
and link
, it will default to show all elements if no further option is specified.ip -c a
).-c
: Show colored output.-4
or -6
: Show IPv4 or IPv6 addresses only.-s
: Show stats (bytes, packets, errors, dropped, etc. for RX and TX).-br
: Show brief with one line per interface (MAC address and status for link
, addresses for address
).-o
: Show one line per interface (but all info unlike -br
).-j [-p]
: Print as JSON. Add -p
for pretty printing.ip link [show [<interface>]]
ip address [show [<interface> [scope <scope>]]]
scope global
: Only show global addresses (excludes localhost/host
, link-local/link
, etc.).ip neighbor
ip route
ip maddress
ip mroute
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/*
xkcdpass
): xkcdpass
sha{256,512} <files>
Using GPG (from package gnupg2
on Debian).
gpg --no-default-keyring --keyring ./tmp.keyring --import <pubkey>
(example)-no-default-keyring --keyring ./tmp.keyring
in the commands where you need it.~
-suffixed backup of it when you no longer need it.gpg --show-keys <keyfile>
gpg --import <pubkey>
gpg [--keyserver <url>] --recv-keys <key-id>
.asc
), the publisher's signing pubkey file, and temporary keyring (complete example):
gpg --no-default-keyring --keyring ./tmp.keyring --import <keyfile>
gpg --no-default-keyring --keyring ./tmp.keyring --verify <sig-file> <data-file>
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
nice -n<n> <cmd>
(-20 <= n <= 19
)renice
to change the value.ionice
to set the I/O scheduler and scheduler-specific priority.apt install stress-ng
stress-ng -c $(nproc) -t $((10*60))
(use all CPU threads for 10 minutes)mount /dev/sda2 /mnt
(example)mount /dev/sda1 /mnt/boot/efi
(example)mount -t proc proc /mnt/proc
mount -t sysfs sys /mnt/sys
mount -t bind /dev /mnt/dev
chroot /mnt [/bin/bash]
/bin/bash
, may be necessary.exit
woeusb
from ppa:nilarimogard/webupd8
.{% include footer.md %}