MacOS – How to terminate the running sudo command that always reopens

macosterminal

When i open a new window in terminal i get this: !
enter image description here

I was trying to install MacPorts approximately a year ago and that did not go well.

Since i don't use terminal very often I just left it that way.

Now I would like to have it working again!

I tried to delete the com.apple.terminal.plist file and I am stuck.

When I enter my password the shell turns from sudo to tee and everything I enter is just repeated!

enter image description here

When I don't enter my password I get a useable shell.
What can I do to prevent the sudo command from reopening?
enter image description here

Best Answer

First of all, there are a number of commands you can try to break out of whatever weird shell state you're in. Ctrl+C, Ctrl+Z, and Ctrl+\ may exit the sudo command, and Ctrl+D would exit the 'tee.' Assuming the command is not running as your controlling shell (which it probably isn't, judging by how not entering your password gives you a shell), one of those will likely get you back to your actual shell (e.g. bash). Then you should look at the following files to see what's putting you in that state:

/etc/profile
.bashrc
.login
.bash_profile
.profile

You can also edit those files from any OSX text editor (rather than having to get into a shell to do it), although it's a bit tricky - from the "file open" dialog, press Cmd+Shift+G and then type the full path to it (i.e. /etc/profile or /Users/username/.bashrc).

It's also possible that your login shell itself may have been changed in some way. In that case, you need to go to the Users & Groups system preferences, then ctrl-click on your username, then select "Advanced Options." Ensure that the "login shell" dropdown reads /bin/bash.