Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Useful Linux Commands

Top consuming processes

Show the process’ command line

cat /proc/_pid_/cmdline|xargs -0

Reload DNS resolver

sudo killall -USR2 systemd-resolved

List directories only

Not elegant but works:

ls -lad */|awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}'|sed 's/^ *//'

better but results in a leading whitespace:

ls -lad */|awk '{out = ""; for (i = 9; i <= NF; i++) {out = out " " $i}; print out}'

best:

ls -ld */|cut -c 53-

more options

URL-decode

echo -n "%21%20" | python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.stdin.read()));"

Scripting