History Command is used to view the previously executed command and it can also list it.
This feature was not available in the Bourne shell.
Bash and Korn support this feature in which every command executed is treated as the event and is associated with an event number using which they can also be recalled and changed if required.These commands are saved in a history file. in Bash shell history command shows the whole list of the command.
- show the limited number of commands that executed as follows:
The command can also be executed using event number .
2. you can also print command before executing it by using :p after event number of command.
3. to execute the 6th command from the History list Bottom :
4.This Command can also be used along with grep:
history | grep yum
5. The most recent command can be viewed using !!
6. So suppose if the command has to be executed without being stored variable HISTFILE has to be unset.
So the command will be:
7. The command can also be executed using a part of the command.
8. History can also be removed using history -d event_number.
history -d 566
The “.bash_history” hidden file stores every command you wrote, every user has a bash history even the super user ‘root’.
9. the whole history can be removed using history -c option but it can’t be removed from the “.bash_history“.
10. So to remove the whole history from the “.bash_history” file you can use this :
echo " " > .bash_history
11. You can also know your history list size :