JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
System Administration Guide: Basic Administration
search filter icon
search icon

Document Information

Preface

1.  Oracle Solaris Management Tools (Road Map)

2.  Working With the Solaris Management Console (Tasks)

3.  Working With the Oracle Java Web Console (Tasks)

4.  Managing User Accounts and Groups (Overview)

What's New or Changed in Managing Users and Groups?

Tools for User Account and Group Account Management

What Are User Accounts and Groups?

User Account Components

User (Login) Names

User ID Numbers

Using Large User IDs and Group IDs

UNIX Groups

User Passwords

Home Directories

Name Services

User's Work Environment

Guidelines for Using User Names, User IDs, and Group IDs

Where User Account and Group Information Is Stored

Fields in the passwd File

Default passwd File

Fields in the shadow File

Fields in the group File

Default group File

Tools for Managing User Accounts and Groups

Tasks for Solaris User and Group Management Tools

Managing Users and Resources With Projects

Customizing a User's Work Environment

Customizing the Bash Shell

Using Site Initialization Files

Avoiding Local System References

Shell Features

Shell Environment

The PATH Variable

Setting Path Guidelines

Setting a User's Default Path

Locale Variables

Default File Permissions (umask)

User and Site Initialization Files Examples

5.  Managing User Accounts and Groups (Tasks)

6.  Managing Client-Server Support (Overview)

7.  Managing Diskless Clients (Tasks)

8.  Introduction to Shutting Down and Booting a System

9.  Shutting Down and Booting a System (Overview)

10.  Shutting Down a System (Tasks)

11.  Modifying Oracle Solaris Boot Behavior (Tasks)

12.  Booting an Oracle Solaris System (Tasks)

13.  Managing the Oracle Solaris Boot Archives (Tasks)

14.  Troubleshooting Booting an Oracle Solaris System (Tasks)

15.  x86: GRUB Based Booting (Reference)

16.  x86: Booting a System That Does Not Implement GRUB (Tasks)

17.  Working With the Oracle Solaris Auto Registration regadm Command (Tasks)

18.  Managing Services (Overview)

19.  Managing Services (Tasks)

20.  Managing Software (Overview)

21.  Managing Software With Oracle Solaris System Administration Tools (Tasks)

22.  Managing Software by Using Oracle Solaris Package Commands (Tasks)

23.  Managing Patches

A.  SMF Services

Index

Customizing a User's Work Environment

Part of setting up a user's home directory is providing user initialization files for the user's login shell. A user initialization file is a shell script that sets up a work environment for a user after the user logs in to a system. Basically, you can perform any task in a user initialization file that you can do in a shell script. However, a user initialization file's primary job is to define the characteristics of a user's work environment, such as a user's search path, environment variables, and windowing environment. Each login shell has its own user initialization file or files, which are listed in the following table.

Table 4-15 User Initialization Files for Bourne, C, and Korn Shells

Shell
User Initialization File
Purpose
Bourne
$HOME/.profile
Defines the user's environment at login
C
$HOME/.cshrc
Defines the user's environment for all C shells and is invoked after login shell
$HOME/.login
Defines the user's environment at login

Korn
$HOME/.profile
Defines the user's environment at login
$HOME/$ENV
Defines user's environment at login in the file and is specified by the Korn shell's ENV environment variable

Table 4-16 Default User Initialization Files

Shell
Default File
C
/etc/skel/local.login
/etc/skel/local.cshrc
Bourne or Korn
/etc/skel/local.profile

You can use these files as a starting point and then modify them to create a standard set of files that provide the work environment common to all users. You can also modify these files to provide the working environment for different types of users. Although you cannot create customized user initialization files with the Users tool, you can populate a user's home directory with user initialization files that are located in a specified “skeleton” directory. You can accomplish this task by creating a user template with the User Templates tool and then specifying a skeleton directory from which to copy user initialization files.

For step-by-step instructions on how to create sets of user initialization files for different types of users, see How to Customize User Initialization Files.

When you use the Users tool to create a new user account and select the create home directory option, the following files are created, depending on which login shell is selected.

Table 4-17 Files Created by Users Tool When Adding a User

Shell
Files Created
C
The /etc/skel/local.cshrc and the /etc/skel/local.login files are copied into the user's home directory and are renamed .cshrc and .login, respectively.
Bourne and Korn
The /etc/skel/local.profile file is copied into the user's home directory and renamed .profile.

Customizing the Bash Shell

To customize your bash shell, add the information to the .bashrc file that is located in your home directory. The initial user that is created when you install Oracle Solaris has a .bashrc file that sets the PATH, MANPATH, and command prompt. For more information, see the bash(1) man page.

Using Site Initialization Files

The user initialization files can be customized by both the administrator and the user. This important task can be accomplished with centrally located and globally distributed user initialization files that are called, site initialization files. Site initialization files enable you to continually introduce new functionality to the user's work environment, while enabling the user to customize the user's initialization file.

When you reference a site initialization file in a user initialization file, all updates to the site initialization file are automatically reflected when the user logs in to the system or when a user starts a new shell. Site initialization files are designed for you to distribute site-wide changes to users' work environments that you did not anticipate when you added the users.

You can customize a site initialization file the same way that you customize a user initialization file. These files typically reside on a server, or set of servers, and appear as the first statement in a user initialization file. Also, each site initialization file must be the same type of shell script as the user initialization file that references it.

To reference a site initialization file in a C-shell user initialization file, place a line at the beginning of the user initialization file similar to the following line:

source /net/machine-name/export/site-files/site-init-file

To reference a site initialization file in a Bourne-shell or Korn-shell user initialization file, place a line at the beginning of the user initialization file similar to the following line:

. /net/machine-name/export/site-files/site-init-file

Avoiding Local System References

Do not add specific references to the local system in the user initialization file. The instructions in a user initialization file should be valid, regardless of which system the user logs into.

For example:

Shell Features

The following table lists basic shell features that each shell provides, which can help you determine what you can and can't do when creating user initialization files for each shell.

Table 4-18 Basic Features of Bourne, C, and Korn Shells

Feature
Bourne
C
Korn
Known as the standard shell in UNIX
Applicable
No applicable
Not applicable
Compatible syntax with Bourne shell
-
Not applicable
Applicable
Job control
Applicable
Applicable
Applicable
History list
Not applicable
Applicable
Applicable
Command-line editing
Not applicable
Applicable
Applicable
Aliases
Not applicable
Applicable
Applicable
Single-character abbreviation for login directory
Not applicable
Applicable
Applicable
Protection from overwriting (noclobber)
Not applicable
Applicable
Applicable
Setting to ignore Control-D (ignoreeof)
Not applicable
Applicable
Applicable
Enhanced cd command
Not applicable
Applicable
Applicable
Initialization file separate from .profile
Not applicable
Applicable
Applicable
Logout file
Not applicable
Applicable
N/A

Shell Environment

A shell maintains an environment that includes a set of variables defined by the login program, the system initialization file, and the user initialization files. In addition, some variables are defined by default.

A shell can have two types of variables:

In the C shell, you use lowercase names with the set command to set shell variables. You use uppercase names with the setenv command to set environment variables. If you set a shell variable, the shell sets the corresponding environment variable. Likewise, if you set an environment variable, the corresponding shell variable is also updated. For example, if you update the path shell variable with a new path, the shell also updates the PATH environment variable with the new path.

In the Bourne and Korn shells, you can use the uppercase variable name that is equal to some value to set both shell and environment variables. Also, use the export command to activate the variables for any subsequently executed commands.

For all shells, you generally refer to shell and environment variables by their uppercase names.

In a user initialization file, you can customize a user's shell environment by changing the values of the predefined variables or by specifying additional variables. The following table shows how to set environment variables in a user initialization file.

Table 4-19 Setting Environment Variables in a User Initialization File

Shell Type
Line to Add to the User Initialization File
C shell
setenv VARIABLE value

Example:

setenv MAIL /var/mail/ripley

Bourne or Korn shell
VARIABLE=value; export VARIABLE

Example:

MAIL=/var/mail/ripley;export MAIL

The following table describes environment variables and shell variables that you might want to customize in a user initialization file. For more information about variables that are used by the different shells, see the sh(1), ksh(1), or csh(1) man pages.

Table 4-20 Shell and Environment Variable Descriptions

Variable
Description
CDPATH, or cdpath in the C shell
Sets a variable used by the cd command. If the target directory of the cd command is specified as a relative path name, the cd command first looks for the target directory in the current directory (.). If the target is not found, the path names listed in the CDPATH variable are searched consecutively until the target directory is found and the directory change is completed. If the target directory is not found, the current working directory is left unmodified. For example, the CDPATH variable is set to /home/jean, and two directories exist under /home/jean, bin, and rje. If you are in the /home/jean/bin directory and type cd rje, you change directories to /home/jean/rje, even though you do not specify a full path.
history
Sets the history for the C shell.
HOME, or home in the C shell
Sets the path to the user's home directory.
LANG
Sets the locale.
LOGNAME
Defines the name of the user currently logged in. The default value of LOGNAME is set automatically by the login program to the user name specified in the passwd file. You should only need to refer to, not reset, this variable.
LPDEST
Sets the user's default printer.
MAIL
Sets the path to the user's mailbox.
MANPATH
Sets the hierarchies of man pages that are available.
PATH, or path in the C shell
Specifies, in order, the directories that the shell searches to find the program to run when the user types a command. If the directory is not in the search path, users must type the complete path name of a command.

As part of the login process, the default PATH is automatically defined and set as specified in .profile (Bourne or Korn shell) or .cshrc (C shell).

The order of the search path is important. When identical commands exist in different locations, the first command found with that name is used. For example, suppose that PATH is defined in Bourne and Korn shell syntax as PATH=/bin:/usr/bin:/usr/sbin:$HOME/bin and a file named sample resides in both /usr/bin and /home/jean/bin. If the user types the command sample without specifying its full path name, the version found in /usr/bin is used.

prompt
Defines the shell prompt for the C shell.
PS1
Defines the shell prompt for the Bourne or Korn shell.
SHELL, or shell in the C shell
Sets the default shell used by make, vi, and other tools.
TERMINFO
Names a directory where an alternate terminfo database is stored. Use the TERMINFO variable in either the /etc/profile or /etc/.login file. For more information, see the terminfo(4)man page.

When the TERMINFO environment variable is set, the system first checks the TERMINFO path defined by the user. If the system does not find a definition for a terminal in the TERMINFO directory defined by the user, it searches the default directory, /usr/share/lib/terminfo, for a definition. If the system does not find a definition in either location, the terminal is identified as “dumb.”

TERM, or term in the C shell
Defines the terminal. This variable should be reset in either the /etc/profile or /etc/.login file. When the user invokes an editor, the system looks for a file with the same name that is defined in this environment variable. The system searches the directory referenced by TERMINFO to determine the terminal characteristics.
TZ
Sets the time zone. The time zone is used to display dates, for example, in the ls -l command. If TZ is not set in the user's environment, the system setting is used. Otherwise, Greenwich Mean Time is used.

The PATH Variable

When the user executes a command by using the full path, the shell uses that path to find the command. However, when users specify only a command name, the shell searches the directories for the command in the order specified by the PATH variable. If the command is found in one of the directories, the shell executes the command.

A default path is set by the system. However, most users modify it to add other command directories. Many user problems related to setting up the environment and accessing the correct version of a command or a tool can be traced to incorrectly defined paths.

Setting Path Guidelines

Here are some guidelines for setting up efficient PATH variables:

Setting a User's Default Path

This is an example of how to set a user's default path.

The following examples show how to set a user's default path to include the home directory and other NFS mounted directories. The current working directory is specified first in the path. In a C-shell user initialization file, you would add the following:

set path=(. /usr/bin $HOME/bin /net/glrr/files1/bin)

In a Bourne-shell or Korn-shell user initialization file, you would add the following:

PATH=.:/usr/bin:/$HOME/bin:/net/glrr/files1/bin
export PATH

Locale Variables

The LANG and LC environment variables specify the locale-specific conversions and conventions for the shell. These conversions and conventions include time zones, collation orders, and formats of dates, time, currency, and numbers. In addition, you can use the stty command in a user initialization file to indicate whether the terminal session will support multibyte characters.

The LANG variable sets all possible conversions and conventions for the given locale. You can set various aspects of localization separately through these LC variables: LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_NUMERIC, LC_MONETARY, and LC_TIME.

The following table describes some of the values for the LANG and LC environment variables.

Table 4-21 Values for LANG and LC Variables

Value
Locale
de_DE.ISO8859-1
German
en_US.UTF-8
American English (UTF-8)
es_ES.ISO8859-1
Spanish
fr_FR.ISO8859-1
French
it_IT.ISO8859-1
Italian
ja_JP.eucJP
Japanese (EUC)
ko_KR.EUC
Korean (EUC)
sv_SE.ISO8859-1
Swedish
zh_CN.EUC
Simplified Chinese (EUC)
zh_TW.EUC
Traditional Chinese (EUC)

For more information on supported locales, see the International Language Environments Guide.

Example 4-1 Setting the Locale Using the LANG Variables

The following examples show how to set the locale by using the LANG environment variables. In a C-shell user initialization file, you would add the following:

setenv LANG de_DE.ISO8859-1

In a Bourne-shell or Korn-shell user initialization file, you would add the following:

LANG=de_DE.ISO8859-1; export LANG

Default File Permissions (umask)

When you create a file or directory, the default file permissions assigned to the file or directory are controlled by the user mask. The user mask is set by the umask command in a user initialization file. You can display the current value of the user mask by typing umask and pressing Return.

The user mask contains the following octal values:

Note that if the first digit is zero, it is not displayed. For example, if the user mask is set to 022, 22 is displayed.

To determine the umask value that you want to set, subtract the value of the permissions you want from 666 (for a file) or 777 (for a directory). The remainder is the value to use with the umask command. For example, suppose you want to change the default mode for files to 644 (rw-r--r--). The difference between 666 and 644 is 022, which is the value you would use as an argument to the umask command.

You can also determine the umask value you want to set by using the following table. This table shows the file and directory permissions that are created for each of the octal values of umask.

Table 4-22 Permissions for umask Values

umask Octal Value
File Permissions
Directory Permissions
0
rw-
rwx
1
rw-
rw-
2
r--
r-x
3
r--
r--
4
-w-
-wx
5
-w-
-w-
6
--x
--x
7
--- (none)
--- (none)

The following line in a user initialization file sets the default file permissions to rw-rw-rw-.

umask 000

User and Site Initialization Files Examples

The following sections provide examples of user and site initialization files that you can use to start customizing your own initialization files. These examples use system names and paths that you need to change for your particular site.

Example 4-2 The .profile File

(Line 1) PATH=$PATH:$HOME/bin:/usr/local/bin:/usr/ccs/bin:. 
(Line 2) MAIL=/var/mail/$LOGNAME 
(Line 3) NNTPSERVER=server1 
(Line 4) MANPATH=/usr/share/man:/usr/local/man 
(Line 5) PRINTER=printer1 
(Line 6) umask 022 
(Line 7) export PATH MAIL NNTPSERVER MANPATH PRINTER
  1. Defines the user's shell search path.

  2. Defines the path to the user's mail file.

  3. Defines the user's Usenet news server.

  4. Defines the user's search path for man pages.

  5. Defines the user's default printer.

  6. Sets the user's default file creation permissions.

  7. Sets the listed environment variables.

Example 4-3 The .cshrc File

(Line 1) set path=($PATH $HOME/bin /usr/local/bin /usr/ccs/bin)
(Line 2) setenv MAIL /var/mail/$LOGNAME 
(Line 3) setenv NNTPSERVER server1 
(Line 4) setenv PRINTER printer1 
(Line 5) alias h history 
(Line 6) umask 022 
(Line 7) source /net/server2/site-init-files/site.login 
  1. Defines the user's shell search path.

  2. Defines the path to the user's mail file.

  3. Defines the user's Usenet news server.

  4. Defines the user's default printer.

  5. Creates an alias for the history command. The user needs to type only h to run the history command.

  6. Sets the user's default file creation permissions.

  7. Sources the site initialization file.

Example 4-4 Site Initialization File

The following shows an example site initialization file in which a user can choose a particular version of an application.

# @(#)site.login
main: 
echo "Application Environment Selection"
echo ""
echo "1. Application, Version 1"
echo "2. Application, Version 2"
echo "" 
echo -n "Type 1 or 2 and press Return to set your 
application environment: " 

set choice = $<    

if ( $choice !~ [1-2] ) then 
goto main 
endif 

switch ($choice) 

case "1": 
setenv APPHOME /opt/app-v.1 
breaksw 

case "2": 
setenv APPHOME /opt/app-v.2 
endsw

This site initialization file could be referenced in a user's .cshrc file (C shell users only) with the following line:

source /net/server2/site-init-files/site.login

In this line, the site initialization file is named site.login and is located on a server named server2. This line also assumes that the automounter is running on the user's system.