Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Useful Linux Commands

Show top 10 CPU consuming processes

ps -eo pcpu,pid,user,args|sort -k 1 -nr|head -10

Show 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

Scripting