Score:2

Is sudo -u username command the same as doing sudo -i -u username then command?

cx flag

Is a terminal prompt sudo -u username command

same as doing

sudo -i -u username then command in the next line?

If no, what is the differences? What are the use cases when doing the first is better or preferable than doing the later and vice versa.

If anyone could explain what the command do step by step or parameter per parameter, that is even better.

Score:2
by flag
sudo -u username command:

This command runs the specified command as the specified username. It does not change the current working directory or the environment variables

sudo -i -u username:

This command opens an interactive login shell as the specified username. It changes the current working directory to the home directory of the specified user and sets up the environment variables as if you were logging in as that user.

Basically sudo -u username command is better for running a single command as another user without changing the environment or creating a new shell whereas sudo -i -u username is better for running multiple commands in a new shell with the environment of the specified user.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.