Check These Out
This gets you your default route programatically, useful for scripts
this string of commands will release your dhcp address, change your mac address, generate a new random hostname and then get a new dhcp lease.
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
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22)
(all files & folders on destination server/folder will be deleted)
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22)
(all files & folders on destination server/folder will be deleted)
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"
}
Opening several files at once in Vim can be very easy in connection with find command.
Sprunge.us is a code/text sharing site like pastebin, but it is easy to post stuff from the command line.
$
How it works:
$ :w !command
In vim, w writes the current tab to a file when a filename is given afterwards, but if !command is given, the output is piped to the stdin of command.
$curl -F "sprunge=
I use this command to save RTSP video streams over night from one of our national TV stations, so I won't have to squeeze the data through my slow internet connection when I want to watch it the next day.
For ease of use, you might want to put this in a file:
#!/bin/bash
FILE="`basename \"$1\"`"
mplayer -dumpstream -dumpfile "$FILE" -playlist "$1"