Dec 292014
 

The command line is a vast ocean that stretches endlessly, far beyond the imagination of even the smartest guys.

A lot of systems administrators use indispensable command line tools like scp, ls, netstat, rsync etc on a daily basis as part of their work.

But the command line can also do some cute, unusual things that you wouldn’t have thought possible.

Here are 12 cute command line tricks that’ll keep you amused. Hey, some are even useful.

1. Create a 30 character alphanumeric password with upper and lower case letters:

$ strings /dev/urandom | tr -cd '[:alnum:]' | fold -w 30 | head -n 1
15WbweWRx2gUoZlsSpNybtpWSpHq4A

By varying the number next to ‘w,’ you can create longer or shorter passwords.

2. Ha ha ha. Now for a weird command that spits out quotes from the hilarious movie Borat. If you’ve seen Borat, you know that some of the jokes in the movie can be extremely crude and vulgar. šŸ˜‰

$ curl -s "http://smacie.com/randomizer/borat.txt" | shuf -n 1 
Kazakhstan is more civilised now. Women can now travel on inside of bus, and homosexuals no longer have to wear blue hat.

3. Create a Telephone Pad on the terminal by running either of the two below commands:

$ printf "%s\t%s\t%s\n" {1..9} '*' 0 '#'

or

$ echo {1..9} '* 0 #' | tr ' ' '\n' |paste - - -

4. The below command displays size of all files on the system and remains one of my favorites.

$ du -h|sort -hr|less

Be patient because this command takes a few seconds to spit out the output.

5. Act busy even if you are not.

We live in a world where appearances count more than anything else. So the next time you feel like a cup of coffee or an early lunch, run the below command and anyone dropping by to your cubicle will be amazed at how hard you work while actually you’re at Starbucks enjoying a steaming Latte. šŸ™‚

$ cat /dev/urandom | hexdump -C | grep "ca fe"

6. An extremely useful command, inxi provides a summary of the hardware specs and essential software running on your computer.

$ inxi -F

7. How about a stop watch on the screen? Sure, we can do that.

$ time read

Press ctrl-d to stop

8. Your IP address as seen by the world.

$ curl ifconfig.me
209.222.18.83

9. Download your favorite web site with the below command:

$ wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com

In the above illustration, replace example.com with the URL of your favorite web site.

While a small site will take less than a minute to download, large sites with a gazillion pages could take an eternity.

Note: Remember it’s likely illegal in most jurisdictions to download someone else’s web site without permission to your local computer.

10. Put a clock in the top right corner of your terminal

$ while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-29));date;tput rc;done &

11. Which applications are using the Internet?

If you’re like me, you’re forever installing the latest and greatest applications and occasionally even beta apps.

Now with so many applications on your system, I think it’d be prudent to know which ones are accessing the Internet.

The below command will give you both the application accessing the Internet and the IP address it’s connecting to.

$ lsof -P -i -n

or

$ lsof -P -i -n | cut -f 1 -d " "| uniq | tail -n +2

The above command gives just the name of the applications using the Internet.

12. Solid state drives are all the rage with IT guys now, right? A couple of weeks back, even a scrooge like me picked up a Samsung EVO 240 SSD at Best Buy for $99 (250GB version).

But how would you identify whether the hard drive inside your computer is an SSD or the oldstyle spinning disk. Simple, just run the below commanbd,

$ cat /sys/block/sda/queue/rotational
0

If the answer is 0, then you have a SSD inside. If the output is 1, then it’s a regular hard drive.

Sorry, the comment form is closed at this time.