5

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.

1 Answer 1

4

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

2
  • Thank you for your explanation which is very clear for me to understand!
    – DaeYoung
    Commented Apr 19, 2016 at 21:40
  • 2
    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
    Commented Apr 20, 2016 at 0:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .