Tuesday, July 5, 2016

Command line history

The history command can be used to list all the previous commands you have typed before. The syntax is as following:

history n

where n is the number of commands you have typed before.

Example:
This lists the last 5 commands typed before:
$ history 5
  510  cp /home/pepito/myfile /home/pepito/myfolder
  511  ls
  512  ip addr show
  513  ifconfig
  514  history 5

You can select to execute a command from the list with the following:

!n

Where n is the number of the command in the list.

Example:
This will execute the command number 511 that is the ls command:
$ !511
ls
example.txt

Related Posts:

0 comments:

Post a Comment

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Search This Blog

Powered by Blogger.