View the history of commands in Linux terminal
- August 31, 2019 at 1:44 PM #1893Santhosh Kumar DKeymaster
One can simply press the
up arrowkey 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?
In default, the above command will list around 500 commands that you have recently typed.
To filter these commands, use
xis the number of the command you want to see. For example:
And, to search for a specific keyword, use
grepalongside 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
!13and it will show the 13th command from the recent commands list.
If you want to run the very last command, use
And, to run the commands numbered from the last, use
And finally, to clear the history of all commands typed recently, type:
rm ~/.bash_history && history -c
- How to check Linux uptime?
- How to check Linux last reboot time?
- How to ZIP and UNZIP files in Linux?
- How to change the file owner and group in Linux?
- Protect your email address with Firefox Relay
- How to change the language in Microsoft Office?
- How to get Twitter dark mode on desktop and mobile?
- How to find a file in the Linux terminal?
- How to delete a directory in the Linux terminal?
- How to delete a file in the Linux terminal?
- Announcing Arclind Mindspace – Crash course platform for self-learners
- How to disk cleanup in Windows 10?
- How to disable startup programs in Windows 10?
- How to run system maintenance on Windows 10?
- How to remove password encryption from a Microsoft Office document?