This guide explains how to run the last command issued, but as root. It should work correctly on all Linux / Unix / BSD operating systems.

Run the last command as root (superuser)

   

Introduction

I can't tell you how many times I've run a command only to receive the notification that I didn't have sufficient privileges. That or I've setup a large ./configure && make command with 20 options only to have it fail because I accidentally forgot to run the command as root. Oops.

Luckily all you need to remember are two little exclamation marks to save yourself some time.

The following will run the last command you entered again, but as root

sudo !!