This question already has an answer here:

As far as I know the following command is supposed to make me root:

su -i

Nevertheless, when I type it in Ubuntu 17.04 Zesty Zapus, I get the following message:

su: invalid option -- 'i'
Usage: su [options] [LOGIN]
  -c, --command COMMAND         pass COMMAND to the invoked shell
  -h, --help                    display this help message and exit
  -, -l, --login                make the shell a login shell
  -m, -p,
  --preserve-environment        do not reset environment variables, and
                                keep the same shell
  -s, --shell SHELL             use SHELL instead of the default in passwd

I remember it was working some time ago. How do I re-enable it?

marked as duplicate by mikewhatever, karel, Yaron, David Foerster, Eric Carvalho Sep 18 '17 at 11:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


I remember it was working some time ago. How do I re-enable it?

You were almost certainly using sudo -i before, since su doesn't support an -i option, and it has not supported such an option even in earlier releases. (Just to be sure, I've double-checked this on 16.04 LTS.) You can still use sudo -i.

On a system where root logins are enabled, you can enter su and authenticate with root's password. This gives you a root shell but it does not simulate a login shell. It is similar to sudo -s (or sudo --shell), which works even when the root account is disabled. With sudo, you use your own password. In the default configuration, you must be an administrator--i.e., a member of the sudo group--to use it.

Similarly, if you can log in as root then you can also simulate a root login with su - (or su -l, or su --login). Passing the - flag to su sets environment variables similar to those that would be set in root's login environment and starts a login shell. It is similar to sudo -i (or sudo --login).

The most common way to use sudo is to run just a single command, just by running sudo command args.... This can also be done with su by passing the -c flag, but it is awkward because the whole command including its arguments have to be quoted so it is passed as a single command-line argument to su: su -c 'command args...' (If you're not passing any arguments to the command, and the command name itself doesn't require quoting, then the quotes may be omitted.)

I mention all this not to provide a complete guide to sudo, and I recommend man sudo, RootSudo, this thread, this question, the tag wiki, and the upstream site for more information. Aside from showing the commands you are most likely to want, my main point is that even to do similar things, sudo and su use quite differently named short-form options, including for --login. If you ever ran a command to get a root shell, and you passed -i, that command was most likely sudo.

Not the answer you're looking for? Browse other questions tagged or ask your own question.