Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1859  / 2 Years ago, sat, september 3, 2022, 7:29:23

What is wrong with the following?



[cloudera@localhost zookeeper]$ sudo su - zookeeper
[cloudera@localhost zookeeper]$ whoami
cloudera


In response to one of the comments:



[cloudera@localhost zookeeper]$ cat /etc/passwd | grep zook
zookeeper:x:492:488:ZooKeeper:/var/run/zookeeper:/bin/false
[cloudera@localhost zookeeper]$ cat /etc/passwd | grep cloudera
cloudera-scm:x:497:498:Cloudera Manager:/var/run/cloudera-scm-server:/sbin/nologin
cloudera:x:500:500::/home/cloudera:/bin/bash

More From » sudo

 Answers
4

You're trying to su to a user who's shell is /bin/false. /bin/false always exits with code 1, so you're never that user:



$ sudo su - dnsmasq
$ echo $?
1


If you want to start a shell with such a disabled user, use sudo:



$ sudo -u dnsmasq /bin/bash
$ whoami
dnsmasq


Note that dnsmasq usually has /sbin/nologin (a politer version of false) as the shell, so the same principle applies.


[#22168] Sunday, September 4, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ttarum

Total Points: 417
Total Questions: 101
Total Answers: 115

Location: Maldives
Member since Wed, Nov 4, 2020
4 Years ago
ttarum questions
Sat, Aug 20, 22, 12:42, 2 Years ago
Wed, Sep 28, 22, 18:07, 2 Years ago
Mon, Feb 7, 22, 20:23, 2 Years ago
;