Last active
July 18, 2017 14:38
-
-
Save beli-sk/c2be754927056644dd6e to your computer and use it in GitHub Desktop.
Useful CLI one-liners (Linux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Number of open file descriptors per process (replace 'httpd' with process name) | |
lsof -p $( echo `ps -o pid= -C httpd` | tr ' ' ',' ) | awk '{ print $2 }' | uniq -c | |
# Show swap usage per process, >=1000 kB | |
cat /proc/*/status | egrep -B30 '^VmSwap:[[:space:]]+[[:digit:]]{4,}' | egrep '^Name|^Pid|^VmSwap' | |
# generate password | |
head -c12 /dev/urandom | base64 | tr '+/' '_-' | tr -d '=' | |
# days to web server certificate expiry | |
echo $(( ( $( date -d "`openssl s_client -servername example.com -connect example.com:443 < /dev/null 2> /dev/null | openssl x509 -noout -enddate | grep notAfter | cut -d= -f2`" '+%s') - `date '+%s'` ) / 60 / 60 / 24 )) | |
# list virtio block devices with PCI IDs (not exactly one-liner, but useful anyway) | |
for dev in /sys/bus/virtio/drivers/virtio_blk/virtio* ; do | |
echo $( readlink "$dev" | sed -r 's#.*/(pci.*)#\1#' ) $( ls "${dev}/block" ) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment