0

Whenever I attempt to su to root by using su while logged in as a regular user on my Debian machine it silently fails, dumping me back into my original user and shell. While searching for this problem I came across solutions that explained that this behaviour is supposed to happen if the user I attempting to login to has an invalid shell in /etc/passwd, which doesn't seem to be the case, the first line on the file is: root:x:0:0:root:/root:/bin/bash.

The only way I can su to root is with:

su -s /bin/sh

Since it looks like the problem is with the bash installation itself, I tried reinstalling bash with apt-get install --reinstall bash while logged in as root, but the error still persists. How can I make it possible to login to root using bash with just su?

I just noticed that if during the timespan between hitting enter after entering root password and being dumped back into my original user I try hitting ctrl+c, su works and I am logged in as root in bash.

If I'm logged in as root using a shell, and run /bin/bash from there, it returns me a Segmentation fault error.

I tried running /bin/bash -x. It seems to run forever printing /opt/spark//bin:/opt/spark//bin:/opt/spark//bin. When forced to stop with ctrl+c, it runs bash with root user as if nothing happened. strace /bin/bash seems to be showing that the command tries to open /root/.bashrc over and over again until it segfaults.

13
  • Have you checked (with cat -et for example) that there are no trailing non-printing characters (such as a stray carriage return) on the password entry? Commented Mar 9, 2018 at 18:20
  • The first two lines of output of cat /etc/passwd -et are root:x:0:0:root:/root:/bin/bash$ daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin$ Commented Mar 9, 2018 at 18:23
  • Is /bin/bash in /etc/shells? Commented Mar 9, 2018 at 18:29
  • 2
    That's probably the problem; su runs your shell, which segfaults.
    – Jeff Schaller
    Commented Mar 9, 2018 at 18:36
  • 1
    You may try /bin/bash -x to see if there's something in the login profiles that is segfaulting; otherwise, strace could help if bash itself is segfaulting.
    – Jeff Schaller
    Commented Mar 9, 2018 at 18:58

1 Answer 1

5

Your problem stems from an infinite loop in your ~/.bashrc file:

export SPARK_HOME=/opt/spark/ 
export PATH=$PATH:$SPARK_HOME/bin 
source ~/.bashrc

When placed in your ~/.bashrc file, you'll successfully su to the user and run your shell, but you'll never get a prompt.

The minimal fix would be to comment out the source line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .