Ubuntu – Go back to the last command

command line

Suppose you type a command in terminal after Enter you will see a list which more than one page. Now you want to read the result from the beginning and you should scroll up. So if you put some commands before your last one its a bit difficult to scroll the the last one –at least for me — So I need any key switch which show the screen from the last command.

ps: I want to screen show the last command by key switch. Is there any key switch like CTRL+ L which clear the screen. less command show the screen page by page.

Best Answer

There isn't one as far as I know. You have a few choices though:

  1. Pipe the output through less or more

    command | less
  2. Hit the up until you find the command you ran and run it again (optionally using less or more again).

  3. Run the previous command through less using history expansion.

    !! | less
  4. Use a terminal that supports searching through the scroll back. The image below is showing my preferred terminal, terminator (installable with sudo apt-get terminator) but Ubuntu's default terminal also supports this. Just hit Ctrl Shift F to show the search bar. If you then search for either the command's name or your username (which appears in your prompt) you will be taken directly back to the last command:

    enter image description here

Related Question