Check These Out
I find this terribly useful for grepping through a file, looking for just a block of text. There's "grep -A # pattern file.txt" to see a specific number of lines following your pattern, but what if you want to see the whole block? Say, the output of "dmidecode" (as root):
$ dmidecode | awk '/Battery/,/^$/'
Will show me everything following the battery block up to the next block of text. Again, I find this extremely useful when I want to see whole blocks of text based on a pattern, and I don't care to see the rest of the data in output. This could be used against the '/etc/securetty/user' file on Unix to find the block of a specific user. It could be used against VirtualHosts or Directories on Apache to find specific definitions. The scenarios go on for any text formatted in a block fashion. Very handy.
We force IPv4, compress the stream, specify the cypher stream to be Blowfish. I suppose you could use aes256-ctr as well for cypher spec. I'm of course leaving out things like master control sessions and such as that may not be available on your shell although that would speed things up as well.
A key sequence for terminating a frozen session. Full sequence on a swedish keyboard: [ENTER] [ALTGR] tilde [SPACE] dot
Show sizes of all files and directories in a directory in size order.
$du -hs * | sort -hr
for reverse order.
Taken from http://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size
Using the redundant ./ directory information prevents the dash from occurring at the beginning of the filename, and being interpreted as an option of the rm command.
Also works using:
$ rm -- -filename
pings a server once per second, and beeps when the server is unreachable.
Basically the opposite of:
$ ping -a server-or-ip.com
which would beep when a server IS reachable.
You could also substitute beep with any command, which makes this a powerful alternative to ping -a:
$ while true; do [ "$(ping -c1W1w1 server-or-ip.com 2>/dev/null | awk '/received/ {print $4}')" = 1 ] && date || echo 'server is down!'; sleep 1; done
which would output the date and time every sec until the ping failed, in which case it would echo.
Notes:
Requires beep package.
May need to run as root (beep uses the system speaker)
Tested on Ubuntu which doesn't have beep out of the box...
$ sudo apt-get install beep
The "-d" option for gnu's "date" command can calculate positive or negative offset from any time, including "now". You can even specify a source timezone (the output timezone can be set with the TZ environment variable). Useful! Fun! Not very well documented!