• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / Which Command Is Used To ‘Re Execute The Previous Command In Linux

Which Command Is Used To ‘Re Execute The Previous Command In Linux

By Sourabh / January 5, 2025 Category: How To, Ubuntu

Do you want to know which command is used to ‘re execute the previous command in Linux Ubuntu Systems. Read this post to find out which keyboard key retrieves the last command that you entered in the default Linux Shell.

Let us learn more about re-executing previous commands.

Method 1 – Run Last Command using Exclamation Marks

To execute the last executed command, just type double exclamation marks, and press ENTER key in the terminal:

$ !!

This will execute the last command.

You can also run the command as root user. Simply add sudo in-front of !! to execute the last command as root user.

$ sudo !!

Or

$ su -c "!!"

Method 2 – Use Hyphen Symbol with Command Prefix Numbers

If you want to run a specific command which was executed lastly (but you don’t know when, was it the last command or the second last command or the third last command).

To execute the previous command, run the following:

$ !-1

Note that the number 1 denotes here the last executed command, similarly, !-2 will run the second last command, !-3 will run the third last, !-4 will run the fourth last command, and so on.

In this case you can use the history command to re-execute a certain command using hyphen symbol with the command prefix number.

When you run the history command you see the list of previously executed commands with their corresponding command number (prefix). Note down the prefix of the command and to re-execute the command with hyphen.

Method 3 – Re-execute Previous Commands Using CTRL+P

You can search the command line history using CTRL+P. Press CTRL+P key to search through the command line history and once you find the command you want to execute, press ENTER key.

This is also another way to repeat the last executed command. You can use the fc command is used to list, edit and re-run the previously entered command.

And, that’s all. I hope you shall find this article useful and these methods will help yo in future.

Primary Sidebar

Latest Posts

Ubuntu 25.04 ‘Plucky Puffin’ Is Available To Download

How to Login as Root User in Linux Terminal

Install Firefox In Ubuntu Terminal Command Line

How To Check Kernel Installed Date In Linux Ubuntu

How To List All Kernel Modules That Are Loaded In Ubuntu

Enable Ubuntu Auto Login Without Password

Download Ubuntu 25.04 Official Default Wallpapers

How To Fix Initramfs Error In Ubuntu Command Line

How To Check All Available Kernel Version In Linux Ubuntu

3 Best Artificial Intelligence Domain Name Generators

© 2025 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap