If you’re a Bash user and you want to add sudo to your last bash command, there’s a few things you need to know. First, the !! syntax is used to indicate that the command should be run as a superuser. Second, the sudoers file contains information about who should have access to which commands. Finally, the sudoers file can be edited using a text editor such as nano or vi. To add sudo to your last bash command, you’ll need to create a new file called sudoers in your home directory. In this file, you’ll need to list all of the users who should have access to the commands listed in the following table. You can use any of these users names as long as they’re listed first in the list. user name Command groupid Command groupid must be one of “root” or “sudo” for this command to work properly! Next, you’ll need to add the following line at the top of your sudoers file:

User specific settings # # This is where you set up permissions for each user # user_name ALL=(ALL) ALL


You have a couple of options, the easiest one is to just use !! to tell bash to use the last command.

For instance, if you tried to type this, you’d get an error that you are editing a read-only file:

Once that happens, then you can just use this command:

Which bash will then expand into this command:

Screenshot of this in action:

An alternative method would be to just hit the up arrow key, hit either the Home key or Ctrl+A, and then type sudo.