To recall a previous command, we use the history
command. There are many options you can set depending on how you want to manage your history.
Set the number of lines to store in history
Use the HISTSIZE variable. Edit ~/.bashrc
or ~/.bash_profile
and add this:
HISTSIZE=1000
HISTFILESIZE=1000
Log out of the terminal session and login. You will see the changes.
Change the history filename to arulhistory
Use the HISTSIZE variable. Edit ~/.bashrc
or ~/.bash_profile
and add this:
HISTFILE=~/.arulhistory
Log out of the terminal session and login. You will see the changes.
Prevent repeated commands from piling up in history
Sometimes you enter several repeated commands like ls -al
and clear
. To prevent the duplicate commands from getting stored in history, use the HISTCONTROL variable. Edit ~/.bashrc or ~/.bash_profile and add this:
export HISTCONTROL=ignoredups
Now type history
and you won't find previous commands duplicated.
Related Posts
If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.