There is actually a significant difference, as shown in your results. sudo -i or sudo su - start a login shell as root, whereas sudo -s or sudo su start a non-login shell.I prefer sudo -i instead. It achieve the same result, but runs one less process
A login shell will have its environment reset to the defaults for the root user, and its initial working directory will be /root/. A non-login shell will inherit some of its environment (exactly how much depends on distribution, and sudoers configuration), and its working directory from the unprivileged user.
sudo -i may be safer for beginners, because there is less risk of root ending up owning files in the user's home, but sudo -s is often more convenient.
Statistics: Posted by jojopi — Mon Jun 02, 2025 10:58 pm