Search commands in Linux (last terminal commands)
Sometimes we type very complex and the next day we don’t remember them, so in this article, you’ll see how to search for commands in Linux
How to fetch commands in Linux?
The first strategy we can use is a reverse search
In the terminal press Ctrl + r, and a prompt will ask you for the command name, see:
If you remember a part of the command, Linux will help you complete with commands that have already been typed, like this:
If the command is not the first result, to search again you can press Ctrl + r as many times as you need, it will search for more results similar to what you typed.
Also if you type something different from the previous commands, it still indicates that the search said:
In this case, no command close to what you’re looking for has been done before.
He returned the cd as my first term was ‘~’, but nothing for ‘~~~’ exists.
Another important piece of information is that you will feel trapped in this reverse search because it “leaves” the terminal and performs this search.
So if you want to cancel this action just press Ctrl + c, then you will be “back” to the terminal 🙂
Another way to fetch commands in Linux
Another way to search for commands if you don’t remember any part of the command is history.
If you type this command in the terminal, you will see a list of the last used commands.
This can be useful if the command was recently used, so you can quickly find it.
It’s also a good way to know which commands were used if something damaged the system from one to another 🙂
In this article you’ve learned how to search for commands in Linux terminal
There are two ways to search for commands:
- Ctrl + r: when you remember a part of the typed command;
- history: when you want to see a newly typed command;
And that’s it for today, until the next post!