Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Path statements when using the Bash shell UNIX
[Editor's note: See the comments for a good discussion and solution to this question]

I just managed to get bash compiled and running but I have a problem whenever I switch the shell in Terminal.app's preferences.

If I set it to bash, zsh or anything besides tcsh, it seems that I can only use commands from /bin. I mean, I'm missing basic stuff like ping and traceroute. I can su root and copy commands from /sbin or /usr/bin, but this doesn't seem like the right way to go about using my spiffy new shell.

Oddly enough, I can start Terminal with tcsh and then temporarily switch to bash, and everything works perfectly. Tried using chsh, but it launches vi, and vi and I are not on speaking terms.

Need help from someone who knows what the heck I'm doing wrong.

Thanks,
-Jeff K.
    •    
  • Currently 4.25 / 5
  You rated: 5 / 5 (4 votes cast)
 
[6,075 views]  

Path statements when using the Bash shell | 10 comments | Create New Account
Click here to return to the 'Path statements when using the Bash shell' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
bash
Authored by: robh on Mar 27, '01 04:53:29AM

Looks like you haven't got a working PATH. Type 'echo $PATH' in tcsh and bash. The PATH tells the shell where it should look for executables and in what order.

When the shell starts it reads system and user config files which should set various variables, one being the PATH.
If you type "man tcsh" and then look for the section "Startup and shutdown" it'll show you the sequence of files it'll look for. Hunting around I think tcsh's default path for OSX is set with:
set path = (
~/bin
/usr/local/bin /usr/bin /bin
/usr/local/sbin /usr/sbin /sbin
)


You'll need to set the same path from bash. I don't use bash or understand why OSX unix newbies would want to choose bash over tcsh. Bash's syntax is different to tcsh, so whenever you see hints and tips you might have to translate them into bash syntax before you can get started. Apple chose tcsh for a reason, it does the job and is easy to learn. Why use anything else ?



[ Reply to This | # ]
bash
Authored by: geoffsaulnier on Mar 27, '01 11:53:49AM

in your home dir (~) create a file called .profile (or vi it if there already is one) and add, somewhere:

PATH=${PATH}:/usr/bin:/usr/local/bin:/usr/sbin:/usr/sbin/sbin:/usr/ucb:$HOME/bin
export PATH

And that will set your path for any shell that you log in to with bash.



[ Reply to This | # ]
RE: bash
Authored by: Anonymous on Mar 27, '01 02:35:35PM

Looks like it's working fine now. I wrote the following to ~/.profile

PATH=${PATH}:/usr/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/ucb:$HOME/bin
export PATH

instead of:

PATH=${PATH}:/usr/bin:/usr/local/bin:/usr/sbin:/usr/sbin/sbin:/usr/ucb:$HOME/bin
export PATH

I'm assuming that :/usr/sbin/sbin was a typo? I replaced it with :/sbin

And BTW, what's /usr/ucb? I don't see that in my filesystem.


Thanks for all the help!

-Jeff K.



[ Reply to This | # ]
RE: bash
Authored by: geoffsaulnier on Mar 28, '01 11:10:18AM

Yikes, sorry! Been in SunOS land for too long. /usr/ucb is where all the good stuff like the old ps lives.

The sbin stuff was, indeed, a typo.



[ Reply to This | # ]
RE: bash
Authored by: geoffsaulnier on Mar 29, '01 10:19:14AM

that didn't make sense, did it!?!?!

It's where the BSD (ucb = university of california at berkely) stuff lives on SunOS/Solaris. Obviously, on MacOS X, which is BSD, that's what you get anyway.

That makes a little more sense, I hope!



[ Reply to This | # ]
bash
Authored by: trebor on Mar 27, '01 03:19:24PM

Accually Apple did not distribute the bash shell because of confusion over the GPL. They were worried that if they distributed it ALL of OS X would then be covered by the GPL.



[ Reply to This | # ]
tcsh sucks
Authored by: Anonymous on Mar 27, '01 03:23:56PM

See title. Tcsh sucks. It takes the brain-dead csh and fixes a few things to make it work better for shell scripting, better redirection, etc. But bash is from the sh heritage, which is far more consistent from a programming perspective, and is the standard shell scripting language for most things Unix. If you don't like sh or bash, there's always zsh or ksh.



[ Reply to This | # ]
tcsh sucks
Authored by: robh on Mar 27, '01 06:16:49PM

scripting language ?. You can write scripts in any language you want, what you use for a shell is another matter. If I want to write a script I use Perl. I wouldn't think of using tcsh or bash for scripting. If the script is trivial one or two liner then sh or csh will suffice, and if the script is more sophisticated then Perl is the answer.

I've been using unix for about 15 years and have been using tcsh for most of that time. I'd say to newcomers to unix to stick with tcsh. Telling people to switch to and learn bash instead is wasting their time because tcsh will do everything you're going to need in a shell.

Now if Apple hadn't picked tcsh as theyir preferred shell I'd say to people go choose whatever shell they want, they all have their features and religious followers. But since there is an Apple preferred shell, and that shell is a perfectly good one then stick with it.



[ Reply to This | # ]
tcsh/csh vs sh/zsh for scripting
Authored by: Anonymous on Apr 05, '01 02:52:04AM

There is a good article on why tcsh/csh is considered bad for scripting.
This is similar in vein as to why goto's is a bad programming practice:

http://www.landfield.com/faqs/unix-faq/shell/csh-whynot/

Personally, I use sh for scripting and csh for interaction. However, there
are people who prefer to use sh for both purposes, and I can see why. The file
attribute/looping capabilities of sh are superior, so much so that Perl uses
the same syntax.

I don't want this to be another csh/sh, vi/emacs, Mac/PC jihad, but the
bottom line is that unlike the Wintel world, Apple's OS X gives us the choice,
and that's what's important to me.



[ Reply to This | # ]
the many shells, pros & cons
Authored by: cichlisuite on May 06, '01 03:16:53AM

Unix newbie here. Does anyone have a handy reference that outlines the differences between all these different shells? The pro's and cons?
I'm not look for any religious arguements, just facts.

I've been using bash on a friends remote *nix box, and I've gotten more handy with customizing it than I have with tcsh. I'm thinking on making it my default shell on OS X. Also, many of the *nix reference books I have picked up tend to mention bash more often than all the others.

But I'd stil like to make a well educated decision.



[ Reply to This | # ]