Restore .bash_profile?

mtaplits

Registered
Hi there,

I needed to add a directory to my path. I opened terminal and vi .bash_profile. I was suprised to see it was a new file and there didn't appear to be an existing .bash_profile. Anyways, being a new MAC user I figured that was ok and I added a line to put a directory in my path.

I save the file. Now the directory is in my path..good. However, basic commands like ls etc don't work! Command not found. It appears to me as though I've overwritten my whole .bash_profile now.

I called tech support to find an original copy of the .bash_profile but they don't support terminal users apparently. Can anyone assist by telling me how I can restore my .bash_profile or point me to an original copy? Or perhaps this isn't the problem and someone can offer a suggestion.

Appreciate the help,
Marshall
 
I think you'll find the problem is that the default shell you're running isn't BASH. By default, on the current version of Mac OS X, the Terminal opens in TCSH unless you specify otherwise in your user account in Netinfo Manager. Since its not running bash, its not even using the .bash_profile.

You have two options. You can edit the .tcshrc which is the TCSH equivalent of .Bash_profile, or if you really would rather use BASH, you can go into Applications/Utilities/Netinfo Manager, find your user account and change the default shell to bash. I believe you can also change the shell in the Terminal preferences somewhere, as well.
 
as a user, you need to create a .bash_profile in your /Users/<home> directory.
When you start up a shell, global paths are included: to add a path you merely append to the PATH environment variable like:

export PATH=$PATH:./
 
symphonix said:
I think you'll find the problem is that the default shell you're running isn't BASH. By default, on the current version of Mac OS X, the Terminal opens in TCSH unless you specify otherwise in your user account in Netinfo Manager. Since its not running bash, its not even using the .bash_profile.

You have two options. You can edit the .tcshrc which is the TCSH equivalent of .Bash_profile, or if you really would rather use BASH, you can go into Applications/Utilities/Netinfo Manager, find your user account and change the default shell to bash. I believe you can also change the shell in the Terminal preferences somewhere, as well.

the default shell was changed in 10.3. Only users who've upgraded from 10.2 to 10.3/10.4 have tsch as their default shell.

I believe to change your shell using Terminal you can use:

$ chsh -s /bin/bash

or

$ chsh -s /bin/bash $LOGNAME

I'm pretty sure the last one works.
 
Weird as I'm running OS X 10.3.9 and the default shell for root is set to sh (bash) as seen from the netinfo manager. I've changed my profile shell default to tsch using the netinfo manager.

I'm wondering if I change the root shell to tsch how much damage is that likly to do in terms of path statements? If I examine my set command as root (su) but from within my profile it gives me the same path in bash and tsch (tsch is set as shell). Why does the root profile as seen from netinfo manager show as bash if this is the case?

But what i really want to know is;

1. how do I set my aliases file so that the shell permanently reads from it. I can't edit the my etc/csh.login file and add in the commands I want as it gives me a read only error. I can use chmod I guess but am unsure if this is the right thing to do.

As you can tell I'm new to unix (background is dos and wondoze) so I expect that the questions are pretty obveous if you know the answers...
 
I'm not a bash guru but I just dealt with the same issue. I put the aliases in the new file .bashrc in my home directory. I also had to put in:

export MANPATH=/usr/share/man:/usr/
 
I'm not a bash guru but I just dealt with the same issue. I put the aliases in the new file .bashrc in my home directory. I also had to put in:

export MANPATH=/usr/share/man:/usr/X11R6/man

so that man would work. Look at the bash man page (type 'man bash' from a terminal window). There is a section in it that explains which files are read in what order when you start a login shell.
 
Hi there,

I needed to add a directory to my path. I opened terminal and vi .bash_profile. I was suprised to see it was a new file and there didn't appear to be an existing .bash_profile. Anyways, being a new MAC user I figured that was ok and I added a line to put a directory in my path.

I save the file. Now the directory is in my path..good. However, basic commands like ls etc don't work! Command not found. It appears to me as though I've overwritten my whole .bash_profile now.

I called tech support to find an original copy of the .bash_profile but they don't support terminal users apparently. Can anyone assist by telling me how I can restore my .bash_profile or point me to an original copy? Or perhaps this isn't the problem and someone can offer a suggestion.

Appreciate the help,
Marshall

I made a similar mistake and spent quite alot of time trying all sorts of fixes. In the end it was quite simple. simple put get a text editor which has a view hidden files option (BBEdit is an example) . Open your text editor, then navigate to your home directory (this is the directory identical to your username) once you open that, you will see you .bash_profile file. Select it and edit away (dont forget to make a backup ;) )
 
Wow, I believe I just hosed myself up as well. I used to have a .bash_profile in which I exported a couple of things. I just finished installing MySql and added the path to the it in the profile. Long story short, I can't issue an "ls" command, I can't issue a "vi" command. This is what my path looks like,
"/usr/local/mysql-5.1.44-osx10.6-x86_64/bin.:/usr/local/mysql/bin." and for the life of me I can't remember what the original path looked like.
I would appreciate any help I can get. I can't run any commands other than the change directory and the "pwd" but I can't do a directory listing.

Thanks in advance

Javier
 
I was able to correct my problem. I created a new account and I checked to see what the new account contained on the PATH variable. I then re-set my PATH to the correct values. Just in case anyone is interested or has the same problem, OS X (10.6.2) the default path should look like this:
"/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin". Should you want to add to it, the correct way to do it would be something like this:
export PATH=$PATH:your new path goes here...."
 
Back
Top