Also: 8 things you can do with Linux that you can’t do with MacOS or Windows I’ve been using Linux for a very long time, so the terminal window is second nature to me. Because of that, I run a lot of commands. Sure, I could do everything I need with a GUI, but sometimes the terminal is just faster (for me).  However, there are days when I find myself staring at the terminal window, scratching my head and trying to remember the command I ran the previous day. Thankfully, with Linux, there are a number of ways to locate the command. I tend to use two methods. The first is to use the up and down arrow keys to scroll through the last few commands I ran. Although that method is my go-to, there are times when I have to scroll so far back in my history that it’s not exactly the most efficient use of my time.  Also: The best Linux laptops you can buy There’s another way to view those previously run commands. With a nod to irony, the method of viewing previously run commands is yet another command… history. According to the history man page (which can be viewed with the command man history), “The GNU History library is able to keep track of those lines, associate arbitrary data with each line, and utilize information from  previous lines in composing new ones.” A better description would be the history command prints out a line-by-line history of the commands you’ve previously run. By default, 1000 commands will be retained. You can even verify this with the command: echo $HISTSIZE The output should read simply: 1000

How to use the history command

You can then scroll through the output to find the command you need. Or: Also: How to install Linux on an old laptop Say, for instance, you want to change the history limit to 500. The commands for that would be: Or: You get the idea. When you find the command you’re looking for, highlight it, hit [Ctrl]+[Shift]+[C] to copy the command and [Ctrl]+[Shift]+[V] to paste it back into the terminal. 

Simplify the search with grep

Say you know you’ve run a particular command many times with different options. For example, you’ve used the nano editor on a configuration file but you can’t remember where the file was.  Also: Ubuntu Lunar Lobster could be the surprise hit of 2023 You can filter out only commands that included nano by piping the history output through grep, like so: The output will only include only nano commands. And that’s how Linux can help remind you of the command you’re looking for, without having to spend too much time or energy recalling what you did two or three days ago in the CLI.