10

What does the sudo -i command do and in which situations would it be used. read it using the man sudo command but i'm looking for a more diluted discription to help me understand better.

0

2 Answers 2

11

sudo lets you run commands in your own user account with root privileges. su lets you switch user so that you're actually logged in as root.

sudo -s runs a shell with root privileges. sudo -i does this as well, but also acquires the root user's environment.

This means that login-specific resource files such as .profile, .bashrc or .login will be read and executed by the shell.

5

Basically, you use sudo -i when you know you will be running various commands that need root access and don't want to run each of them with sudo. To illustrate:

$ whoami
terdon
$ sudo -i
[sudo] password for terdon: 
# whoami
root

So, after running sudo -i all subsequent commands you run will be run as though you had run them with sudo. You are now logged in as root and no longer need sudo to gain privileges.

Not the answer you're looking for? Browse other questions tagged .