To repeat commands you can normally use the old csh! history operator “!!” (without quotes) for the most recent command, if you want to just repeat the prior command then you can use !-2, !foo for the most recent starting with the subsrting “foo.” You can also use the fc command or just use :p to print the history operator suggestion.

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

Let’s see some of the ways to recall commands at the shell prompt:

How to repeat the last command in Linux without using the arrow keys Method 1: For csh or any shell implementing csh-like history substitution Method 2: Use Emacs key bindings Method 3: Use CTRL + P then CTRL + O Method 3: Using the fc command Method 4: Use ! Method 5: In case of using MAC you can the key

Method 1: For csh or any shell implementing csh-like history substitution

Note: !! or !-1 will not auto expand for you and until you execute them it might be too late. If using bash, you can put bind space:magic-space into ~/.bashrc then after the command press space will auto expand them inline.

Method 2: Use Emacs key bindings

Most shells that have a command line edition feature that supports Emacs key bindings: Also Read: Fix Bash Syntax Error Near Unexpected Token

Method 3: Use CTRL + P then CTRL + O

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

Method 3: Using the fc command

Also read, How to Restore files from lost+found

Method 4: Use !

For csh or any shell implementing csh-like history substituion (tcsh, bash, zsh), you can use the ! to call the last command beginning with

Method 5: In case of using MAC you can the key

You can bind ?+R to 0x0C 0x10 0x0d. This will clear the terminal and run the last command. That’s it 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 post feel free to ask them in the comment’s section.