Soon it will be 2016 — the Year of the Monkey in the Chinese Zodiac’s 12 year cycle. People born in these years (e.g., 1920, 1932, 1944, 1956, 1968, 1980, 2004, and now 2016) are supposed to be quick-witted, optimistic, ambitious, etc. So, let’s see what quick-witted, optimistic, ambitious things we can do to monkey around on the command line more gracefully.

To start, let’s look at some of the more unusual and less obvious things that you can do with Linux history. The tricks that most command line users know include these relatively easy commands:

Example	  Description
=======   ===========
!e        run the last command you ran that started
          with "e"
!22       run the 22nd command as stored in the
          history commands
!!        run the previously entered command
sudo !!	  run the previous command using sudo (very
          helpful if you forgot to use sudo and don't
          want to retype the entire command)
sudo !e	  run the last command you ran that starting
          with "e" using sudo
sudo !22  run the 22nd command in your history using
          sudo

Less obvious are commands such as !-2 that run previous commands based on how far we have to reach back in our history. This one runs the command that was entered two commands ago (i.e., the command before the most recent command).

To read this article in full or to leave a comment, please click here

Source: COMPUTER WORLD