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

# Never Re-Type a Command Again — Use (sudo !!)
- URL: https://snubmonkey.com/never-re-type-a-command-again-use-sudo/
- Published: 2025-07-01T21:12:50.000Z
- Updated: 2025-07-05T21:01:52.000Z
- Description: Tired of retyping commands when you forget sudo? Use sudo !! to instantly rerun the last command with elevated privileges. It’s a simple bash trick that saves time, avoids frustration, and keeps your terminal workflow smooth. A must-know for every Linux user.
- Author: yannick Coffi
- Tags: how to 🪄, linux 🐧, shell 🛠️

Ever run a command, only to realize you forgot sudo? Instead of retyping it, use this **life-saving shortcut**:

```zsh
$ sudo !!
```

Let's walk through what it does — and why you'll love it.

## **What Is !!?**

The `!!` is a bash history expansion trick that stands for:  
The last command you ran.  
  
So when you type:

```zsh
$ sudo !!
```

It becomes:

```zsh
$ sudo <your_last_command>
```

## **Real-World Example**

You try to install something:

```zsh
$ sudo apt install nginx
```

Oops — permission denied:

```zsh
E: Could not open lock file /var/lib/dpkg/lock-frontend - Permission denied
```

Instead of retyping everything:

```zsh
$ sudo !!
```

Boom. It reruns:

```zsh
$ sudo apt install nginx
```

And this time — it works.

## **Why This Rocks**

- Saves time
- Prevents typos
- Keeps your terminal flow clean

## **⚠** Head**\-up!**

- This works in **bash**, **zsh**, and similar shells.
- Be cautious: !! repeats whatever your **last command** was — know what you’re re-running!
- To see history: run history or press the up-arrow key ↑.
  
  
We hope you found these insights useful!