> ## Content Index
> Fetch the complete content index at: https://mfitzp.ghost.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# Execute last command as root
- URL: https://mfitzp.ghost.io/execute-last-command-as-root/
- Published: 2011-11-06T18:45:00.000Z
- Updated: 2023-06-25T18:45:52.000Z
- Author: Martin Fitzpatrick
- Tags: Tutorials, #Import 2024-03-14 08:20, #Import 2026-08-24 14:26

Sometimes you need to re-run a command you just ran, but this time as a super-user. For example, you may have run a command which needed super-user rights, but forgot to prepend the command with `sudo`.

In that case you can make use of the `!!` bash shortcut to re-run the previous command. But helpfully you can *also* prepend the `!!` shortcut with `sudo`. For example, the following will re-run the previously entered command as root user.

```bash
sudo !!

```

`!!` is automatically substituted to the content of the previous command. Turning the above line into `sudo <your previous command here>`.