Solved

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

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
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.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

749 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