Home / General
nobody:nogroup/etc/debian_versionnobody:nobody/etc/redhat-release or /etc/centos-releaseurandom 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. /etc/environment works, though. See systemd#7641.sort
LC_ALL=C to use byte-value sorting instead of locale-enabled sorting (which can be a bit unpredictable).sudo -lhwloc):
lstopolstopo will try to output in GUI mode if supported. Use lstopo-no-graphics to force non-graphical output.-vlsusblsusb -vlspcilspci -kfile <executable>
ldd <executable>
LD_TRACE_LOADED_OBJECTS=1 set to instruct glibc (TODO the loader/interpreter?) to print dependencies and exit (this is normally how ldd works internally).strings -a <executable>ltrace <executable> [args]strace <executable> [args]strip <executable>
gensymtab.nm <file>
strip).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 iozone3iozone -aiozone -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 / -nouserfind / -perm /4000find <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>rsync:
rsync [opts] <src> <dst>-v: Verbose.-s: Protect args. Prevents remote hosts from interpreting paths, which might cause trouble e.g. if the path contains spaces.-h: Show numbers as human-readable.--progress: Show fancy progress bar.-a: Archive, equal to -rlptgoD (recursive, preserve symlinks/owner/group/permissions/modification-time etc.).-z: Compress. Use for network transfers, not locally.--include <pattern>: Only copy files/dirs matching the provided pattern. Supports * globbing, if quoted properly.--exclude <pattern>: Exclude files matching the pattern. THe matching works similarly to --include, but files matching the --exclude pattern overrides any files matched with the --include pattern (if any).--delete: Delete any files in the destination that are not present in the source.--info=progress2: Show single progress bar (not one per file as for --progress).<user>@<addr>:<path> to copy over SSH (default transport protocol).rsync [...] <src>/ <dst>) results in copying the source dir to the destination dir (i.e. copying the source dir contents into the destination dir). Omitting it will copy the whole source dir into the destination dir. (TODO: This is how it’s supposed to work, but for some reason it always copies the contents into the destination dir for me.)rsync -azs --delete --progress . "hon@minisummit:Projects/yolo"lolcatcowsayfortunehtop:
top, but prettier and more interactive.apt install htophtop (interactive)glances:
pip3 install glancesglances (interactive)dstat:
dstat <options> [interval] [count]
--bits: Force usage of bits (e.g. to show network traffic as b/s instead of B/s).-f: Show stats for all devices (not aggregated).-C <>: Comma-separated list of CPUs/cores to show for, including total.-D <>: Same but for disks.-N <>: Same but for NICs.-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 -tcmyrd 5dstat -tcyn --net-packets --bits 5dstat -tcmygp --socket 5lshw
-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.lspcilsblklsusblscpuapt updateapt install <package>apt upgradeapt full-upgradeapt list -a <package>apt depends <package>apt rdepends [--installed] <package>apt-mark hold <package>apt-key add <key-file>.add-apt-repository <repo-line>/etc/apt/sources.list, where you can manually remove it again./usr/share/keyrings/<name>.gpg./etc/apt/sources.list.d/<name>.list, add the repo line and add [signed-by=/usr/share/keyrings/<name>.gpg] after deb (in the existing square brackets if one exists already).apt updateapt-key list
apt-key add <key-file>/etc/apt/trusted.gpg.d/<name>.gpg (or .asc).apt-key del <key-id>
pub line or as the last 8 hex digits on the continuation line.apt-cache policy <package>/etc/apt/preferences and /etc/apt/preferences.d/<name>./var/log/dpkg.log.apt install -f doesn’t fix it):
apt install -f afterwards, to make sure the problem is resolved and make sure APT isn’t left in an errored state.dpkg -r --force-depends <package>apt clean (or apt autoclean)pacman -Syupacman -Ss <package-name>pacman -Si <package>pacman -S <packages>
-Sy to avoid partial upgrades.pacman -R <packages>
-s-npacman -R $(pacman -Qdtq)nload <if>iftop -i <if>speedometer -t <if> -r <if> [...]dstat -tcyn --net-packets 60nethogspeedtest (from speedtest.net)iperf3ss):
ss -tulpnss 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.nstatnetstat -sip 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 neighborip routeip route get <dst>ip maddressip mroutetcpdump -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)snmpwalk -v2c -c<community> <host> [oid]snmpwalk -v3 -l authpriv -u <user> -a SHA -A <auth-pass> -x AES -X <priv-pass> <host> [oid]snmpwalk -v2c -c<community>@<vid> <host> BRIDGE-MIB::dot1dTpFdbTable (defaults: VLAN 1)snmpwalk -v3 <auth-args> -nvlan-<vid> <host> BRIDGE-MIB::dot1dTpFdbTable (defaults: VLAN 1)numastat (from package numactl)echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governorecho powersave | ...grep "cpu MHz" /proc/cpuinfo | cut -d' ' -f3time (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): xkcdpasssha{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-releaseuname -alsb_release -auptimeiostat [-c] [-t] [interval]ps (e.g. ps aux or ps ax o uid,user:12,pid,comm)irqtopwatch -n0.1 /proc/interruptsyay -S usbtopmodprobe usbmonsudo usbtopnice -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-ngapt install stressstress(-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/procmount -t sysfs sys /mnt/sysmount -t bind /dev /mnt/devchroot /mnt [/bin/bash]
/bin/bash, may be necessary.exitwoeusb from ppa:nilarimogard/webupd8.