View the history of commands in Linux terminal
- AuthorPosts
- August 31, 2019 at 1:44 PM #1893
Santhosh Kumar D
Keymaster@santhoshOne can simply press the
up arrow
key to scroll through the typed commands in Ubuntu. But, what if you want to view the history of commands in Linux terminal that you typed a week ago?Just type:
history
In default, the above command will list around 500 commands that you have recently typed.To filter these commands, use
history x
Herex
is the number of the command you want to see. For example:history 5
And, to search for a specific keyword, use
grep
alongside the history command. For example:history | grep user
You can also recall a command by typing the (exclamation mark)
!
followed by the entry number.
For example, type!13
and it will show the 13th command from the recent commands list.If you want to run the very last command, use
!-1
or!!
And, to run the commands numbered from the last, use
!-2
or!-3
And finally, to clear the history of all commands typed recently, type:
rm ~/.bash_history && history -c
- AuthorPosts
Advertisement
RECENT TIPS
- How to send email as an alias in Gmail?
- How to stop Google from tracking your location?
- Command to check the Ubuntu version
- How to add a percentage in Excel?
- How to convert currencies in Google Sheets?
- How to voice type on Google Docs?
- What is Django framework?
- How to turn Google Assistant off?
- How to check the Python version?
- How to create a virtual environment in Python?
- How to change the directory in the Command Prompt?
- How to add a shortcode in WordPress PHP template file?
- Useful websites to research stocks
- How to check Linux uptime?
- How to check Linux last reboot time?