Linux Shell History

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Linux Shell History

The 'history' command will display a list of last commands used in the shell (shell history).

Syntax:

history <number>

Example:

history 10

Linux History1

Look at the above snapshot, we have used history -10 (you can use any integer) command, it displays list of last ten commands.

Note:"history -c" clears the list of all the commands from history.


Ctrl + r

The keys 'ctrl+r' executes the last command from history matching the specified characters that you type.

Syntax:

press 'ctrl+r'. <characters> 

Example:

press 'ctrl+r'. ca

Linux History2

Look at the above snapshot, we have pressed 'ctrl + r' followed by two characters ca and it has found the last command matching characters 'ca'.