Categories
Linux Tutorial Series

Linux Tutorial Series – 77 – The history command

Here is the video version, if you prefer it:

Let’s talk about history. No, not about a high school history class or about your browsing history (that could spark interesting conversations for sure). I’m talking about the history command.

The history command is used to display your command execution history. (Shotts, 2019)⁠ Example usage:

mislav@mislavovo-racunalo:~/Linux_folder$ history | grep sudo

1075 sudo apt install nodejs npm

1081 sudo npm install npm@latest -g

...

Here, I look for all of the sudo prefixed commands that I have executed. It is important to note that history doesn’t go on till the beginning of your bash usage – it is limited, although you can change how much history entries you keep. Keep that in mind.

Your history is stored in a file called .bash_history in your home directory (the first dot in the filename indicates it is a hidden file).

I didn’t use history as much, but I was aware of its existence. I have found myself looking for the commands I ran by using the Up/Down arrows on the keyboard. history seems to be a better choice for when the command was used in the not-so-recent past.

Hope you learned something useful!

References

Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Page 110

Categories
Linux Tutorial Series

Linux Tutorial Series – 16 – Command history and cursor movement

Here is the video version, if you prefer it:

Did you know you can use the Up/Down arrows on your keyboard to see previous commands you executed in the Linux shell? Did you know that you can use Left/Right arrows to move your cursor? (Shotts, 2019)⁠

If you did not, now you do. If you did, great for you!

Hope this helped.

References

Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Page 27