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

# Run the last shell command with sudo
- URL: https://til.codes/run-the-last-shell-command-with-sudo/
- Published: 2016-02-16T09:59:15.000Z
- Updated: 2016-02-16T09:59:15.000Z
- Author: Manu Ajith
- Tags: shell, bash, terminal, sudo, #Import 2024-07-13 21:01

I often an into the situation where I type in a long command, hit enter and then figure out that I needed to run that command as root user. Instead of typing the same command with sudo prefixed we can do the same thing using a shortcut.

To run the last command 'as is', you can just do

```
$ !!

```

If you want to run it as root, with sudo; just do

```
$ sudo !!

```

Hope you find it useful.