Shell commands history [Linux]
Here is a quick tip for those who use Linux and in particular those who use shell/terminal often. We all know that terminal remembers all your past commands and you can navigate to and fro using arrow keys. But what if you want to use a particular command which you used long back. It involves a lot of navigation.
But luckily all commands are stored in a text file called ".bash_history" which is located in the home folder of the user (ex: /home/adithya). Its a hidden and system file by default. Normally all linux file managers shows the hidden files by pressing CTRL + H.
So, just open that file in text editor and you can see all commands that you have typed in.
In case you want to clear all your command history, first delete the ".bash_history" file by typing command
In case you wish to copy/transfer the command history from one system / user to another, just copy the ".bash_history" file and overwrite it in the target user folder.
But luckily all commands are stored in a text file called ".bash_history" which is located in the home folder of the user (ex: /home/adithya). Its a hidden and system file by default. Normally all linux file managers shows the hidden files by pressing CTRL + H.
So, just open that file in text editor and you can see all commands that you have typed in.
In case you want to clear all your command history, first delete the ".bash_history" file by typing command
rm ~/.bash_historyIn addition, if you want to clear the buffer history (Command history remains active after history file deletion until the current terminal session is closed ), then issue command :
history -cThis will reset the terminal command history.
In case you wish to copy/transfer the command history from one system / user to another, just copy the ".bash_history" file and overwrite it in the target user folder.

0 comments:
Post a Comment