Using Linux History
One really nice feature of Linux is its ability to maintain a history of the commands you typed in. Its like a little journal of your linux journey and you can easily access and browse with some handy commands. There are some commands that you’ll run often and being able to reference those can be extremely useful. We’ve written about leveraging your history before in our article terminal history auto suggestions as you type with oh my zsh so we’re big fans of being efficient and reusing commands in our terminal. Let’s check out some info about history:
Simply typing history
will show you a list of all your executed commands in linux.
A very quick tip is to use the pipe (written about here) to be able to search on what the history output shows us:
We use ripgrep which is an extremely fast and easy to use search tool so our search would be:
If you want to customize how your history output displays, linux gives you some options you can specify to change the display:
You would specify this in your .bashrc or your .bash_profile. You can also set an option to ignore duplicate commands in your history:
Set the number of commands stored in your history with the HISTSIZE variable:
See a list of other bash variables here