Solved

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

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now