Check These Out
Launch a command from within a manpage, vim style. This is rather trivial, but can be very useful to try out the functions described in a manpage without actually quitting it (or switching to another console/screen/...).
Recursively rename .JPG to .jpg using standard find and mv. It's generally better to use a standard tool if doing so is not much more difficult.
transfer files from localhost to a remotehost.
Converts any number of seconds into days, hours, minutes and seconds.
sec2dhms() {
declare -i SS="$1"
D=$(( SS / 86400 ))
H=$(( SS % 86400 / 3600 ))
M=$(( SS % 3600 / 60 ))
S=$(( SS % 60 ))
[ "$D" -gt 0 ] && echo -n "${D}:"
[ "$H" -gt 0 ] && printf "%02g:" "$H"
printf "%02g:%02g\n" "$M" "$S"
}
Another step to bring cli and gui closer together: gnome-open
It opens a path with the default (gui) application for its mime type.
I would recommend a shorter alias like alias o=gnome-open
More examples:
$ gnome-open .
[opens the current folder in nautilus / your default file browser]
$ gnome-open some.pdf
[opens some.pdf in evince / your default pdf viewer]
$ gnome-open trash://
[opens the trash with nautilus]
$ gnome-open http://www.commandlinefu.com
[opens commandlinefu in your default webbrowser]
It will return a ranked list of your most commonly-entered commands using your command history
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
This command is very helpful when we need to duplicate a test scenario and first we want to find out the installed libraries together with the version and release numbers and architecture. (look example)
Command can be tuned by choosing just the names of libraries we are interested in. For example glibc and gcc.
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
Reads 4 bytes from the random device and formats them as unsigned integer between 0 and 2^32-1.