现在的位置: 首页 > 综合 > 正文

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

2018年05月03日 ⁄ 综合 ⁄ 共 2709字 ⁄ 字号 评论关闭

1. 开机启动配置文件

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

 

runlevel

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

 

 

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

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

 

  1. [root@emma_test_server etc]# cd rc  
  2. rc          rc1.d/      rc3.d/      rc5.d/      rc.d/       rc.sysinit  
  3. rc0.d/      rc2.d/      rc4.d/      rc6.d/      rc.local  

在系统/etc目录下,我们可以找到rc0.d ~ rc6.d 启动文件夹,其中保存的即为Linux在相应级别启动时所调用的启动文件,打开rc5.d我们可以看到:

 

 

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

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

 

 

2. 用户登录启动:

 

1/etc/profile此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行并从/etc/profile.d目录的配置文件中搜集shell的设置。
2/etc/bashrc: 为每一个运行bash
shell
的用户执行此文件.bash shell被打开时,该文件被读取。
3 ~/.bash_profile: 每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件。
4 ~/.bashrc: 该文件包含专用于你的bash
shell
bash信息,当登录时以及每次打开新的shell,该该文件被读取。
5
~/.bash_logout:
当每次退出系统(退出bash shell),执行该文件.
另外,/etc/profile中设定的变量(全局)的可以作用于任何用户,~/.bashrc等中设定的变量(局部)只能继承
/etc/profile
中的变量,他们是"父子"关系。
6~/.bash_profile 是交互式、login 方式进入 bash 运行的~/.bashrc 是交互式 non-login 方式进入 bash 运行的通常二者设置大致相同,所以通常前者会调用后者。


原文地址:http://www.cnblogs.com/xd502djj/archive/2013/02/18/2915405.html

抱歉!评论已关闭.