AddThis Smart Layers

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
rm ~/.bash_history
In 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 -c
This 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:

About This Blog

There is something for everyone. !! A tech blog updated by me on various topics. Let it be reviews of websites, software's, a new service ,guide etc we have it all covered here in layman terms :)

Total Pageviews

Back to TOP