日期:2014-05-16  浏览次数:20621 次

Linux开机启动和用户登录启动配置

 

1. 开机启动配置文件

       一般来说Linux会用不同的level开机,可以用

#runlevel

来查看运行的level。而关于level的配置,可以在 /etc/inittab中找到,如下:

 # Default runlevel. The runlevels used by RHS are:
 #   0 - halt (Do NOT set initdefault to this)
 #   1 - Single user mode
 #   2 - Multiuser, without NFS (The same as 3, if you do not have networking    )
 #   3 - Full multiuser mode
 #   4 - unused
 #   5 - X11
 #   6 - reboot (Do NOT set initdefault to this)
 #
 id:5:initdefault:

从注释的部分可以看到Linux系统启动分为0~6一共7个级别,而此处默认启动在第5个级别上,X11即为图形桌面方式启动

[root@emma_test_server etc]# cd rc
rc          rc1.d/      rc3.d/      rc5.d/      rc.d/       rc.sysinit
rc0.d/      rc2.d/      rc4.d/      rc6.d/      rc.local
在系统/etc目录下,我们可以找到rc0.d ~ rc6.d 启动文件夹,其中保存的即为Linux在相应级别启动时所调用的启动文件,打开rc5.d我们可以看到:

[root@emma_test_server rc5.d]# ls -l
total 296
lrwxrwxrwx 1 root root 17 Aug 26  2011 K01dnsmasq -> ../init.d/dnsmasq
lrwxrwxrwx 1 root root 24 Aug 26  2011 K02avahi-dnsconfd -> ../init.d/avahi-dnsconfd
lrwxrwxrwx 1 root root 24 Aug 26  2011 K02NetworkManager -> ../init.d/NetworkManager
lrwxrwxrwx 1 root root 16 Aug 26  2011 K05conman -> ../init.d/conman
lrwxrwxrwx 1 root root 19 Aug 26  2011 K05saslauthd -> ../init.d/saslauthd
lrwxrwxrwx 1 root root 17 Aug 26  2011 K05wdaemon -> ../init.d/wdaemon
lrwxrwxrwx 1 root root 19 Aug 26  2011 K10dc_server -> ../init.d/dc_server
lrwxrwxrwx 1 root root 16 Aug 26  2011 K10psacct -> ../init.d/psacct
lrwxrwxrwx 1 root root 19 Aug 26  2011 K12dc_client -> ../init.d/dc_client
lrwxrwxrwx 1 root root 15 Aug 26  2011 K15httpd -> ../init.d/httpd
lrwxrwxrwx 1 root root 14 Aug 26  2011 K24irda -> ../init.d/irda
lrwxrwxrwx 1 root root 15 Aug 26  2011 K25squid -> ../init.d/squid
lrwxrwxrwx 1 root root 19 Aug 26  2011 K35vncserver -> ../init.d/vncserver
lrwxrwxrwx 1 root root 17 Aug 26  2011 K35winbind -> ../init.d/winbind
lrwxrwxrwx 1 root root 20 Aug 26  2011 K50netconsole -> ../init.d/netconsole
..........

其中包含了大量的链接文件,都是链接到/etc/init.d目录下的启动文件,这些文件负责启动相应的应用程序或者服务。


2. 用户登录启动:

1/etc/profile此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置。
2/etc/bashrc: 为每一个运行bash shell的用户执行此文件.bash shell被打开时,该文件被读取。
3 ~/.bash_profile: 每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一