Different Ways To Repeat Your Last Command In Linux

14 Responses

  1. ashley_101 says:

    Thanks. Good information.
    However, it’s mentioned at the beginning that arrow UP key will work ON ALL. it doesn’t work for me. I get this : ^[

  2. Tiago says:

    thank you!

  3. Fodil says:

    Many thanks

  4. Leandro Cadete says:

    Very cool!

  5. Fabian says:

    Thanks for the tip with the exclamation mark. A nice workflow is this:
    history | grep -i “bash”
    Output:
    […]
    1223 bash -c “sudo su”
    1360 nano ~/.bashrc
    1432 history | grep bash
    Then:
    !1360
    That executes “nano ~/.bashrc” again.

  6. Chiti says:

    Good information!!

  7. Jalal says:

    Hi,
    Thanks a lot

  8. K3N says:

    You can also hit ALT dot (Alt+.) to get last command wo/ running it

    • sk says:

      Yes, but it will only retrieve the last argument in the command. For example, if your previous command is uname -r, hitting ALT+. will bring the -r, but not the entire command.

  9. fuseteam says:

    doesn’t work for me, perhaps because alt is sending escape aswell

  10. charle says:

    Thanks

  11. fuseteam says:

    here’s an sequel to your tip
    !1360 will not only print the 1360th command it will also add it to your bash history

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.