Monday, November 5, 2012

V7/x86: Changing the User's Shell

"And in her ears the little Seashells, the thimble radios tamped tight, and an electronic ocean of sound, of music and talk and music and talk coming in, coming in on the shore of her unsleeping mind. The room was indeed empty. Every night the waves came in and bore her off on their great tides of sound, floating her, wide-eyed, toward morning. There had been no night in the last two years that Mildred had not swum that sea, had not gladly gone down in it for the third time." - Fahrenheit 451 by Ray Bradbury
The default shell in Unix V7 is the Bourne shell (sh). It replaced an earlier shell and has itself been replaced by a long line of shells over the years. V7/x86 also includes the C shell (csh).
The computing history has produced a lot of wordplay like this. For example, GNU is a recursive acronym for "GNU's Not Unix!", YACC is Yet Another Compiler Compiler, and GIMP is the GNU Image Manipulation Program. I had once created a PHP based template processor years ago called YATP - Yet Another Template Parser.
The C shell included several improvements over the Bourne shell. The script syntax was more like the C programming language whereas the Bourne took its inspiration from Algol 68. There were improvements in history tracking as well as others, you can read the details in the link above.

The user can drop into another shell from within a shell just by executing the desired shell program. For the C shell, just type in the following command. The prompt will change from the Bourne shell '$' to '%'.

$ /bin/csh
%

This is convenient for occasionally switching shells, but what if we want to change the user account default shell?

User account information is stored in the passwd file found in /etc. Passwd contains the user's login name, password, and other information including the program to use as shell. You can read more about it in the passwd man page.

Changing the user's default shell is pretty simple. Switch to the root account with "su", edit the /etc/passwd file with "vi", find the line for the desired user account, and add the path to the shell program at the end of the line.

guest::7:3::/usr/guest:/bin/csh

Change the shell for "guest" to "/bin/csh".
Exit the root account, logout of your account, and log back in. You should now be in the new default shell.

Running the C shell by default


No comments:

Post a Comment