cmd to find used cmd in linux

  1. Using the history Command: You can view a list of previously executed commands along with their line numbers by typing history in the terminal. Then, you can refer to a specific command by its line number.

  2. Using the Ctrl + R Shortcut: Pressing Ctrl + R in the terminal will initiate a reverse search. You can start typing a portion of the command you want to search for, and the terminal will display the most recent matching command. Pressing Ctrl + R again will cycle through older matches.

  3. Using !!: Typing !! in the terminal will execute the last command used. This is useful if you want to quickly repeat the previous command.

  4. Using !n: You can execute a specific command from your history by typing !n, where n is the line number of the command you want to execute. For example, !123 will execute the command on line 123 of your command history.

  5. Using history | grep keyword: You can search for commands containing a specific keyword by piping the output of history to grep. For example, history | grep ssh will display all commands related to SSH.

These methods should help you quickly find and reuse previously used commands in your Linux terminal.