0

I am confused about the difference between running a command as "user1" in a terminal and running a command as "sudo -Hiu user1 [command]".

If I run /home/user1/script.sh , the script successfully calls a program that accesses GNOME/Keyring and the program gets the password without any issues.

However, if I run sudo -Hiu user1 /home/user1/script.sh, the program the script calls fails to access GNOME/Keyring successfully.

What is the difference between executing commands as user1 and running sudo -Hiu user1 [command] and how can I fully change users from e.g. root to user1 in bash?

0

There is essentially no difference between running sudo -Hiu user1 [command] versus running [command] as user1 (or even running sudo [command]), although there are some subtle differences (as mentioned in your question). Most of these are related to GNOME, which can be circumvented by using the gksudo command (or on newer systems, using admin:///full/path/to/command arguments or pkexec [command] arguments).

You can use su user1 as root (or as any other user if you know the password) to run a shell as user1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.