1

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

4
  • 1
    Welcome to Ask Different! Have a look at our help center if no one is able to guess what has happened here to provoke a password prompt. My guess would be your dot files are messed up, but it's not clear whether or how you want to proceed to fix them (if that's the case).
    – bmike
    Commented Sep 7, 2013 at 17:51
  • Can't you just edit /etc/profile and remove the lines relating to MacPorts?
    – nohillside
    Commented Sep 8, 2013 at 7:31
  • I deleted that file I believe. Can I somehow just terminate the running sudo command? I am not familiar with Terminal commands. I have tried kill as well as many other commands and however it still reopens!
    – Leon
    Commented Sep 8, 2013 at 18:22
  • Can you please check wether you deleted it, we can't guess how your system looks like. According to the error message in your last screenshot the file is still there and has an error in line 51. If you don't know how to fix this, please upload the file to Dropbox or so and add a link here.
    – nohillside
    Commented Sep 9, 2013 at 7:26

2 Answers 2

1

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.

2
  • Thanks for the answer. If I send you my profile file, could you tell me whats wrong with it? Im quite shure that file is causing the trouble. Or can I reset it somehow? Btw I can't find /Users/username/.bashrc. Is that bad?
    – Leon
    Commented Nov 10, 2013 at 11:07
  • It's okay if there's no .bashrc. But really, just look for any lines containing 'sudo' or 'tee' in them and delete them and save the file back out again. There's no reason for any of those commands to be in your login scripts.
    – fluffy
    Commented Nov 10, 2013 at 18:24
2

What you have is a bad set of shell startup files, so the first thing to do is regain control of your Mac.

  1. Do not log out or reboot (just in case the damage will prevent a new log in - unlikely, but why risk it - especially if you don't have a good backup)
  2. Open System Preferences
  3. Make a new Admin account and enable fast user switching
  4. Save whatever work in other apps you cannot afford to lose
  5. Use the menu bar to log in as the new admin account

At that point, you'll know if that new user has full shell access or if you somehow messed up the files that set up all user shell processes.

You can go about removing MacPorts from the new user as well as be sure you have a good backup before you go in to clear the files that are messing up your current user's shell login process. Since your port install isn't functioning - try to run the port uninstall, but proceed with the manual rm command to actually remove the items in /opt and elsewhere that were installed.

http://guide.macports.org/chunked/installing.macports.uninstalling.html

At that point, you can also try cleaning up files elsewhere - here are the files MacPorts should have changed on you, so you may have to delete all of these and/or recover them from a clean instal or a backup from before when MacPorts touched them:

Depending on your shell and which configuration files already exist, the installer may use .profile, .bash_login, .bash_profile, .tcshrc, or .cshrc.

The cleaning for you might also involve:

cd /Users
sudo -s
cd broken
tar -cvf ./bash_broken.tar .bash*
rm -i .bash*

That will make a backup tar file of all your broken bash startup files (.bash_history, .bahsrc, etc…) Be careful with the sudo - if you rm the wrong file, there is no trashcan or undo. The -i flag will have rm ask you if you want to delete each file. You want to remove pretty much all of them except maybe the history file (so you can look back at what you did in the past if needed).

Once you've removed the files, log out of the new user and back into the old user and see about whether that fixed your terminal problems.

7
  • 1
    Terminal has been in the described state since approximately 1 year and i can log in
    – Leon
    Commented Sep 7, 2013 at 18:31
  • Perfect - it was more for someone else. I'll add the steps for you to do once you have a terminal prompt. You could also do these steps in single user mode.
    – bmike
    Commented Sep 7, 2013 at 18:33
  • Can you give me more details on which files I have to delete? Thanks for your quick answer btw.
    – Leon
    Commented Sep 7, 2013 at 19:19
  • Your default shell should be bash - so focus on deleting them. It's unlikely you have a .profile - rename that and any of the other files if you have doubts rather than deleting all the dot files I listed above.
    – bmike
    Commented Sep 7, 2013 at 20:29
  • So I followed the steps and deleted the files you listed. Additionally deleted history file (I have it backed up). However terminal still always opens the command. I really don't care if MacPorts is install only half. Is there some way to terminate the command that just does't go away? :DD its been quite annoying when I really need to use terminal.
    – Leon
    Commented Sep 7, 2013 at 22:14

You must log in to answer this question.

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