12

I can't switch to user jenkins on an OpenVZ container. There is still a jenkins process running, which was started by this user.

I tried # su jenkins; it does not switch to the jenkins user. There is no error message.

/etc/groups shows there is a jenkins group: jenkins:x:498:. I tried id -g jenkins and got this: jenkins(uid=497). There is a /etc/passwd entry:

jenkins:x:497:498:Jenkins Continuous Build server:/var/lib/jenkins:/bin/false

Nothing happened to this container. I revisited it some time after it was stopped, I started it and found it in this situation.

So there is a jenkins user. Why can't I switch to it?

2
  • Does /etc/passwd show an entry for user jenkins? Did anything happen that could have caused this user account to be deleted? Do you get any error messages when you run the su command that you posted?
    – dhag
    Mar 31, 2015 at 0:59
  • This is /etc/passwd entry jenkins:x:497:498:Jenkins Continuous Build server:/var/lib/jenkins:/bin/false There is no error if I try to switch using su jenkins, Nothing happened to this container I revisited after some time it was stooped i started it and found in this stituation
    – DevOps_101
    Mar 31, 2015 at 1:07

2 Answers 2

12

The reason su jenkins appears to fail is because the user's shell is /bin/false. You can specify a shell with su that will be used instead of the default login shell:

su -s /bin/bash jenkins
4
  • The standard does not mention a -s option for su and on FreeBSD, -s sets the MAC security label...
    – schily
    Jun 27, 2018 at 10:57
  • Downvoting this, as this didn't worked for me in Ubuntu.
    – daparic
    Apr 12, 2022 at 11:42
  • 1
    @eigenfield My answer assumed the user was already root as indicated in the question. That is why you needed sudo.
    – jordanm
    Apr 13, 2022 at 14:21
  • Feature idea? "su" could make an observation like "Hello root, you're using /bin/bash but (user) is using /bin/false -- How would you like to proceed?"
    – PJ Brunet
    Mar 25, 2023 at 4:00
0

This worked for me:

sudo su -s /bin/bash >username<;
1
  • Upvoting this, as this worked for me in Ubuntu.
    – daparic
    Apr 12, 2022 at 11:41

You must log in to answer this question.

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