Forrest logo
back to the --login tool

sudo:tldr:a3f5f

sudo: Launch the default shell as the specified user, loading the user's environment and reading login-specific files (`.profile`, `.bash_profile`, etc.).
$ sudo --login --user=${user}
try on your machine

The command "sudo --login --user=${user}" is used to switch a user in the terminal to another user account with elevated privileges.

Here is a breakdown of the command:

  • "sudo" is a command in Unix-like operating systems that allows users to run programs or commands with the security privileges of another user (usually the superuser or root).
  • "--login" tells sudo to start a login shell after switching to the desired user. This means that the target user's environment variables, shell configuration files, and other settings will be loaded.
  • "--user=${user}" specifies the user account to switch to. The "${user}" portion is a placeholder that should be replaced with the actual username. For example, if the target user is named "john", the command would be "sudo --login --user=john".

When executed, this command will prompt for the password of the current user (the one executing the command) and, if successful, switch the user to the specified account, setting up a new login session with the target user's environment and privileges.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the --login tool