Linux Tutorials

2 Methods to Re-run Final Executed Instructions in Linux

One of many best options of Bash is the command historical past, which shops all instructions a consumer runs, in a historical past file inside his/her dwelling listing (usually /dwelling/$USER/.bash_history). This permits the consumer to simply recall, edit and rerun earlier instructions.

On this article, we’ll reveal methods to re-execute a particular command from the historical past of instructions entered to a shell. That is helpful to keep away from typing the identical instructions again and again.

Usually, to get a command you lately run, you should use the Up arrow keys to retrieve a earlier command. Urgent it always takes you thru a number of instructions in historical past, so you will discover the one you need. Use the Down arrow to maneuver within the reverse path.

Nonetheless, the historical past file could comprise a variety of entries, to re-execute a particular command from the historical past of instructions, you may run the historical past command.

$ historical past

List Last Executed Linux CommandsList Last Executed Linux Commands

Record Final Executed Linux Instructions

Then get the quantity(s) of the command(s) you need to re-execute (if, for instance you need to restart PHP-FPM and examine its standing, it’s worthwhile to re-execute the instructions 997 and 998) as proven.

$ !997
$ !998

Re-excute Previous Commands in LinuxRe-excute Previous Commands in Linux

Re-excute Earlier Instructions in Linux

You may also re-execute beforehand used command (sudo yum replace) with ‘!’ character adopted by just a few of the primary characters (as an example sud or sudo) of that individual command as proven.

$ !sud
OR
$ !sudo

Re-excute Previous Command Using Exclamation MarkRe-excute Previous Command Using Exclamation Mark

Re-excute Earlier Command Utilizing Exclamation Mark

For extra details about Bash historical past, see these following guides:

The Energy of Linux “Historical past Command” in Bash Shell
How one can Clear BASH Command Line Historical past in Linux
Set Date and Time for Every Command You Execute in Bash Historical past
Helpful Linux Command Line Bash Shortcuts You Ought to Know

That’s all! Bash historical past is a cool function that lets you simply recall, edit and rerun earlier instructions. If you already know different methods to re-excute the final exucuted command do share with us within the remark part.

Share

Ask Anything

‘,
enableHover: false,
enableTracking: true,
buttons: twitter: by way of: ‘tecmint’,
click on: perform(api, choices)
api.simulateClick();
api.openPopup(‘twitter’);

});
jQuery(‘#fb’).sharrre();
jQuery(‘#googleplus’).sharrre(
share: ,
template: ‘

‘,
enableHover: false,
enableTracking: true,
urlCurl: ‘https://www.tecmint.com/wp-content/themes/tecmint/js/sharrre.php’,
click on: perform(api, choices)
);
jQuery(‘#linkedin’).sharrre();
// Scrollable sharrre bar, contributed by Erik Frye. Superior!
var shareContainer = jQuery(“.sharrre-container”),
header = jQuery(‘#header’),
postEntry = jQuery(‘.entry’),
$window = jQuery(window),
distanceFromTop = 20,
startSharePosition = shareContainer.offset(),
contentBottom = postEntry.offset().prime + postEntry.outerHeight(),
topOfTemplate = header.offset().prime;
getTopSpacing();
shareScroll = perform(){
if($window.width() > 719)
var scrollTop = $window.scrollTop() + topOfTemplate,
stopLocation = contentBottom – (shareContainer.outerHeight() + topSpacing);
if(scrollTop > stopLocation)
shareContainer.offset();

else if(scrollTop >= postEntry.offset().top-topSpacing)
shareContainer.offset();
else if(scrollTop 1024)
topSpacing = distanceFromTop + jQuery(‘.nav-wrap’).outerHeight();
else
topSpacing = distanceFromTop;

});

Source link

Related Articles

Back to top button