3

Could someone kind enough explain to me what this command means?

sudo su -s /bin/bash - foo

I was told that if I want to switch to a different account in this case "foo" without knowing its password use this command.

2

sudo is a command that executes whatever command follows as another user (if no username is given like in this case, that user is root) - to be able to do this, the account from which sudo is being executed needs to have the necessary permissions setup (see /etc/sudoers)

su starts a new shell under a different user id

-s /bin/bash specifies the shell to be started, i.e. /bin/bash

- makes that shell a login shell

foo is the user with whose user id and group id will the new shell be started

  • Thank you for your explanation which is very clear for me to understand! – DaeYoung Apr 19 '16 at 21:40
  • 1
    it's also overly long. If sudo is configured to let you run any command as any user, you can just use sudo -u foo -i – cas Apr 20 '16 at 0:53
0

I guess it would use your sudoer ability to get a bash with the foo user.

It wouldn't require foo's password because with sudo you are using root's permissions or something.

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.