12. history command - muneeb-mbytes/linux_course GitHub Wiki
The history command in Linux is a built-in shell tool that displays a list of commands used in the terminal session.
we will show you how the history command works and different ways to use it.
Fig: These are all the variations that you have in "history" command.
S.No | History commands | Description |
---|---|---|
1 | history | Show the previously executed commands |
2 | history -c | Remove all the history of executed commands |
3 | history n | Show of history of previously 5 executed commands |
4 | command execution with history | Access the particular command from history with help of event number |
This command is used to show the previously executed commands.
In this below Fig-1 you can see we type some commands , then these commands
are list out with event number and time when we use history command
Fig-1: Usage of history command
The below GIF shows the whole process from sourcing scripting file till the output.
GIF-1: giphy of history command
GitHub Link : https://github.com/muneeb-mbytes/linux_course/blob/b7_Team_BJT/history_commands/history.csh
This command is used to remove the whole history
In this below Fig-2 you can see we type some commands then we type history -c
which remove the all previously executed commands
Fig-2: Usage of history -c command
The below GIF shows the whole process from sourcing scripting file till the output.
GIF-2: giphy of history -c command
GitHub Link : https://github.com/muneeb-mbytes/linux_course/blob/b7_Team_BJT/history_commands/history_clear.csh
This command is used to show the previously executed n command
In this below Fig-3 you can see we use some commands then use the command history 5
which list out the previously latest 5 executed commands
Fig-3: Usage of history 5 command
The below GIF shows the whole process from sourcing scripting file till the output.
GIF-3: giphy of history 5 command
GitHub Link : https://github.com/muneeb-mbytes/linux_course/blob/b7_Team_BJT/history_commands/history_number.csh
This command is used to access a particular command from history .
In this below Fig-4 you can see when we type history 5 then previously 5 executed command is list out
with event number . ls command is at event number 100 so, when we type !100 then ls command is executed
Fig-4: Usage of the !<event_num>
To learn mv command : https://github.com/muneeb-mbytes/linux_course/wiki/13.-mv-command