Both commands:
sudo -i -u username
sudo su - username
Will log me in as username
if I enter my password. Is there actually any difference between these commands?
sudo vs su Both su and sudo elevate privileges assigned to the current user. The main difference between the two is that su requires the password of the target account, while sudo requires the password of the current user.
The sudo (superuser do) command is a command-line utility that allows a user to execute commands as the root or a different user. It provides an efficient way to grant certain users the appropriate permissions to use specific system commands or run scripts as the root user.
sudo (superuser do) allows you to configure non-root users to run root level commands without being root. Access can be given by the root level administrator through configuration of the /etc/sudoers file.
Sudo (superuser do) is a utility for UNIX- and Linux-based systems that provides an efficient way to give specific users permission to use specific system commands at the root (most powerful) level of the system. Sudo also logs all commands and arguments.
The su
command stands for "substitute user", and allows you to become different user(super user).
sudo su
changes the current user to root but environment settings (PATH)
would remain same. It allows user who have permissions to execute a command as the superuser or another user, as specified in the sudoers
file.
With sudo -i
you get a clean root shell.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With