One of my favorite is the following bash command:
exec 1> >(logger -s -t $(basename $0)) 2>&1
which added at the top of your bash causes all stdout and stderr to be direct to syslog while instructing the logger to include the name of the script (via $(basename $0)) making debugging easier. What's your favorite?
One of the first spots of this command is to be found at twitter.com/lindvall/status/509054237267853312 by https://twitter.com/lindvall
cmatrix
Its a fun command which transforms your terminal into matrix style terminal.
Need to get package first using:
apt-get install cmatrix
P.S. Only useful for showing off in front of your friends with no other significant use
On a serious note I think it might be
ssh username@host
Mainly because it gives us access to endless network of servers
Here's one that's amazing, more for its history than anything else:
tr -cs A-Za-z '\n' |
tr A-Z a-z |
sort |
uniq -c |
sort -rn |
sed ${1}q
(source and details: leancrew.com/all-this/2011/12/more-shell-less-egg)
This is Doug McIlroy's six-command response to Donald Knuth's "10 pages of pascal" solution to the challenge: Read a file of text, determine the n most frequently used words, and print out a sorted list of those words along with their frequencies.
It was a cheeky response because Knuth was actually demonstrating 'literate programming', which was intentionally verbose; and even McIlroy admitted Knuth's solution was more refined/powerful/extensible. But it was a great way to show the power of unix pipelines.
Which goes back to my original thought for this thread - it's not the individual commands that are amazing, it's how those simple pieces combine that breaks your head ;)
I don't know that it's "amazing" but type commandname is really useful; reveals a lot of information and works in cases where which and declare would fail.
Simple example:
$ which ls
/bin/ls
$ declare -f ls
$ type ls
ls is aliased to `ls -la'
which gives an accurate result but does not tell you there is an alias; declare wouldn't tell you anything; but type alerts you to the alias.
Makes it useful for beginners to learn; but also remains useful to more experienced devs. eg. in scripts trying to determine what's available on a server or workstation (I once needed to detect NVM and didn't realise it was a function, so which didn't help; but type did).
rm -rf
Such ease of use; such amazing power.
(Disclaimer: don't actually run that)
Nikos Roussos
Web Tech Lead @ Greenpeace
python3 -m http.server