Why my MacBook Air terminal uses sh-3.2# instead of my username#? In my MacBook Air Terminal, I have the following prompt:

Zoos-MacBook-Air:~ zdm$


When I type sudo su and then enter my root password, I usually get the same prompt with the # sign as follows:

Zoos-MacBook-Air:~ zdm#


Recently I noticed that when I typed sudo su and then entered my root password, the prompt changed to:

sh-3.2# 


How to change it back to usual?
I don't know why it changed, but you can override sh-3.2# or other default shell prompts by changing the $PS1 variable. To do that, simply run the following command (including the space after the dollar sign):

export PS1='\h:\w \u\$ '


This will replace your shell prompt with Zoos-MacBook-Air:~ root$. However, this change is not persistent and will be gone when you exit or close the Terminal. You can make it persistent by editing root's .bash_profile file. Run the following command while you are in a root shell to modify that file:

echo 'export PS1='"'"'\h:\w \u\$ '"'" &gt;&gt; ~/.bash_profile
echo 'export PS1='"'"'\h:\w \u\$ '"'" &gt;&gt; ~/.profile


or

echo "export PS1='\\h:\\w \\u\\\$ '" &gt;&gt; ~/.bash_profile
echo "export PS1='\\h:\\w \\u\\\$ '" &gt;&gt; ~/.profile


This will make the change persistent.

Tests were made on iOS 11 with root shell, but everything in this answer works on macOS as well.