Customizing the Unix Shell

Posted On 2005-11-1 by FortyPoundHead
Keywords: Unix Tutorial Part 12
Tags: Tip Tutorial Linux
Views: 1493

The UNIX shell is a actually a user program that the kernel runs for you when you log in. There is usually more than one shell available >on most UNIX systems. The most common shells available on UNIX systems are the Bourne Shell (sh), the C Shell (csh) and the Korn shell (ksh). A summary of features available on these three shells are shown at the end of this article, adapted from the Hewlett Packard "Beginner's Guide to HPUX."

Choosing your shell

It is possible to invoke any available shell from within another shell. To start a new shell, you can simply type the name of the shell you want to run, ksh, csh, or sh.

It is also possible to set the default startup shell for all your future sessions. The default shell for your account is stored in the system database /etc/passwd, along with the other information about your account. To change your default shell, use the chsh command The cshs command requires one argument, the name of the shell you want as your default. To change tour default shell to the C shell, you could enter the command

chsh /bin/csh

On ISU's HP-UX system, the available shells are /bin/sh, /bin/posix/sh, and /bin/csh. The default shell for accounts is /bin/posix/sh, which is, for all practical purposes, the same as ksh.

Default file access permissions

Whenever you create a file or directory in a UNIX filesystem, the newly created file or directory is stamped with a default set of permissions. That default set of permissions is stored in a variable called the umask. You can change the value of umask to suit your preferences. To see the current value of the umask variable, enter the shell command:


The umask is stored as an octal (base 8) number, that defines which permissions to deny. As you recall, three kinds of file permissions (read, write, and execute) are given for each of three classes of users (owner, group, and others). Each of the nine permissions is specified as a zero (allow access), or a one (deny access).

To set your umask to deny write permission to group and others, use the command

umask 022

To deny all access to group and others, use the command

umask 077

Some versions of UNIX provide a more user-friendly way of specifying your umask. In HP-UX sh-posix (or ksh), you are allowed to specify the access permissions in manner of the chmod command. The command

mask u=rwx,g=r,o=r

would set the umask to deny write and execute permissions to the group, and to others. That kind of command syntax will not work in HP-UX's C shell or Bourne shell. The HP-UX posix shell also allows the use of the command

umask -S

to print your umask setting in a more readable fashion.

Feature Function sh csh ksh
Job control Allows processes to be run in the background No Yes Yes
History substitution Allows previous commands to be saved, edited, and reused No Yes Yes
File name completion Allows automatic completion of partially typed file name No Yes Yes
Command line editing Allows the use of an editor to modify the command line text No No Yes
Command aliasing Allows the user to rename commands No Yes Yes

About the Author

FortyPoundHead has posted a total of 1974 articles.


Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Recent Forum Posts

Q&A borked
dwirch posted on June 27, 2017 at about 7:00 in Site News

SSL Now Active
dwirch posted on June 16, 2017 at about 8:40 in Site News

SSL Now Active
dwirch posted on June 13, 2017 at about 7:59 in Site News

Coding Archive?
dwirch posted on June 3, 2017 at about 12:54 in Site News

Job Spammer: Bharti Jigyasi
dwirch posted on June 2, 2017 at about 16:57 in Spammers

Coding Archive?
dwirch posted on May 25, 2017 at about 12:38 in Site News