Linux

Search commands in Linux (last terminal commands)

September 15, 2021

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

Search commands in Linux cover

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:

Search commands in Linux example

If you remember a part of the command, Linux will help you complete with commands that have already been typed, like this:

Search commands in Linux example 2

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:

Imagem

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 🙂

Conclusion

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!

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x