Bash - Cheatsheet
How To Find My Public IP Address From Linux CLI
Introduction How do I find out my public IP address on the Linux and OS X Unix command line to u...
While loops
Run for period of time #!/bin/bash runtime="5 minute" endtime=$(date -ud "$runtime" +%s) ...
For loops
Compute md5sum for every item in a directory for i in "$(ls)"; do md5sum "${i}"; done | sort Pr...
SSH
Encrypt Key openssl rsa -des3 -in key.pem -out encrypted-key.pem # Enter a passphrase mv encry...
Create sudo user non-interactively
Skip the prompts that come with creating a user typically, and give them sudoers privileges. Repl...
Run function as another user
export -f <function_name> su <user to run function as> -c "bash -c <function_name>"
Run command as another user
USER=centos runuser -l $USER -c 'whoami' Resource: https://devops.stackexchange.com/questions/1...