Skip to main content
Android

✅ How to repeat the last command in Linux without using the arrow keys




How to repeat the last command in Linux without using the arrow keys: Well, sometimes you want to repeat the above command on the command line when working with Linux systems and that in addition without using the arrow keys, so there is no particular way to do it, but here in the troubleshooter we have listed all the different ways to do just this.

To repeat the commands normally you can use the old history operator csh! «!!» (without quotes) for the most recent command, if you want to just repeat the previous command then you can use! -2,! foo for the most recent one starting with the subsrting "foo". You can also use the fc command or basically use: p to print the hint of the history operator.

How to repeat the last command in Linux without using the arrow keys

Let's look at some of the ways to remember the commands in the shell prompt:

Method 1: For the csh or any shell that implements csh history substitution

!! Then hit Enter. O! -1 Then press Enter OR Ctrl + P and then press Enter

Note: !! or! -1 will not expand automatically for you and until you run them it might be too late.

If you use bash, you can put bind space: magic-space in ~ / .bashrc and after the command hitting space it will automatically expand them online.

Method 2: Use Emacs Key Bindings

Most shells that have a command line editing function that supports Emacs key bindings:

Up Ctrl + P Down Ctrl + N Left Ctrl + B Right Ctrl + F Home Ctrl + A End Ctrl + E Remove Ctrl + D

Method 3: Use CTRL + P and then CTRL + O

Pressing CTRL + P will allow you to switch to the last command and pressing CTRL + O will allow you to execute the current line. Note: CTRL + O can be used as many times as you like.

Method 3: Using the fc command

fc -e: -1 For example: $ echo "Troubleshooter" Troubleshooter $ fc -e: -1 echo "Troubleshooter" Troubleshooter

Also read, How to restore lost + found files

Method 4: Use!

For csh or any shell that implements csh history substitution (tcsh, bash, zsh), you can use the! to call the last command that begins with

Method 5: In case of using MAC you can press

Can you join? + R to 0x0C 0x10 0x0d. This will clean up the terminal and run the last command.

That is all you have successfully learned How to repeat the last command in Linux without using the arrow keys But if you still have any questions regarding this article, don't hesitate to ask in the comments section.

R Marketing Digital