# commandlinefu.com - questions/comments: danstools00@gmail.com # Advanced python tracing strace python -m trace --trace myprog.py | grep -v 'write(1,' # nice column format for openvpn servers log file column -ts , /etc/openvpn/openvpn-status.log # Show running services (using systemctl) command systemctl --no-page --no-legend --plain -t service --state=running # Show running services (using systemctl) systemctl --no-page -t service -a --state running --no-legend # Listen Digitally Imported Radio from CLI (without premium!) mplayer http://pub7.di.fm/di_ambient_aac?1 -user-agent "AudioAddict-di/3.2.0.3240 Android/5.1" # Copy a file using dd and watch its progress dd if=foo of=bar status=progress # Human readable docker stats output docker stats --no-stream $( docker ps -q ) | sed -e "$( docker ps --format "{{.ID}} {{.Names}}" | sed -e "s/\(.*\) \(.*\)/s\/\1\/\2\t\/g;/" )" # Lookup autonomous systems of all outgoing http/s traffic ss -t -o state established '( dport = :443 || dport = :80 )' | grep -Po '([0-9a-z:.]*)(?=:http[s])' | sort -u|netcat whois.cymru.com 43|grep -v "AS Name"|sort -t'|' -k3 # Get just LAN IP without all the extra stuff ip addr show | grep "inet " | while read INET IP TRASH; do if [ $IP != "127.0.0.1/8" ]; then echo $IP; exit 0; fi; done | sed s:/[1-9][1-9]:"": # Lookup autonomous systems of all outgoing http/s traffic ss -t -o state established '( dport = :443 || dport = :80 )'|grep tcp|awk '{ print $5 }'|sed s/:http[s]*//g|sort -u|netcat whois.cymru.com 43|grep -v "AS Name"|sort -t'|' -k3 # Read curl output line by line in a while loop while read line; do echo $line;done < <(curl -s ) # Test remote SSH server status using telnet (no login required) $if [[ "$(sleep 1 | telnet -c 2>&1 | grep '^SSH')" == SSH* ]]; then ; else ; fi; # Git reset added new files git status --porcelain -z | grep -zZ '^A[ MD] ' | sed -z 's/^...//' | xargs -0 --no-run-if-empty git reset HEAD -- # Put the command in background running state nohup # status and statistical information about the battery upower -i /org/freedesktop/UPower/devices/battery_BAT0 # Get currently logged in console user's shortname stat -f '%Su' /dev/console # Get current position of the International Space Station in pulses of 1 second while true; do pos=$(curl -s "http://api.open-notify.org/iss-now.json"); echo "lat=$(echo $pos | jq ".iss_position.latitude"), lon=$(echo $pos | jq ".iss_position.longitude")"; sleep 1; done # Powershell Ping Logs Host Up/Down Events sajb {$ip="192.168.100.1";$old=0;while(1){$up=test-connection -quiet -count 1 $ip;if($up-ne$old){$s=(date -u %s).split('.')[0]+' '+(date -f s).replace('T',' ')+' '+$ip+' '+$(if($up){'Up'}else{'Down'});echo $s|out-file -a $home\ping.txt;$old=$up}sleep 10}} # Git reset added new files for f in `git status | grep new | awk '{print $3}'`; do git reset HEAD $f ; done # Abbreviated docker ps as an alias alias dps='docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"' # check the status of 'dd' in progress (OS X) while pgrep ^dd; do sudo pkill -INFO dd; sleep 20; done # easily strace all your apache *child* processes strace -c $(ps -u www-data o pid= | sed 's/^/-p/') # display swap space used by a process awk '/VmSwap/{print $2 " " $3}' /proc/$PID/status # Sort your files perl -MPOSIX=strftime -MFile::Path -e 'for(glob"*"){mkpath$d=strftime"%Y-%m-%d", localtime((stat)[9]);rename$_,"$d/$_"}' # Force laptop "idle" mode action when laptop lid is closed echo 'LidSwitchIgnoreInhibited=no' > /etc/systemd/logind.conf.d/respect-inhibit-lid.conf