Real Shells at USC

I will start with a few questions, then the how-to.

FAQ

1. Why is my shell this strange C Shell? Is that a Solaris thing?
No, it is NOT a Solaris thing. Default shell in Solaris is Korn (i.e. ksh), or Bourne (i.e. sh) for root.

Your shell is C Shell because someone somewhere at sometime decided to make C Shell the default USC Shell. As of Fall 2004, all new accounts get tcsh. In some instances, if you fall into a situation where ISD puts you into forcepasswd (a shell requiring you to change your shell), you may get tcsh when you change your password instead of tcsh. tcsh is much better than csh, but they are both evil. See csh considered harmful.

2. Why run a bourne shell derivitive?
Bourne Shell is THE industry-standard UNIX shell. Period. It is still often the default shell in many unices. It's a good thing to know. C Shell was written at a time when Bourne was lacking many features, and it only added a few. Since then many Bourne-compatible shells have come out, and you should use these.

On top of that, all the system scripts are written in bourne -- so you have to know it anyway. Why learn two completely different shell syntaxes when you don't have to? bash/ksh/zsh can do everything tcsh/csh can do and more.

3. So why not just use Bourne?
Bourne is feature-lacking. We now have several other Bourne-derivitives, the most popular of which are Bourne Again (Bash) and Korn shell (ksh).

For a user shell either is good. I prefer bash because of a few extra keys that make things easier for me to use.

From a programming standpoint, Korn used to be my choice because of it's math support, but bash now has this. I try to program in bourne when possible, but graduate to bash for more complex scripts.

HOW TO


Ok, so how do you go about running a real shell at USC?

FOR BASH
  1. Create a .bash_profile and a .bashrc
  2. Go ahead and translate your .login to .bash_profile and your .cshrc to .bashrc
    The idea here is that .bash_profile has everything fundamental like PATH, MANPATH, MAIL, and BASHENV, while bashrc has aliases and user functions.
  3. If you are new to this and don't have any customizations in your .login and .cshrc I have provided very simple .bash_profile and .bashrc
  4. Inside the .bash_profile under MAIL, change j/jdibowit to the first letter of your username, slash, your username, so if you are ttrojan you would use t/ttrojan
  5. Open a new Secure Shell window (if you are using telnet, STOP, and use OpenSSH (if you are in unix), Putty or Cygwin (if you are in windows), or one of the Mac SSH clients if you are in Mac. While this process will work regardless of whether you use telnet or Secure Shell, telnet is stupid and sends your password in plain text across the internet. Additionally, I'm disabled telnet and FTP in mid-2005.).
  6. In the new window type exec /usr/usc/bin/bash -login
  7. Test everthing, if that works, use chsh to change your shell permentantly. Keep that window open until it takes effect, and you've tested logging in in another window. Once that works, you may close your csh/tcsh window.

FOR KSH
  1. Korn uses the same login file as Bourne: .profile
  2. Since you already have a .profile, I'm not going to provide one. You can (A) translate the stuff from your .login and .cshrc and stick it in your .profile, or you can (B) look at my sample .bash_profile and copy relevant parts (all of it except the bashrc and BASHENV parts) into your .profile
  3. Inside the .bash_profile under MAIL, change j/jdibowit to the first letter of your username, slash, your username, so if you are ttrojan you would use t/ttrojan
  4. You can put aliases in .profile, OR you can create a .kshrc file and change the .bashrc lines from my .bash_profile to a file called .kshrc, and you know have a seperate file for them
  5. Open a new Secure Shell window (if you are using telnet, STOP, and use OpenSSH (if you are in unix), Putty or Cygwin (if you are in windows), or one of the Mac SSH clients if you are in Mac. While this process will work regardless of whether you use telnet or Secure Shell, telnet is stupid and sends your password in plain text across the internet.).
  6. In the new window type exec /usr/bin/ksh -o emacs
  7. Test everthing, if that works, use chsh to change your shell permentantly
  8. You might want to add set -o emacs to your .profile to get emacs-like keys if it doens't happen automatically
FOR BOTH
I highly recommend you read Phil Brown's KSH Tutorial. It provides VERY valuable information.

Other Things

You will invariably run into problems if you have class-specific software you have to run. For example in EE102L we have to run powerview. In order to run it in Bash, I had to port some EIGHT C Shell scripts. As a student, I gave up and used the following wrapper:
#!/bin/tcsh

source .login
source .cshrc
setenv TERM xterm
cd ~/pv/ee457
dash &
This wrapper is for epd, but the idea is the same. However, if you find some software that has a setup.csh script but not a setup.sh, let me know, and I'll make sure one gets there.