If you are a Linux user, macOS or you are using the Git terminal on windows, surely you know that every time we execute a command in the terminal it is stored in the command history.
The history stores the last 500 commands that have been executed in the Terminal, and it is very useful to have this list to be able to access a specific command.
What if we want to delete a command from the history? How do you do it?The first thing we should know is that to show the history of the terminal, we must enter the history command :
See the full history
To see a complete list with the last 500 commands, we must execute in the Terminal:
# Ver historial de comandos
$ history
On the left there is a column with the command history index.
Delete a given command (x)
If we want to eliminate a specific command, we must keep its number that appears on the left side.
# Eliminar el comando X
$ history -d X
Delete all history
If we need to delete all the history we simply type in our terminal.
# Eliminar todo el historial
$ history -c
View a specified number of commands
Sometimes we need to see only the last, for example, 10 commands executed.