[ Pobierz całość w formacie PDF ]
.si::sysinit:/etc/rc.d/rc.sysinitl0:0:wait:/etc/rc.d/rc 0l1:1:wait:/etc/rc.d/rc 1l2:2:wait:/etc/rc.d/rc 2l3:3:wait:/etc/rc.d/rc 3l4:4:wait:/etc/rc.d/rc 4l5:5:wait:/etc/rc.d/rc 5l6:6:wait:/etc/rc.d/rc 6# Things to run in every runlevel.ud::once:/sbin/update# Trap CTRL-ALT-DELETEca::ctrlaltdel:/sbin/shutdown -t3 -r now# When our UPS tells us power has failed, assume we have a few minutes# of power left.Schedule a shutdown for 2 minutes from now.# This does, of course, assume you have powerd installed and your# UPS connected and working correctly.pf::powerfail:/sbin/shutdown -f -h +2 Power Failure; System Shutting Down124881-6 ch08.F 11/12/01 8:30 AM Page 277Chapter 8 &' User Environment Settings277# If power was restored before the shutdown kicked in, cancel it.pr:12345:powerokwait:/sbin/shutdown -c Power Restored; Shutdown Cancelled# Run gettys in standard runlevels1:2345:respawn:/sbin/mingetty tty12:2345:respawn:/sbin/mingetty tty2# Run gettys in standard runlevels1:2345:respawn:/sbin/mingetty tty12:2345:respawn:/sbin/mingetty tty23:2345:respawn:/sbin/mingetty tty34:2345:respawn:/sbin/mingetty tty45:2345:respawn:/sbin/mingetty tty56:2345:respawn:/sbin/mingetty tty6# Run xdm in runlevel 5# xdm is now a separate servicex:5:respawn:/etc/X11/prefdm -nodaemonThe previous file shows how the INIT process sets up the system for a certain run-level.The INIT process is used to start specific services for specific run levels andgeneral services for every run level.In the preceding example, the default run levelis indicated in the line si::sysinit:/etc/rc.d/rc.sysinit, several items run instandard run levels, and the X Window System runs in run level 5.Editing the con-figuration file for the INIT process can be useful to start services for a specific runlevel or all run levels.One of the major jobs of the inittabfile is to set up the envi-ronment variable TERM, which should normally contain the name of the type of ter-minal, console, or display-device type to be used.The /etc/inittabfile will control the TERM environment, so be familiar withthe location and format of the file.This information is critical to any program that is screen-oriented, including edi-tors, mailers, and remote access programs.A default TERM value is set on a per-linebasis and nearly always provides all the services needed for a workstation console.However, you can edit the terminal parameters to use a different configurationdepending on the needs of a user.Use the inittabfile to set up user-specific TERMenvironment specifications when the default settings are not acceptable.BASH3.11 Identify the purpose and characteristics of configuration files (e.g., BASH,inittab, fstab, /etc/*)3.12 Edit basic configuration files (e.g., BASH files, inittab, fstab)The Bourne Again SHell (BASH), is the shell, or command language interpreter, forthe GNU operating system and is standard for most Linux systems.BASH has many124881-6 ch08.F 11/12/01 8:30 AM Page 278Part III &' Configuration278features that allow it to perform well in the Linux environment, including commandand filename completion, command line editing, history commands and events,detailed shell operational control, and aliasing.BASH is widely used because ofthese abilities.To verify the use of BASH on a system, use the envcommand to listinformation shown below:bash-2.04$ envPWD=/home/billTMPDIR=/tmp/LC_MESSAGES=en_USREMOTEHOST=192.168.6HOSTNAME=dhcppc1NLSPATH=/usr/share/locale/%l/%NLESSKEY=/etc/.lessLESSOPEN=|/usr/bin/lesspipe.sh %sLANGUAGE=en_US:enPS1=\s-\v\$LESS=-MMUSER=billLS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.tar=01;31:*.tgz=01;31:*.tbz2=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lha=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:*.tiff=01;35:LC_TIME=en_USMACHTYPE=i586-mandrake-linux-gnuMAIL=/var/spool/mail/billINPUTRC=/etc/inputrcLANG=enLC_NUMERIC=en_USTMP=/tmp/LOGNAME=billSHLVL=1LC_CTYPE=en_USSHELL=/bin/bashHOSTTYPE=i586OSTYPE=linux-gnuHISTSIZE=1000TERM=ansiHOME=/home/billPATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/gamesSECURE_LEVEL=3LC_MONETARY=en_USRPM_INSTALL_LANG=en_US:enLC_COLLATE=en_US_=/usr/bin/envNotice the lineSHELL=/bin/bash124881-6 ch08.F 11/12/01 8:30 AM Page 279Chapter 8 &' User Environment Settings279that sets this system to use BASH as the default shell.The configuration files forBASH are.bash_profile,.bashrc, and.bash_logout.The.bash_profileisthe login initialization file for BASH.The shell is initialized in a couple of ways one upon boot and the other interactively.Both ways look for the.bashrcfile,which contains the configuration.The file is executed each time the BASH shell orany sub-shells are entered.A global file, usually located at /etc/bashrc, and a userspecific file, usually located in /home/username/.bashrc, are the configurationsthat BASH will use.Any changes to these initialization files will take effect the nexttime the system is restarted, or the changes can be activated during the currentsession by running the initialization program.This allows the special features tobe activated.To learn more about the features of BASH, see the MAN pages.The most commonoptions that can be enabled are noclobber, ignoreeof, and alias.Aliasisespecially useful because it simplifies the use of common commands, such asadding alias cp cp -i to allow only the cpcommand to be used instead of cp-icommand.The home directory of each user also contains the.bash_profileand.bash_logoutfiles.The.bash_logoutfile can be edited to perform taskswhen a user logs out.A common addition to this file is the ability to display mes-sages on logout.A common.bash_logoutfile may look like this:# ~/.bash_logoutclearecho Exiting the systemThese BASH commands clear the screen and then display the message, Exiting thesystem. The.bash_profilemay also be named.profileand is the BASH logininitialization file, which is a script that is executed whenever a user logs in.You canalso use the BASH logon initialization file to define special environmental variablesused to manage the shell, and to set PATH variables for Linux to use to providequick access to your application programs that are located in other directories.You can do this by using the following simple method:#.bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then.~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/binBASH_ENV=$HOME/.bashrcexport BASH_ENV PATHunset USERNAME124881-6 ch08.F 11/12/01 8:30 AM Page 280Part III &' Configuration280Notice the PATH lines in the preceding example; the first path line sets the $PATH,which holds the directories searched for any command entered, and $HOME, whichholds the path of the users home directory.The /binadds the user s bin directoryto the directories searched when a command is entered.The next line sets theBASH_ENVto the user s home directory and to that user s.bashrcfor individualconfiguration.Notice also the export command, which is used to export the vari-ables to any sub-shells that may be used.By using an editor, you can customizethe
[ Pobierz całość w formacie PDF ]