Ubuntu – the functional difference between sudo su and sudo -i

command linesudo

Why is one preferred over the other in this example?

sudo su
echo "options iwlwifi 11n_disable=1" >> /etc/modprobe.d/iwlwifi.conf

Please provide links to Ubuntu documentation.

Best Answer

The sudo su command stands for "switch user", and allows you to become another user. It allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.

The ‑i (simulate initial login) option runs the shell specified by the password database entry of the target user as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution via the shell's ‑c option. If no command is specified, an interactive shell is executed.