Check These Out
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token.
This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use:
`awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'`
You must adapt the command line to include:
* $MFA_IDis ARN of the virtual MFA or serial number of the physical one
* TTL for the credentials
Run "ps -x" (process status) in the background every hour (in this example).
The outputs of both "nohup" and "ps -x" are sent to the e-mail (instead of nohup.out and stdout and stderr).
If you like it, replace "ps -x" by the command of your choice, replace 3600 (1 hour) by the period of your choice.
You can run the command in the loop any time by killing the sleep process. For example
$ ps -x
2925 ? S 0:00.00 sh -c unzip E.zip >/dev/null 2>&1
11288 ? O 0:00.00 unzip E.zip
25428 ? I 0:00.00 sleep 3600
14346 pts/42- I 0:00.01 bash -c while true; do ps -x | mail (...); sleep 3600; done
643 pts/66 Ss 0:00.03 -bash
14124 pts/66 O+ 0:00.00 ps -x
$ kill 25428
You have mail in /mail/(...)
Shows a simple clock in the console
-t param removes the watch header
Ctrl-c to exit
Summarize established connections after netstat output.
Using tee and /dev/stderr you can send one command output to terminal before executing wc so you can summarize at the bottom of the output.
this bzips a folder and transfers it over the network to "host" at 777k bit/s.
cstream can do a lot more, have a look http://www.cons.org/cracauer/cstream.html#usage
for example:
$ echo w00t, i'm 733+ | cstream -b1 -t2
hehe :)
eh stands for Edit History
.
Frequently, I'll mistype a command, and then step back through my history and correct the command. As a result, both the correct and incorrect commands are in my history file. I wanted a simple way to remove the incorrect command so I don't run it by mistake.
.
When running this function, first the ~/bash_history file is updated, then you edit the file in vi, and then the saved history file is loaded back into memory for current usage.
.
while in vi, remember that `Shift-G` sends you to the bottom of the file, and `dd` removes a line.
.
this command is different than bash built-in `fc` because it does not run the command after editing.
Generate a truly random password using noise from your microphone to seed the RNG. This will spit out 12 password with 12 characters each, but you can save this into a bash script and replace 'pwgen -ys 12 12' with 'pwgen $@' so you can pass any paramters to pwgen as you would normally do.
An other way to run it ( playing a random file ending with avi, flv or mpeg ) from a specified dir and a specified type of extension :
making MOVIE array with a glob :
$ MOVIE=( /PATH/TO/MY/FAVORITE/MOVIES/*.{avi,flv,mpeg} )
playing the random file from a random key from the array
$ mplayer ${MOVIE[ RANDOM % ( ${#i[@]} + 1 ) ]]}
I use only globs and a bash array.
I use GNU bash, version 3.2.48