Solved

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

Posted on 2016-07-15
3
230 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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