Using chsh


Using chsh

In our discussion of shells earlier in this book, we have talked many times about either what shell you are using or what shell prompt commands you can perform. We have also touched on why you may want to change your shell, and now we will cover how to do just that within your Unix environment.

In the beginning of this book, you learned that there are a variety of different shells that you can run; we covered most if not all of them. There will be times when you will want to change your shell, and to do that, you can use the change shell command, or chsh. The chsh command will allow you to choose one of the shells that is registered for use on your machine. This means that you must have a shell on your system in order to request it.

One problem you may encounter is not knowing which shell to choose; after all, there are so many shells, and how do you know which ones are registered for use on your system? To help solve this problem, you can use the chsh command with the l option. The chsh l command will list out all the available shells on your system. After using chsh l, changing shells is as easy as running the correct command and knowing what syntax to use.

 >chsh -l /bin/ash /bin/bash /bin/csh /bin/ksh /bin/sh /bin/bsh /bin/tcsh /bin/zsh 

In this example, there are eight different shells that you can choose from. If you wanted to change to the bash shell from your current shell, you would do the following:

 >chsh Changing shell for rob. Password: ***** New shell [/bin/csh]: /bin/bash Shell changed. 

The next time you logged in to your machine, you would be in the bash shell instead of your previous shell. You probably won't ever need to change your shell unless the default shell on your system is not able to do what you want it to.

The Shell Game Changing your shell is easy, but it all depends on your distribution of Unix or Linux and how it is set up. In some distributions, you may find yourself locked out of your session if you make a mistake. Again, this illustrates the need to practice on a Unix system that you are not working on just in case you do make a mistake and wind up in a jam. There is absolutely no shame in asking for help if you don't know what you are doing. Practice makes perfect, so I suggest getting yourself a lab system and changing into all the shells just to see how to do it.


Now that you have changed the default shell in your Unix system, you can either keep it that way or change it back. For the next portion of the lesson, you should be in the shell most comfortable to you. If you changed into a shell you are not familiar with, you should change back to the shell that you usually work in so that you can follow the rest of the lesson's exercises.



    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net