How to view the history of all the commands typed in Ubuntu?

Log In to Reply

Curiosity Technology Computers and Smartphones How to view the history of all the commands typed in Ubuntu?

Tagged: 

  • Is it possible to list all the commands ever typed in the terminal (or) pick a particular command from the log? I use the up arrow key to scroll through the commands but it is tedious to get back to a command that I typed a week ago. There should be an efficient way to do this.

  • The command is history. It lists around 500 commands that you have recently typed. You can filter the most recent commands with history x where x is the number of commands you’d like to see. You can also use grep alongside with the history command to search for a specific keyword. E.g. history | grep foo.

    And to use a command, you can use ! followed by the command number. E.g, !523 will run the 523rd command you typed. And !! will execute the last command you typed (comes handy if you forget sudo. You can just sudo !! instead of typing it all again.

    • Just ‘history’? Cool! This will save me a lot of time. Thank you very much.

    • You’re welcome! You can also save more time by using CTRL + R and searching for the frequent command. Hitting it repeatedly cycles through your history from the bottom. CTRL + S if you want to cycle from the top.

You must be logged in to reply to this topic. Log In