59.

function OpenWin(url, w, h) { if(!w) w = 400; if(!h) h = 300; window.open(url, "_new", "width=" + w + ",height=" + h + ",menubar=no,toobar=no,scrollbars=yes", true); }

Book: LPI Linux Certification in a Nutshell
Section: Chapter 7.  Administrative Tasks (Topic 2.11)



7.2 Objective 2: Tune the User Environment

When you create a new user account on your Linux system, some basic setup information is necessary for the user to initially become productive. When the user logs into the system, she will need:

  • A minimal set of environment variables, including a PATH that is meaningful for your system.

  • Basic configuration files in her home directory.

The amount of default information you provide can range from minimal to extremely detailed. In general, you'll want to provide the setup information that will allow the user to begin working without extensive personal customization.

7.2.1 System-wide Startup Scripts

When the bash shell starts, it looks for a number of configuration script files, including /etc/profile. Commands in this file are executed at login time and contain global startup information and settings for all bash users.[5] Example 7-1 contains an example profile.

[5] This does not apply to users of other shells, such as tcsh. Those shells require different global startup setup and are not among the Objectives for the LPIC Level 1 exams.

Example 7-1. Sample /etc/profile File
# /etc/profile # System wide environment and startup programs # Functions and aliases go in /etc/bashrc PATH="$PATH:/usr/X11R6/bin" PS1="[\u@\h \W]\\$ " ulimit -c 1000000 if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then umask 002 else umask 022 fi USER=`id -un` LOGNAME=$USER MAIL="/var/spool/mail/$USER" HOSTNAME=`/bin/hostname` HISTSIZE=1000 HISTFILESIZE=1000 INPUTRC=/etc/inputrc PATH="$PATH:/usr/local/bin" export PATH PS1 HOSTNAME HISTSIZE HISTFILESIZE  USER LOGNAME MAIL INPUTRC

The syntax for bash programming is in Chapter 17. However, you can see that this file does basic shell setup for the user, including the assignment of a number of environment variables. As an example of a common local customization, note the line containing PATH= adds an additional directory to those already listed in the PATH environment variable. In this case, the system administrator expects that most users will need to run programs stored in /usr/local/bin. Making this modification once in /etc/profile eliminates the need for individuals to make it in their personal bash profiles.

On the Exam

Remember that /etc/profile is executed only once, while /etc/bashrc is called for each new shell invocation. Also note that these startup scripts are specific to bash and that users of other shells will have a different configuration.

As you may have noted in the comments at the top of Example 7-1, the definition of functions and aliases typically is not done in /etc/profile, but instead in /etc/bashrc. This is because functions and aliases are not inherited by new shells. Since commands in /etc/profile are executed only at login time, functions and aliases defined there would only be available in the login shell. Commands in the bashrc file are executed each time a new shell starts; their effects will apply to all shells.

7.2.2 Setting the Home Directory for New Accounts

When creating a new account, usually you'll want to create a default home directory for the user of the account. On Linux systems, the home directory is most likely something like /home/username, but you can define it in any way you like.

When you create a new home directory, it is a courtesy to the new user to initially populate the directory with useful files. These might include startup files for the user's shell, his desktop, or for X Window applications. To facilitate the automated population of new user directories, an example home directory is created in a "skeleton" directory /etc/skel. This directory should contain all of the files and subdirectories that all new users will need. Example 7-2 shows the contents of an example /etc/skel directory.

Example 7-2. Sample Skeleton (/etc/skel) Directory
-rw-r--r--  1 root   root   1422 Mar 29  1999 .Xdefaults -rw-r--r--  1 root   root     24 Jul 13  1994 .bash_logout -rw-r--r--  1 root   root    230 Aug 22  1998 .bash_profile -rw-r--r--  1 root   root    124 Aug 23  1995 .bashrc drwxr-xr-x  3 root   root   1024 Dec  2 09:37 .kde -rw-r--r--  1 root   root    966 Apr 16  1999 .kderc drwxr-xr-x  5 root   root   1024 Dec  2 09:37 Desktop

This example /etc/skel directory contains:

  • An X application startup file (.Xdefaults).

  • Three configuration files for the shell (.bash_logout, .bash_ profile, and .bashrc).

  • A directory and a startup file for KDE (.kde and .kderc).

  • A Desktop directory, which defines the appearance of the user's desktop.

The specifics of this example are not important, but illustrate that a number of default files can be included in a new user's account setup. Additions could include default files for other desktop environments such as GNOME as well as startup files for other shells.

When a new account is created with a home directory, the entire contents of /etc/skel are copied recursively (that is, including subdirectories) to the new home directory location. The home directory and its entire contents are then set to the new account's UID and GID, making the new user owner of her initial files. She is then free to modify these files and directories as necessary.

As the system administrator, you may add, modify, and delete files in /etc/skel as needed for your environment.

 


LPI Linux Certification in a Nutshell
LPI Linux Certification in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596005288
EAN: 2147483647
Year: 2000
Pages: 194

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