Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

what does this command mean "sudo su - -s /bin/bash jenkins"

Posted on 2016-07-15
3
Medium Priority
?
393 Views
Last Modified: 2016-07-15
I couldn't understand what this command does "sudo su - -s /bin/bash jenkins". Is it log in as jenkins user under the current shell?



root@monitor:/home/jyu$ su - jenkins
su: user - does not exist
root@monitor:/home/jyu$ cat /etc/passwd | grep jenkins
root@monitor:/home/jyu$ sudo su - -s /bin/bash jenkins
Last login: Fri Jul 15 17:17:09 UTC 2016 on pts/1
[jenkins@monitor ~]$ whoami
jenkins
[jenkins@monitor ~]$ ls -alth
total 56K
-rw------- 1 jenkins jenkins 8.5K Jul 15 17:44 .bash_history
drwx------ 2 jenkins jenkins 4.0K Jul 15 16:55 .ssh
drwxr-xr-x 4 jenkins jenkins 4.0K Jul 15 16:55 .
-rw------- 1 jenkins jenkins  11K Jul 15 16:55 .viminfo
drwxr-xr-x 8 root    root    4.0K May 27 22:26 ..
drwxr-xr-x 3 jenkins jenkins 4.0K Jul  8  2014 .java
-rw-r--r-- 1 jenkins jenkins   18 Jul  3  2014 .bash_logout
-rw-r--r-- 1 jenkins jenkins  124 Jul  3  2014 .bashrc
-rw-r--r-- 1 jenkins jenkins  171 Jul  3  2014 .kshrc
-rw-r--r-- 1 jenkins jenkins  176 Jul  3  2014 .bash_profile
[jenkins@monitor ~]$
0
Comment
Question by:Jason Yu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 41713260
You're using "sudo" to run the command "su" (substitute user) as root, with the parameters
"-" (start a login shell),
"-s /bin/bash" (use /bin/bash instead of the default shell)
"jenkins" (substitute user jenkins).

So yes, basically you're logging in as jenkins, starting bash as a login shell.

I assume that "su - jenkins" doesn't work saying "user - does not exist" because in your environment "su" is already an alias for "su -".

Run "alias su" to verify"

"su" works after "sudo" because sudo doesn't observe alias settings.
0
 

Author Comment

by:Jason Yu
ID: 41713267
Yes, you are right. In my environment, su is an alias of "su -".

root@monitor:/home/jyu$ alias su
alias su='su -'
root@monitor:/home/jyu$
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 41713269
That's why "su - jenkins" throws an error.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question