• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Saturday, May 17, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

2 Ways to Re-run Last Executed Commands in Linux

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
112
VIEWS
Share on FacebookShare on Twitter

One of the greatest features of Bash is the command history, which stores all commands a user runs, in a history file within his/her home directory (typically /home/$USER/.bash_history). This allows the user to easily recall, edit and rerun previous commands.

In this article, we will demonstrate how to re-execute a specific command from the history of commands entered to a shell. This is useful to avoid typing the same commands over and over again.

Normally, to get a command you recently run, you can use the Up arrow keys to retrieve a previous command. Pressing it constantly takes you through multiple commands in history, so you can find the one you want. Use the Down arrow to move in the reverse direction.

However, the history file may contain a lot of entries, to re-execute a specific command from the history of commands, you can run the history command.

$ history 
2 Ways to Re-run Last Executed Commands in Linux

List Last Executed Linux Commands

Then get the number(s) of the command(s) you want to re-execute (if, for example you want to restart PHP-FPM and view its status, you need to re-execute the commands 997 and 998) as shown.

$ !997
$ !998
2 Ways to Re-run Last Executed Commands in Linux

Re-excute Previous Commands in Linux

You can also re-execute previously used command (sudo yum update) with '!' character followed by a few of the first characters (for instance sud or sudo) of that particular command as shown.

$ !sud
OR
$ !sudo
2 Ways to Re-run Last Executed Commands in Linux

Re-excute Previous Command Using Exclamation Mark

For more information about Bash history, see these following guides:

  1. The Power of Linux “History Command” in Bash Shell
  2. How to Clear BASH Command Line History in Linux
  3. Set Date and Time for Each Command You Execute in Bash History
  4. Useful Linux Command Line Bash Shortcuts You Should Know

That’s all! Bash history is a cool feature that allows you to easily recall, edit and rerun previous commands. If you know other ways to re-excute the last exucuted command do share with us in the comment section.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

4 Ways to Disable Root Account in Linux

Next Post

12 Practical Examples of Linux grep Command

Next Post

12 Practical Examples of Linux grep Command

Leave a Reply Cancel reply

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

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet