0

If I as a non-root user (but in the sudoers file) do sudo -i, I get root privileges:

laptop:~$ sudo -i
[sudo] password for bjmgeek: 
laptop:~$ whoami
root
laptop:~$ id
uid=0(root) gid=0(root) groups=0(root)
laptop:~$ 

But, notice the prompt still shows a $ (which typically means a normal user), not a # (which typically means root).

If, however, I do sudo su -, I also become root, but get the # prompt:

laptop:~$ sudo su -
-bash-5.2# whoami
root
-bash-5.2# id
uid=0(root) gid=0(root) groups=0(root)

According to the man page, su - starts the shell as a login shell. And, according to the man page, sudo -i starts the shell as a login shell. So, what's the difference that one gets the prompt, with a #, and one gets the prompt with a $ ?

This is on a Debian system, but I don't think there's anything debian-specific about the su or sudo commands.

I wonder if it is specifically related to \$ which should show a # for root, and a $ for non-root users.

Update: $PS1 for sudo -i is set to \h:\[\e[1;34m\]\w\[\e[0m\]$ instead of ending in a \$, so that's the cause of the problem. Now I just need to comb through all my files to see what's not setting it correctly.

0 Answers0