Linux - Run the last command as root, Refer to command line n

Run the last command as root


Run the last command as root (sudo !-n, n...1,2,3...)

  # sudo !-1

Run the previous command as root

! Start a history substitution, except when followed by a blank, newline, = or (.

!n Refer to command line n.

!-n Refer to the current command line minus n.

!! Refer to the previous command. This is a synonym for ?!-1?.

! string Refer to the most recent command starting with string.

!?string[?] Refer to the most recent command containing string.

^string1^string2^ Quick substitution. Repeat the last command, replacing string1 with string2. Equivalent to ??!!:s/string1/string2/??

The topic on Linux - Run the last command as root is posted by - Patel

Hope you have enjoyed, Linux - Run the last command as rootThanks for your time

Tech Bluff