Linux系統啟動過程
主機加電自檢
按下電源鍵後,系統加載BIOS,檢查連接配接到系統的外接裝置、并枚舉和初始化裝置(比如讓光驅雷射頭複位、測試風扇狀态等),如果沒有出錯,則根據BIOS中的設定查找處于活動狀态并能引導系統的硬碟分區、CD光牒或者U盤,進而從中讀取引導裝載程式。
引導裝載程式加載核心
不同的作業系統,引導裝載程式也有所不同;linux中廣泛使用的是GRUB,該程式被讀取後,會從/boot/grub/menu.lst(或者/boot/grub/grub.conf)檔案中讀取相應的配置;menu.lst檔案的内容大緻如下:
#這兩個值表示啟動後光标所在的預設菜單編号,菜單項就是下面title列出來的項
#0表示預設在第一項,8表示8秒内無動作、則預設啟動第一項
default 0
timeout 8
##YaST - generic_mbr-這裡設定了mbr引導分區檔案的位置、啟動背景圖案等參數,都在下面這個message檔案裡寫着
#啟動背景存放在/etc/bootsplash/themes/SLES/cdrom下面
gfxmenu (hd0,1)/boot/message
##YaST - activate-這裡表示GRUB引導選擇界面隐藏使用者選擇菜單,為空則顯示選擇菜單
hiddenmenu
###Don't change this comment - YaST2 identifier: Originalname: linux###
#下面三段分别表示選擇界面的三個選擇項
#名稱
title SUSE Linux Enterprise Server 11 SP3 - 3.0.76-0.11
#根目錄
root (hd0,1)
#要加載的核心檔案和核心參數
kernel/boot/vmlinuz-3.0.76-0.11-default root=/dev/sda2 resume=/dev/sda1 splash=silentcrashkernel= showopts
#挂在記憶體映像檔案
initrd/boot/initrd-3.0.76-0.11-default
###Don't change this comment - YaST2 identifier: Originalname: failsafe###
title Failsafe -- SUSE Linux Enterprise Server 11 SP3 -3.0.76-0.11
root (hd0,1)
kernel/boot/vmlinuz-3.0.76-0.11-default root=/dev/sda2 showopts ide=nodma apm=offnoresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1nomodeset x11failsafe
initrd/boot/initrd-3.0.76-0.11-default
###Don't change this comment - YaST2 identifier: Originalname: floppy###
title Floppy
rootnoverify(fd0)
chainloader +1
*關于記憶體映像檔案
可以把上面的initrd-3.0.76-0.11-default檔案單獨拷到一個檔案夾中、解壓:
zcat initrd-3.0.76-0.11-default | cpio -imd
解壓出的檔案中有一個名為init的shell可執行腳本,其功能主要是挂在檔案系統、加載相應核心子產品等。
此時如果使用root使用者執行這個腳本,會進入fast boot模式,這有可能臨時修複損壞的系統,但有可能損壞硬碟分區上的業務資料,是以、營運中伺服器千萬不要這麼做,危險!
*定制記憶體映像檔案
後面會詳細學習這部分内容,這裡先不深究每一個指令參數的使用是否正确。
這樣做的目的主要是為了能在系統啟動時加載一些特殊裝置(如SCSI裝置、Raid卡等)的驅動。
首先要明确被裝載驅動檔案的位置。比如我們隊防火牆的核心驅動檔案進行了修改/更新:
/lib/modules/3.0.76-0.11-default/kernel/drivers/firewire/firewire-core.ko
*注:.ko是核心子產品檔案,是核心加載的某個子產品,一般是驅動程式。
之後就可以在記憶體映像檔案目錄(也就是上面initrd-3.0.76-0.11-default檔案所在的目錄)中使用mkinitrd指令制作(我覺得叫更新更合适)記憶體映像,該指令的基本格式如下:
mkinitrd [選擇性參數] <必要參數>
必要參數包括:
<映像檔案>:/boot/grub/menu.lst中指定要加載的核心檔案
<核心版本>:所依據的核心版本,使用uname -r檢視。
[可選參數]包括
--builtin=<子產品>
認為指定子產品已經裝入核心,忽略錯誤
-f
允許覆寫已存在的映像檔案
--image-version
核心版本号将附加到建立的映像檔案的目錄前
--fstable=<檔案系統清單>
使用清單自動探測根裝置所建立的檔案系統類型
--nocompress
不壓縮生成的映像檔案
--nopivot
不使用pivot_root系統調用作為映像的一部分
--omit-lvm-modules
不載入任何lvm子產品
--omit-scsi-modules
不載入任何scsi子產品
--preload=<子產品>
将指定的子產品載入映像中
-v
在建立映像過程中列印資訊
-version
列印程式版本資訊
初始化系統環境
Linux加載核心後、會将控制權移交給核心,核心根據讀取到得配置項等資訊構造最基本的核心環境,執行的動作有:調用初始化函數初始化各種裝置、加載驅動、加載核心等。核心環境構造完成後,啟動系統的第一個程序-INIT程序。
要初始化的系統腳本有很多,這裡着重介紹幾個常用的:
啟動服務/etc/init.d/rc
當系統讀取了目前要啟動的runlevel後、會執行/etc/init.d/rc腳本:
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
#l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
去執行對應檔案夾的系統腳本來實作這一過程。
以runlevel=3為例,Linux會去執行/etc/init.d/rc3.d目錄下的檔案,該目錄下的檔案命名規律:
S和K開頭的檔案分别代表start和kill,表示需要運作/關閉的服務;S和K後面的數字表示優先級;最後是服務名。
(SUSE下待确認)/etc/rc.d/rc.sysinit
該腳本是在INIT程序被載入後開始運作。作用:
1. 取得網路環境與主機類型:
首先讀取網路設定檔 /etc/sysconfig/network ,取得主機名稱與預設通訊閘(gateway) 等網路環境。
2. 測試與挂載記憶體裝置 /proc 及 USB 裝置 /sys:
除挂載記憶體裝置 /proc 之外,還會主動偵測系統上是否具有 usb 的裝置,若有則會主動載入 usb 的驅動程式,并且嘗試挂載 usb 的檔案系統。
3. 決定是否啟動 SELinux :
近期以來,很多 distributions 都加入了美國國家安全局發展的 Security Enhance Linux 套件, 這個 SELinux 可以更加強化 Linux 操作環境的安全性,不過,由于安全挂帥, 對于新手來說,不是很容易上手。是以,我們才會建議大家先不要啟動啊。無論如何,在這個階段我們可以分析 SELinux 是否要啟動。
4. 周邊裝置的偵測與 Plug andPlay (PnP) 參數的測試:
根據核心在開機時偵測的結果 (/proc/sys/kernel/modprobe ) 開始進行 ide / scsi / 網路 / 音效 等周邊裝置的偵測,以及利用以載入的核心模組進行 PnP 裝置的參數測試。
5. 使用者自訂模組的載入
使用者可以在 /etc/sysconfig/modules/*.modules 加入自訂的模組, 則此時會被載入到系統當中喔!
6. 載入核心的相關設定:
系統會主動去讀取 /etc/sysctl.conf 這個檔案的設定值,使核心功能成為我們想要的樣子。
7. 設定系統時間 (clock):
8. 設定終端機 (console) 字形:
9. 設定 RAID 與 LVM 等硬碟功能:
10. 以 fsck 檢驗磁碟檔案系統:
11. 進行磁碟配額 quota 的轉換 (非必要):
12. 重新以可讀取模式挂載系統磁碟:
13. 啟動 quota 功能:
14. 啟動系統亂數裝置 (産生亂數功能):
15. 清除開機過程當中的暫存檔案:
16. 此外還設定了滑鼠鍵盤及産生随機數裝置等,很多底層功能都能在該腳本中得到定義。
/etc/init.d/rc.local
該檔案在SUSE下的名字是/etc/init.d/boot.local
該腳本會在INIT程序啟動完畢後開始自動執行,如果你有需要開啟自動執行/啟動的腳本/應用,可以将指令加進來。關于該檔案的官方解釋:
# Here you should add things, that shouldhappen directly after booting
# before we're going to the first runlevel.
加入指令時要注意:
使用&将要執行的指令放到背景,避免指令執行後一直占用終端。
腳本的位置要用決定路徑,否則在開機啟動時報錯,很難定位原因(因為輸出資訊不便于被檢視)。
注:如果系統啟動後發現有問題,可以通過/var/log/boot.msg和/var/log/boot.omsg檢視系統啟動過程中的錯誤資訊。
啟動INIT程序
此時基本的核心環境已經準備好了,Linux開始加載系統的第一個程序-INIT程序,這也是所有程序的父程序,啟動該程序時,會讀取/etc/inittab中的配置資訊。
*INIT程序的配置檔案
/etc/inittab檔案内容如下:
# /etc/inittab
#
# Copyright (c) 1996-2002 SuSE Linux AG,Nuernberg, Germany. All rights reserved.
#
# Author: Florian La Roche, 1996
# Please send feedback tohttp://www.suse.de/feedback
#
# This is the main configuration file of/sbin/init, which
# is executed by the kernel on startup. Itdescribes what
# scripts are used for the differentrun-levels.
#
# All scripts for runlevel changes are in/etc/init.d/.
#
# This file may be modified by SuSEconfigunless CHECK_INITTAB
# in /etc/sysconfig/suseconfig is set to"no"
#
#這裡定義系統的預設運作級别
#格式為id:runlevels:action:process,可以通過“maninittab”檢視相關的資訊
id:3:initdefault:
# First script to be executed, if notbooting in emergency (-b) mode
si::bootwait:/etc/init.d/boot
# /etc/init.d/rc takes care of runlevelhandling
#
# runlevel 0 is System halt (Do not use this forinitdefault!)
# runlevel 1 is Single user mode
# runlevel 2 is Local multiuser without remote network (e.g. NFS)
# runlevel 3 is Full multiuser with network
# runlevel 4 is Notused
# runlevel 5 is Full multiuser with network and xdm
# runlevel 6 is System reboot (Do not use this for initdefault!)
#下面定義了不同runlevel下要初始化的系統腳本
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
#l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# what to do in single-user mode
ls:S:wait:/etc/init.d/rc S
~~:S:respawn:/sbin/sulogin
# what to do when CTRL-ALT-DEL is pressed
#定義組合鍵CTRL-ALT-DEL的意義
ca::ctrlaltdel:/sbin/shutdown -r -t 4 now
# special keyboard request (Alt-UpArrow)
# look into the kbd-0.90 docs for this
kb::kbrequest:/bin/echo "KeyboardRequest -- edit /etc/inittab to let this work."
# what to do when power fails/returns
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
#pn::powerfail:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop
# for ARGO UPS
#定義了市電中斷、UPS電源啟動後要做的動作
sh:12345:powerfail:/sbin/shutdown -h nowTHE POWER IS FAILING
# getty-programs for the normal runlevels
#<id>:<runlevels>:<action>:<process>
# The "id" field MUST be the same as the last
# characters of the device (after"tty").
1:2345:respawn:/sbin/mingetty --nocleartty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
#
#S0:12345:respawn:/sbin/agetty -L 9600ttyS0 vt102
#cons:12345:respawn:/sbin/smart_agetty -L38400 console
#
# Note: Do not use tty7 in runlevel 3, this virtual line
# isoccupied by the programm xdm.
#
# This is for the package xdmsc, after installing and
# and configuration you should remove the comment character
# from the following line:
#7:3:respawn:+/etc/init.d/rx tty7
# modem getty.
# mo:235:respawn:/usr/sbin/mgetty -s 38400modem
# fax getty (hylafax)
# mo:35:respawn:/usr/lib/fax/faxgetty/dev/modem
# vbox (voice box) getty
# I6:35:respawn:/usr/sbin/vboxgetty -d/dev/ttyI6
# I7:35:respawn:/usr/sbin/vboxgetty -d /dev/ttyI7
# end of /etc/inittab
加載Login
INIT程序最後加載的是/bin/login,也就是登入界面。
使用者環境
全局使用者配置檔案/etc/profile
所有建立的使用者都會使用該檔案建構使用者環境。這裡儲存了使用者使用的SHELL類型、UID/EUID值、環境變量、快捷鍵設定及指令别名等。
其具體内容如下:
# /etc/profile for SuSE Linux
#這裡是一些簡單的說明
# PLEASE DO NOT CHANGE /etc/profile. Thereare chances that your changes
# will be lost during system upgrades.Instead use /etc/profile.local for
# your local settings, favourite globalaliases, VISUAL and EDITOR
# variables, etc ...
#檢查使用者使用SHELL類型并為使用者調用對應的Shell
# Check which shell is reading this file
if test -f /proc/mounts ; then
if! is=$(readlink /proc/$$/exe 2>/dev/null) ; then
case "$0" in
*pcksh) is=ksh ;;
*) is=sh ;;
esac
fi
case "$is" in
*/bash) is=bash
case"$0" in
sh|-sh|*/sh)
is=sh ;;
esac ;;
*/ash) is=ash ;;
*/dash) is=ash ;;
*/ksh) is=ksh ;;
*/ksh93) is=ksh ;;
*/pdksh) is=ksh ;;
*/*pcksh) is=ksh ;;
*/zsh) is=zsh ;;
*/*) is=sh ;;
esac
#
#`r' in $- occurs *after* system files are parsed
#
fora in $SHELL ; do
case "$a" in
*/r*sh)
readonly restricted=true ;;
-r*|-[!-]r*|-[!-][!-]r*)
readonly restricted=true ;;
--restricted)
readonly restricted=true ;;
esac
done
unset a
else
is=sh
fi
#
# Call common progams from /bin or /usr/binonly
#
path ()
{
if test -x /usr/bin/$1 ; then
${1+"/usr/bin/$@"}
elif test -x /bin/$1 ; then
${1+"/bin/$@"}
fi
}
#初始化登入終端
# Initialize terminal
#
tty=`path tty 2> /dev/null`
test $? -ne 0 && tty=""
if test -O "$tty" -a -n"$PS1"; then
test -z "${TERM}" &&{ TERM=linux; export TERM; }
test "${TERM}" = "unknown" && { TERM=linux; export TERM; }
#Do not change settings on local line if connected to remote
if test -z "$SSH_TTY" -a "${TERM}" !="dumb" ; then
pathstty sane cr0 pass8 dec
pathtset -I -Q
fi
#on iSeries virtual console, detect screen size and terminal
if test -d /proc/iSeries -a \( "$tty" = "/dev/tty1"-o "$tty" = "/dev/console" \) ; then
LINES=24
COLUMNS=80
exportLINES COLUMNS TERM
if test -x /bin/initviocons ; then
eval `/bin/initviocons -q -e`
fi
fi
fi
unset TERMCAP
#不明
# Time until a complete key sequence musthave arrived
#ESCDELAY=2000
#export ESCDELAY
#
# The user file-creation mask
# The global umask value is stored in/etc/login.defs and
# will be set by pam_umask.so (see"man pam_umask").
#umask 022
#
# Setup for gzip and (t)csh users
#
if test -z "$PROFILEREAD" ; then
#GZIP=-9
#export GZIP
CSHEDIT=emacs
export CSHEDIT
fi
#
# ksh/ash sometimes do not know
#
test -z "$UID" && readonly UID=`path id -ur 2> /dev/null`
test -z "$EUID" && readonlyEUID=`path id -u 2> /dev/null`
test -z "$USER" &&USER=`path id -un 2> /dev/null`
test -z "$MAIL" &&MAIL=/var/spool/mail/$USER
test -z "$HOST" &&HOST=`/bin/uname -n 2> /dev/null`
test -z "$CPU" && CPU=`/bin/uname -m 2> /dev/null`
# Remark: /proc/sys/kernel/domainname andthe program domainname
# its self will provide the NIS/YPdomainname, see domainname(8).
if test -s /etc/HOSTNAME ; then
test -z "$HOSTNAME" && HOSTNAME=`cat /etc/HOSTNAME`
else
test -z "$HOSTNAME" && HOSTNAME=$HOST
fi
test -z "$LOGNAME" && LOGNAME=$USER
case "$CPU" in
i?86) HOSTTYPE=i386 ;;
*) HOSTTYPE=${CPU} ;;
esac
OSTYPE=linux
MACHTYPE=${CPU}-suse-${OSTYPE}
# Do NOT export UID, EUID, USER, andLOGNAME
export MAIL HOST CPU HOSTNAME HOSTTYPEOSTYPE MACHTYPE
#
# You may use /etc/initscript,/etc/profile.local or the
# ulimit package instead to set up ulimitsand your PATH.
#
# if test "$is" !="ash" -a ! -r /etc/initscript; then
# ulimit -Sc 0 # don'tcreate core files
# ulimit -Sd $(ulimit -Hd)
# ulimit -Ss $(ulimit -Hs)
# ulimit -Sm $(ulimit -Hm)
# fi
#
# Make path more comfortable
#
if test -z "$PROFILEREAD" ; then
PATH=/usr/local/bin:/usr/bin:/bin
if test "$HOME" != "/" ; then
fordir in $HOME/bin/$CPU $HOME/bin ; do
test -d $dir && PATH=$dir:$PATH
done
fi
if test "$UID" = 0 ; then
test-d /opt/kde3/sbin &&PATH=/opt/kde3/sbin:$PATH
PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
fi
for dir in /usr/X11/bin \
/usr/bin/X11\
/usr/X11R6/bin\
/var/lib/dosemu\
/usr/games\
/opt/bin\
/opt/kde3/bin\
/opt/kde2/bin\
/opt/kde/bin\
/usr/openwin/bin\
/opt/cross/bin
do
test-d $dir && PATH=$PATH:$dir
done
unset dir
export PATH
fi
#環境變量INPUTRC,設定加載快捷鍵
# Many programs using readline library forline editing
# should know about this (e.g. bash)
#
if test -z "$INPUTRC" ; then
INPUTRC=/etc/inputrc
test -s $HOME/.inputrc && INPUTRC=$HOME/.inputrc
export INPUTRC
fi
#
# Most bourn shell clones knows about this
#
if test -z "$PROFILEREAD" ; then
HISTSIZE=1000
export HISTSIZE
fi
#
# Set some environment variables forTeX/LaTeX (Not used due luatex)
#
#if test -n "$TEXINPUTS" ; then
# TEXINPUTS=":$TEXINPUTS:$HOME/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX"
#else
# TEXINPUTS=":$HOME/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX"
#fi
#export TEXINPUTS
#
# Configure the default pager on SuSE Linux
#
if test -z "$LESS" -a -x/usr/bin/less ; then
LESS="-M -I"
LESSOPEN="lessopen.sh %s"
LESSCLOSE="lessclose.sh %s %s"
LESS_ADVANCED_PREPROCESSOR="no"
if test -s /etc/lesskey.bin ; then
LESSKEY=/etc/lesskey.bin
fi
PAGER=less
MORE=-sl
export LESSOPEN LESSCLOSE LESS LESSKEY PAGER LESS_ADVANCED_PREPROCESSORMORE
fi
#
# Minicom
#
if test -z "$PROFILEREAD" ; then
MINICOM="-c on"
export MINICOM
fi
#
# Current manpath
#
if test -z "$PROFILEREAD" ; then
tmp="$MANPATH"
unset MANPATH
if test -n "$tmp" ; then
MANPATH="${tmp}:`test-x /usr/bin/manpath && /usr/bin/manpath -q`"
else
MANPATH="`test-x /usr/bin/manpath && /usr/bin/manpath -q`"
fi
unset tmp
export MANPATH
fi
#
# Some applications do not handle theXAPPLRESDIR environment properly,
# when it contains more than one directory.More than one directory only
# makes sense if you have a client with/usr mounted via nfs and you want
# to configure applications machinedependent. Uncomment the lines below
# if you want this.
#
#XAPPLRESDIR="$XAPPLRESDIR:/var/X11R6/app-defaults:/usr/X11R6/lib/X11/app-defaults"
#export XAPPLRESDIR
#
# Set INFOPATH to tell xemacs where he canfind the info files
#
if test -z "$PROFILEREAD" ; then
tmp="$INFODIR"
if test -n "$tmp" ; then
INFODIR="${tmp}:/usr/local/info:/usr/share/info:/usr/info"
else
INFODIR="/usr/local/info:/usr/share/info:/usr/info"
fi
INFOPATH=$INFODIR
unset tmp
export INFODIR INFOPATH
fi
#
# These settings are recommended for oldmotif applications
#
if test -z "$PROFILEREAD" ; then
if [ -r /usr/share/X11/XKeysymDB ]; then
exportXKEYSYMDB=/usr/share/X11/XKeysymDB
else
exportXKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
fi
if [ -d /usr/share/X11/nls ]; then
exportXNLSPATH=/usr/share/X11/nls
else
exportXNLSPATH=/usr/X11R6/lib/X11/nls
fi
#
#Midnight Commander needs this to run in color mode
#
COLORTERM=1
export COLORTERM
fi
#
# For RCS
#
#VERSION_CONTROL=numbered
#export VERSION_CONTROL
#
# Source the files generated by SuSEconfig
#
# But do not source this if PROFILEREAD isalready set to avoid
# overriding locale variables alreadypresent in the environment
#
if test -z "$PROFILEREAD" ; then
test -r /etc/profile.d/sh.ssh && . /etc/profile.d/sh.ssh
test -r /etc/SuSEconfig/profile && . /etc/SuSEconfig/profile
if test -z "$SSH_SENDS_LOCALE" ; then
if test -r /etc/sysconfig/language -a -r /etc/profile.d/sh.utf8 ; then
tmp="$(. /etc/sysconfig/language; echo$AUTO_DETECT_UTF8)"
test "$tmp" = "yes"&& . /etc/profile.d/sh.utf8
unset tmp
fi
fi
fi
#
# Source profile extensions for certainpackages, the super
# may disable some of them by setting thesticky bit.
#
if test -d /etc/profile.d -a -z"$PROFILEREAD" ; then
for s in /etc/profile.d/*.sh ; do
test-r $s -a ! -k $s && . $s
done
unset s
fi
if test "$is" != "ash"; then
#
#And now let's see if there is a local profile
#(for options defined by your sysadmin, not SuSE Linux)
#
test -s /etc/profile.local && . /etc/profile.local
fi
#
# System wide configuration of bourneshells like ash
#
if test "$is" != "ksh"-a "$is" != "zsh" -a -z "$PROFILEREAD" ; then
ENV=/etc/bash.bashrc
export ENV
fi
#
# Avoid overwriting user settings if calledtwice
#
if test -z "$PROFILEREAD" ; then
readonly PROFILEREAD=true
export PROFILEREAD
fi
#
# Standard ssh command does not do anlogin, therefore
# /etc/profile will be sourced by/etc/bash.bashrc
#
if test -z "$_SOURCED_FOR_SSH" ;then
#
#System BASH specials, maybe also good for other shells
#Note that ksh always reads /etc/ksh.kshrc
#
if test "$is" != ksh -a "$is" != zsh ; then
test-r /etc/bash.bashrc && . /etc/bash.bashrc
fi
if test -n "$restricted" ; then
readonly_HOMEBASHRC=true
fi
if test "$is" = "bash" -a -z"$_HOMEBASHRC" ; then
#loop detection
readonly_HOMEBASHRC=true
test-r $HOME/.bashrc && . $HOME/.bashrc
fi
#
#KSH specials
#
if test "$is" = "ksh" -a -r /etc/ksh.kshrc ; then
iftest -n "$restricted" ; then
readonly _HOMEKSHRC=true
fi
iftest ! /etc/bash.bashrc -ef /etc/ksh.kshrc ; then
test -r /etc/bash.bashrc && ./etc/bash.bashrc
fi
iftest -n "$ENV" -a "$ENV" != "\$HOME/.kshrc" -a -z"$_HOMEKSHRC" ; then
# loop detection
readonly _HOMEKSHRC=true
test -r $HOME/.kshrc && .$HOME/.kshrc
fi
fi
fi
if test -n "$restricted" ; then
PATH=/usr/lib/restricted/bin
export PATH
fi
#
# An X session
#
case "$-" in
*i*)
if test "$TERM" = "xterm" -a -O "$tty" ;then
iftest -z "${SSH_TTY}" ; then
test ! -f $HOME/.hushlogin -a -s /etc/motd&& cat /etc/motd
echo"Directory: $PWD"
# Last but not least
date
fi
#
#shadow passwd
#Note: on normal console this will be done by /bin/login
#iftest -r /var/log/faillog ; then
# test -x /bin/faillog &&/bin/faillog
# test -x /usr/sbin/faillog &&/usr/sbin/faillog
#fi
fi
esac
#專門為Oracle使用者添加的限制條件
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#JAVA的環境變量,這可以讓所有建立使用者都是用同一套JDK環境
JAVA_HOME=/usr/local/jdk1.7.0_67
CLASSPATH=.:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
# End of /etc/profile
個人使用者配置檔案.bash_profile
SUSE中這個檔案命名為.bashrc,在這裡配置的環境變量、别名等資訊隻針對目前使用者生效。
該檔案的模闆位于/etc/skel目錄下。