Jenkins run as non root user

In this tutorial, How do I Jenkins run as a non-root user in Linux? Jenkins the essential for DevOps Roles.

Jenkins run as a non-root user

To change the Jenkins user, Open “/etc/sysconfig/jenkins” file. Changing JENKINS_USER variable and Make sure user exists in your system.

The default, JENKINS_USER is Jenkins USER as below

[root@DevopsRoles ~]# cat /etc/sysconfig/jenkins | grep JENKINS_USER
JENKINS_USER="jenkins"

Changing JENKINS_USER to huupv USER.

[root@DevopsRoles ~]# sed -i -e 's/JENKINS_USER\="jenkins"/JENKINS_USER\="huupv"/g' /etc/sysconfig/jenkins

The screen output terminal:

[root@DevopsRoles ~]# cat /etc/sysconfig/jenkins | grep JENKINS_USER
JENKINS_USER="huupv"

The changing ownership Jenkins home

[root@DevopsRoles ~]# chown -R huupv:huupv /var/lib/jenkins 
[root@DevopsRoles ~]# chown -R huupv:huupv /var/cache/jenkins
[root@DevopsRoles ~]# chown -R huupv:huupv /var/log/jenkins

The restarted Jenkins and check user has changed with ps command.

[root@DevopsRoles ~]# /etc/init.d/jenkins restart
[root@DevopsRoles ~]# ps -ef | grep jenkins

The screen output terminal:

Jenkins run as non root user

Conclusion

Thought the article, you can use Jenkins run as the non-root user as above. I hope will this your helpful.

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.