@ankita.ahuja
Linux Oct 20, 2026

sudo -i vs su, how do I become root properly?

On Ubuntu su asks for a root password that I never set. I've seen people use sudo -i or sudo su instead. What's the right way to get a root shell, and is it a bad habit to work as root?
1

Leave A Reply

Log in to post an answer.

1 Answer

mayurbyte Oct 21, 2026
ankita.ahuja
On Ubuntu and most desktop distros use sudo -i. It asks for YOUR password, gives you a proper root login shell, and every use is logged. su asks for the root account's password, and on Ubuntu root has no password set by default, which is why su just fails there. If you do use su, use su - (with the dash) so you get root's environment and PATH. Plain su keeps yours and you get odd command-not-found stuff. Honestly for most things sudo is better than sitting in a root shell at all.