Check These Out
It's somewhat common ISPs to intercept DNS queries at port 53 and resolve them at their own.
To check if your ISP is intercepting your DNS queries just type this command in the terminal.
"#.abc" it's an OK answer.
But if you get something like "I am not an OpenDNS resolver.", yep, you are beign cheated by your ISP.
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"
}
One of my favorite ways to impress newbies (and old hats) to the power of the shell, is to give them an incredibly colorful and amazing version of the top command that runs once upon login, just like running fortune on login. It's pretty sweet believe me, just add this one-liner to your ~/.bash_profile -- and of course you can set the height to be anything, from 1 line to 1000!
$ G=$(stty -g);stty rows $((${LINES:-50}/2));top -n1; stty $G;unset G
Doesn't take more than the below toprc file I've added below, and you get all 4 top windows showing output at the same time.. each with a different color scheme, and each showing different info. Each window would normally take up 1/4th of your screen when run like that - TOP is designed as a full screen program. But here's where you might learn something new today on this great site.. By using the stty command to change the terminals internal understanding of the size of your terminal window, you force top to also think that way as well.
# save the correct settings to G var.
$ G=$(stty -g)
# change the number of rows to half the actual amount, or 50 otherwise
$ stty rows $((${LINES:-50}/2))
# run top non-interactively for 1 second, the output stays on the screen (half at least)
$ top -n1
# reset the terminal back to the correct values, and clean up after yourself
$ stty $G;unset G
This trick from my [ http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html bash_profile ], though the online version will be updated soon. Just think what else you could run like this!
Note 1: I had to edit the toprc file out due to this site can't handle that (uploads/including code). So you can grab it from [ http://www.askapache.com/linux-unix/bash-power-prompt.html my site ]
Note 2: I had to come back and edit again because the links weren't being correctly parsed
Shorter regex.
I often use it to find recently added ou removed device, or using find in /dev, or anything similar.
Just run the command, plug the device, and wait to see him and only him
Sometimes it is handy to be able to list contents of a tar file within a compressed archive, such as 7Zip in this instance, without having to extract the archive first. This is especially helpful when dealing with larger sized files.