This is a simple command line skill for beginners how to use history commands quickly and easily.
For frequently used command with a long code, you don’t need to type all the code everytime you run this command. Just type in !n, where n is a number from your history list.
For example, following is a section of my history commands:
1262 sudo apt-key adv –keyserver pgp.mit.edu –recv-keys 5044912E
1263 sudo sh -c ‘echo “deb http://linux.dropbox.com/ubuntu/ raring main” >> /etc/apt/sources.list.d/dropbox.list’
1264 sudo apt-get update
1265 sudo apt-get install dropbox
Before cleaning the history, I can run “sudo apt-get update” command by type in:
!1264
For more:
- !! : run the previous command.
- !n:p : only preview command number n (will not execute the command).
- !string : Run most recent command starting with characters in string.