![]() ![]() ![]() However, it’s always crucial to use these commands responsibly, given the high level of access and control they provide.Even though it appears sa for system administrator is no longer included in the ubuntu variant by default (apt install acct), so I guess I mean logically.Īctually I guess I am showing my age with 'sa' but never used it because at the time 'su' was a more direct approach.ĭoing 'su' directly is not possible as you need the root password but the account is disabled by default. Your choice between the two commands will depend on your specific needs at any given time. In conclusion, while `sudo -i` and `sudo su -` can often be used interchangeably, it’s important to remember that they have slightly different behaviors. This makes sudo -i slightly more efficient. Command Usage: From a usage perspective, `sudo -i` is a single command, while `sudo -i` is a combination of two commands.Command History: With `sudo -i`, commands entered are stored in the root’s command history, whereas `sudo su -` stores commands in the invoking user’s command history.This could lead to subtle differences in command behavior if the two sets of environment variables differ significantly. Conversely, `sudo su -` uses the environment variables of the current user, which are then replaced by those of the root user. Environment Variables: `sudo -i` uses the environment variables of the root user exclusively.Shell initialization files: The commands read different shell initialization files.While `sudo -i` and `sudo su -` both provide a shell with root privileges, they differ in how they handle the user environment: Get the root’s environment variables and also inherit the environmental variables of the su command.ĭifferences Between sudo -i and sudo su.However, `sudo su -` handles the user environment differently than `sudo -i`. ![]() The – after su signifies a login shell, much like `-i` does for sudo. The `sudo su -` command is a combination of sudo and su that aims to mimic a root login shell. Get root’s environment variables (not retaining the user’s environment).Are given the root’s shell (which could be different from your user’s shell, e.g., bash or sh).Switch to the root home directory (/root).This command initiates a new shell session with the environment variables of the root user, including any path updates or user-specific settings. This is similar to a root user logging in to a shell session, hence the `-i` option, which stands for “login shell”. The `sudo -i` command is designed to start a root shell with root’s environment variables. When used without specifying a username, su defaults to switching to the root account. Su (short for “substitute user” or “ switch user“), on the other hand, is a command used to switch to a different user in the system. Instead of sharing the root password with a user who needs to perform a few administrative tasks, you can grant limited root access to that user with sudo. Its primary purpose is to enhance system security. In Unix and Unix-like operating systems, sudo (which stands for “superuser do”) is a command that allows users to run programs with the security privileges of another user (normally the superuser, or root). After this, we’ll dig into the specifics of `sudo -i` and `sudo su -` and outline their differences. To understand these differences, we first need to delve into what sudo and su are and how they function. But while they seem to perform a similar function, the commands `sudo -i` and `sudo su -` have some significant differences under the hood. `sudo` and `su` are two important commands in Unix-based systems like Linux that give you access to administrative tasks. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |