Helpful, Crazy and Somewhat Useless Linux Commands

Linux, being a great community, has a great command for everything.  If you need it, somebody wrote it.  And even if you don’t need it, somebody probably wrote it.  Below is a list of some useful, some absolute useless, and other completely crazy Linux commands.

Useful Commands

Let’s go over the fairly useful ones first.

1.  w command:  See Who’s Doing What

Sometimes the simplest, shortest command will tell you more information than a long one.  Take the “w” command for example.  This simple, one character command will return uptime information, load average, a list of users logged in and what commands they are running:

# w
 01:55:43 up 101 days, 19:28,  2 users,  load average: 0.08, 0.03, 0.01
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
jstaten  pts/0    c-50-160-113-166 01:45   10:12   0.15s  0.15s telnet towel.blinkenlights.nl
jstaten  pts/1    c-50-160-113-166 01:49    0.00s  0.02s  0.01s sshd: jstaten [priv]

2.  Factor Command:  Help Your Son or Daughter with 6th Grade Math

Ok, truthfully, I am not certain how useful this one is. but, If your child is doing typical 6th grade math, you can use the “factor” command to find the root factors of a particular number.  In the example below, we were able to find the factors of the following numbers:  4, 8, 16, 43046721, and 8675309!

$ factor 4
4: 2 2

$ factor 8
8: 2 2 2

$ factor 16
16: 2 2 2 2

$ factor 43046721
43046721: 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

$ factor 8675301
8675301: 3 23 59 2131


3.  Watch:  Rerun a Command Frequently, Displaying Changes in Output

I think I use the “watch” linux command everyday.  Watch will continue to run a command until you interrupt it with a <ctrl-c>.  You can have it highlight the changes in the output using the -d parameter and change the frequency that it is run using the -n parameter

Example:  The example below will watch the /proc/diskstats file for changes on the vda line every 3 seconds:

# watch -d -n3 'cat /proc/diskstats | grep vda

Every 3.0s: cat /proc/diskstats | grep vda Thu May 29 18:12:58 2014

 253 0 vda 8389675 45452479 739870324 17019061 17813291 104927370 98195352
0 347683787 0 34861757 364694207

 

Example:  I am watching the size of my varnishncsa.log file to see if it is growing or not.  Note, in this example, the refresh rate is using the default of 2 seconds because I did not specific a -n parameter:

# watch -d 'ls -l /var/log/varnish/varnishncsa.log'

Every 2.0s: ls -l /var/log/varnish/varnishncsa.log                                                    Thu May 29 03:04:46 2014

-rw-r--r-- 1 root root 32471599 May 29 03:04 /var/log/varnish/varnishncsa.log

 

Useless Linux Commands

Ok.  So some of those commands above are obviously pretty useful.  Here are some Linux commands that may have a use, but it may be hard to find.

1.  Cal – Display a Calendar for a Specific Month or Year

If you want just one month, specify the month’s number, followed by the year.  If you want just a specific year, only enter the year as a parameter.

Example:  Show me a calendar for April 2015

$ cal 4 2015
     April 2015
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

Admittedly, I do remember a time or two where I needed a quick calendar view and used this, so maybe I can’t call this completely useless, but I will say that its overall usefulness is a bit questionable.

2.  Yes – Repeatedly Echo a String Until Interrupted

So can anybody really give me a scenario where this would be a useful??  The gist of the yes command is to give it a string, hit return, and the string will be echoed repeatedly until you interrupt it with a <Ctrl-C>.

Example:  Using the “yes” command to echo “some string” again and again…

$ yes "some string"
some string
some string
some string
some string
some string
some string
some string
some string
some string
some string
some string
some string
some string
some string
<Ctrl-C>

Yeah, that’s useful.

3.  Rev – Reverse the Characters of a Input String

PLEASE, PLEASE somebody tell me how this could be useful.  I am looking for anything here.

Example:  Enter the rev command and then type some strings to be reversed.

$ rev
jeff
ffej
uptimemadeeasy
ysaeedamemitpu

Or

Example:  Redirect a file into the “rev” command.

$ rev < ./sometextfile
xof nworb kciuq eht

 

4.  Figlet – Make Big Puffy Letters Out of Your Input String

This one might be useful for the crafty types.  Figlet wasn’t installed on my machine by default, so I had to install the “figlet” command using yum which, of course, required the having the EPEL repository.

Example:  Install figlet and then use figlet to make big puffy letters out of my domain name:  “uptimemadeeasy.com”

# yum install figlet
....
# figlet uptimemadeeasy.com
             _   _                                    _
 _   _ _ __ | |_(_)_ __ ___   ___ _ __ ___   __ _  __| | ___  ___  __ _ ___
| | | | '_ \| __| | '_ ` _ \ / _ \ '_ ` _ \ / _` |/ _` |/ _ \/ _ \/ _` / __|
| |_| | |_) | |_| | | | | | |  __/ | | | | | (_| | (_| |  __/  __/ (_| \__ \
 \__,_| .__/ \__|_|_| |_| |_|\___|_| |_| |_|\__,_|\__,_|\___|\___|\__,_|___/
      |_|

 _   _   ___ ___  _ __ ___
| | | | / __/ _ \| '_ ` _ \
| |_| || (_| (_) | | | | | |
 \__, (_)___\___/|_| |_| |_|
 |___/

Example:  The following example uses a specific figlet font file from the /usr/share/figlet directory to rewrite my domain name.  For additional font files, navigate to and list the files in the /usr/share/figlet directory.

# figlet -f /usr/share/figlet/bubble.flf uptimemadeeasy.com
  _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _
 / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( u | p | t | i | m | e | m | a | d | e | e | a | s | y | . | c | o | m )
 \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/

Totally Crazy Linux Commands

First, there are useful commands, then useless commands, then absolutely crazy commands.  These commands were written, I am sure because they are just fun.  There may not be anything useful about them, except for providing a laugh.

1.  Cowsay – Give the Cow Some Text to Say

The cowsay command is installed using yum and the EPEL repository.  The cowsay command by default will display the cut cow stating the text you typed.  However, there are other options for the character.  You can use any of the character templates found in the cowsay template directory (/usr/share/cowsay).  Cowsay also has a “Tongue String” option that allows you to specify a string that will be used for the tongue of the cow.

Example:  This example shows how to install the cowsay command using yum, then shows an example of using “cowsay” to type “I love milk” with a tongue made of eights.  Afterwards, I list the cow template files found in the “/usr/share/cowsay” directory.

# yum install cowsay
...

$ cowsay -T 88 I love milk
 _____________
< I love milk >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
             88 ||----w |
                ||     ||




$ ls /usr/share/cowsay/
beavis.zen.cow  dragon-and-cow.cow     hellokitty.cow    milk.cow       small.cow        turkey.cow  bong.cow        dragon.cow             kiss.cow          moofasa.cow        
...

Example: In this example, I use the skeleton cow template.

$ cowsay -f /usr/share/cowsay/skeleton.cow I make cheese
 _______________
< I make cheese >
 ---------------
          \      (__)
           \     /oo|
            \   (_"_)*+++++++++*
                   //I#\\\\\\\\I\
                   I[I|I|||||I I `
                   I`I'///'' I I
                   I I       I I
                   ~ ~       ~ ~
                     Scowleton


2.  Sl – Steam Locomotive Command

Once again, this sl command needs to be installed with yum and the EPEL repository.
Example:  In this example, I use the steam locomotive (sl) which displays a train driving across my screen.

$ sl

 

sl-steam_locomotive

Choo Choo!!

3 – And Finally!  Watch Star Wars – Episode IV in Your Linux Terminal

Ok.  So, you don’t have to use linux to do this one, all that you need is telnet client.  By using telnet to contact  “towel.blinkenlights.nl”, you can watch “Star Wars – Episode IV – A New Hope”

Screen Shot 2014-05-28 at 7.47.28 PM

So, that’s a pretty quick list.  Leave me a comment if you have other useful, useless or totally crazy commands that you think I should add to the list of Helpful, Crazy and Somewhat Useless Linux Commands.

The following two tabs change content below.
Jeff has 20 years of professional IT experience, having done nearly everything in his roles of IT consultant, Systems Integrator, Systems Engineer, CNOC Engineer, Systems Administrator, Network Systems Administrator, and IT Director. If there is one thing he knows for sure, it is that there is always a simple answer to every IT problem and that downtime begins with complexity. Seasoned IT professional by day, Jeff hopes to help other IT professionals by blogging about his experiences at night on his blog: http://uptimemadeeasy.com. You can find Jeff on or LinkedIn at: LinkedIn or Twitter at: Twitter

Latest posts by Jeff Staten (see all)

2 comments for “Helpful, Crazy and Somewhat Useless Linux Commands

  1. chris
    July 14, 2014 at 8:47 am

    How do i get rid of the ‘sl’ command, i do not want it anymore.

  2. July 16, 2014 at 7:36 pm

    Chris,

    You can remove the sl command using “yum remove sl”.

    For more information on installing and removing commands from your box, see the article on yum here at uptimemadeeasy.com at:

  3. http://www.uptimemadeeasy.com/linux/install-update-remove-and-automate-yum-package-management/.
  4. Jeff