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/?


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.

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

su -s /bin/bash -

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


sudo -u jenkins /bin/bash

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.