As root I would like to login as a service user (jenkins - the CI server) and manipulate files with its user,group and umask settings.

Normally I would (as root) do sudo -i -u jenkins, or even su - jenkins. However jenkins' default shell is /bin/false, which exits immediately.

Is there a way to login as Jenkins but specify a different shell to use? Do I really have to change jenkins' shell in /etc/passwd/?

link|improve this question
feedback

3 Answers

up vote 5 down vote accepted

su on linux supports setting the shell with the --shell option

su jenkins --shell=/bin/bash

You will need to su as root for this to work. From the man page:

       If the target user has a restricted shell (i.e. the shell field of
       this users entry in /etc/passwd is not listed in /etc/shell), then
       the --shell option or the $SHELL environment variable wont be taken
       into account, unless su is called by root.
link|improve this answer
feedback

Have you read the manual page (or --help output) to the su command?

su -s /bin/bash -
link|improve this answer
feedback

How about:
su - jenkins -c /bin/bash

or

sudo -u jenkins /bin/bash

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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