How to run the last command as Sudo in Linux

A quick post as I always forget this command, learn how to run the last command again as sudo, to elevate and bypass permissions denied error. ## First command fails with permissions issue dean@veducate # mv openshift-install /usr/local/bin/openshift-install…

veducate header

A quick post as I always forget this command, learn how to run the last command again as sudo, to elevate and bypass permissions denied error.

## First command fails with permissions issue

dean@veducate # mv openshift-install /usr/local/bin/openshift-install
mv: cannot move 'openshift-install' to '/usr/local/bin/openshift-install': Permission denied

## Using the command "sudo !!" will run the last command with sudo, the full command will be outputed

dean@veducate # sudo !!
sudo mv openshift-install /usr/local/bin/openshift-install

## The terminal will return, including any necessary information as part of the command execution.

dean@veducate #

 

Regards

Dean Lewis

Community notes

1 comment

Comments from the original WordPress site are preserved here as a read-only archive.

Healthster

Thank you for this article. It was very useful as I was searching for it from past few time and it helped me a lot. Thanks again.