Linux開機啟動和使用者登入啟動配置 .

來源:互聯網
上載者:User
1. 開機啟動設定檔

       一般來說Linux會用不同的level開機,可以用

 

[plain] view plaincopyprint?
  1. #runlevel  
#runlevel

來查看啟動並執行level。而關於level的配置,可以在 /etc/inittab中找到,如下:

 

 

[plain] view plaincopyprint?
  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:  
 # 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即為圖形案頭方式啟動

 

[plain] view plaincopyprint?
  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  
[root@emma_test_server etc]# cd rcrc          rc1.d/      rc3.d/      rc5.d/      rc.d/       rc.sysinitrc0.d/      rc2.d/      rc4.d/      rc6.d/      rc.local

在系統/etc目錄下,我們可以找到rc0.d ~ rc6.d 開機檔案夾,其中儲存的即為Linux在相應層級啟動時所調用的開機檔案,開啟rc5.d我們可以看到:

 

 

[plain] view plaincopyprint?
  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. ..........  
[root@emma_test_server rc5.d]# ls -ltotal 296lrwxrwxrwx 1 root root 17 Aug 26  2011 K01dnsmasq -> ../init.d/dnsmasqlrwxrwxrwx 1 root root 24 Aug 26  2011 K02avahi-dnsconfd -> ../init.d/avahi-dnsconfdlrwxrwxrwx 1 root root 24 Aug 26  2011 K02NetworkManager -> ../init.d/NetworkManagerlrwxrwxrwx 1 root root 16 Aug 26  2011 K05conman -> ../init.d/conmanlrwxrwxrwx 1 root root 19 Aug 26  2011 K05saslauthd -> ../init.d/saslauthdlrwxrwxrwx 1 root root 17 Aug 26  2011 K05wdaemon -> ../init.d/wdaemonlrwxrwxrwx 1 root root 19 Aug 26  2011 K10dc_server -> ../init.d/dc_serverlrwxrwxrwx 1 root root 16 Aug 26  2011 K10psacct -> ../init.d/psacctlrwxrwxrwx 1 root root 19 Aug 26  2011 K12dc_client -> ../init.d/dc_clientlrwxrwxrwx 1 root root 15 Aug 26  2011 K15httpd -> ../init.d/httpdlrwxrwxrwx 1 root root 14 Aug 26  2011 K24irda -> ../init.d/irdalrwxrwxrwx 1 root root 15 Aug 26  2011 K25squid -> ../init.d/squidlrwxrwxrwx 1 root root 19 Aug 26  2011 K35vncserver -> ../init.d/vncserverlrwxrwxrwx 1 root root 17 Aug 26  2011 K35winbind -> ../init.d/winbindlrwxrwxrwx 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資訊,當使用者登入時,該檔案僅僅執行一次!預設情況下,他設定一些環境變數,執行使用者的.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://blog.csdn.net/lrenjundk/article/details/8187610

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.