PDA

View Full Version : Help!!! Lost All Terminal Commands!!!




Oipiah
Jun 6, 2011, 05:40 PM
You're all gonna laugh, but I have been modifying the ~/.profile , /etc/paths , and /etc/paths.d files, and now none of the unix commands work in the terminal except for cd (as far as I can tell.) I don't think it was modifying the ~/.profile that did anything because I have been told that that file is initially blank. Could someone please tell me which file I modified that screwed everything up and also how to get that file back to normal?

Thanks!
Cody



Oipiah
Jun 6, 2011, 05:41 PM
Also, when I open terminal this is printed
dirname: illegal option -- b
usage: dirname path
basename: illegal option -- b
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]

Hansr
Jun 6, 2011, 05:52 PM
What did you do exactly and what made you want to mess with /etc/paths????

jiminaus
Jun 6, 2011, 05:56 PM
After you open terminal, try entering this command.


export PATH=/usr/bin:/usr/sbin:/bin:/sbin


This should restore access to the commands temporarily.

The errors look like issues with the commands in your ~/.profile and/or ~/.bashrc files.

It's after horse has bolted, but whenever you playing around with kind of stuff, leave a second Terminal window open before you start. Then when you break your bash environment, you can use the second Terminal window to fix it.

It might also be wise to have a second tab in the second window running sudo -s just in case you need Admin privileges to fix the break.

Hansr
Jun 6, 2011, 05:58 PM
Dunno if sudo will still work but you can open a text editor with sudo "/Applications/TextEdit.app/Contents/MacOS/TextEdit" and open /etc/paths and set it to the original paths:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

Export additional via your ~/.profile with EXPORT PATH = $PATH:/path/to/bin
not by editing the system defaults.

By default /etc/paths.d/ should only contain X11 with the content:
/usr/X11/bin

Oipiah
Jun 6, 2011, 05:59 PM
Thank You! that worked! I was messing around with /etc/paths b/c I was told that was the way to hard-wire in aliases. However, I have still not been able to get that to work. Any suggestions?

jiminaus
Jun 6, 2011, 06:02 PM
Thank You! that worked! I was messing around with /etc/paths b/c I was told that was the way to hard-wire in aliases. However, I have still not been able to get that to work. Any suggestions?

WTF. That's soooo not the way to do that.

Aliases should be put into ~/.bashrc. ~/.profile should source ~/.bashrc at the top.

BTW I've assumed you're talking about Bash aliases, not Finder aliases.

Hansr
Jun 6, 2011, 06:07 PM
Just for illustration a real example of a additional path being added and an alias being added:

Hansi:~ hansi$ cat .profile
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
alias showListeners="lsof -i -P | grep LISTEN"