Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 設定檔完全指南:使用者與系統層級配置檔詳解

編輯:Linux 教學

使用者家目錄設定檔

檔案用途引用時機
~/.bash_profileBash 登入 Shell 主設定登入後,/etc/profile 之後
~/.bash_login備選登入設定.bash_profile 不存在時
~/.profileBourne 相容設定前兩者都不存在時
~/.bashrc互動式非登入 Shell開啟終端機、執行腳本
~/.bash_logout登出時執行登出時
~/.bash_history指令歷史紀錄持久化儲存

常用應用程式設定檔

  • 編輯器:~/.vimrc (Vim)、~/.exrc (Vi)
  • 郵件:~/.muttrc (Mutt)、~/.pinerc (Pine)、~/.mail.rc
  • 版控:~/.gitconfig、~/.subversion/
  • SSH:~/.ssh/config、~/.ssh/authorized_keys
  • 桌面環境:~/.xinitrc、~/.Xdefaults、~/.gtkrc、~/.kderc
  • 網路工具:~/.netrc (FTP)、~/.ncftp/、~/.wgetrc
  • 其他:~/.forward (郵件轉寄)、~/.rhosts (rsh/rlogin)、~/.signature (郵件簽名)

系統層級設定檔 /etc/

檔案功能
/etc/profile所有使用者登入 Shell 共用設定
/etc/bashrc系統級 Bash 互動式設定
/etc/inittabinit 程序啟動控制,執行等級定義
/etc/fstab檔案系統掛載表
/etc/passwd使用者帳號資訊
/etc/shadow加密密碼儲存
/etc/group群組定義
/etc/hosts主機名稱解析
/etc/resolv.confDNS 解析器設定
/etc/sysconfig/network網路基礎設定 (RedHat 系)
/etc/ssh/sshd_configSSH 服務端設定
/etc/sudoerssudo 權限控制
/etc/crontab系統排程任務
/etc/logrotate.conf日誌輪轉設定
/etc/ld.so.conf動態連結器路徑

/proc 虛擬檔案系統

核心資料結構介面,僅存在記憶體中:

  • /proc/cpuinfo:CPU 資訊
  • /proc/meminfo:記憶體使用狀況
  • /proc/version:核心版本
  • /proc/mounts:目前掛載點
  • /proc/modules:已載入核心模組
  • /proc/<PID>/:程序詳細資訊

設定檔優先順序與最佳實務

  1. 系統全域 /etc/profile → 使用者 ~/.bash_profile → ~/.bashrc
  2. 環境變數設定於 .bash_profile,別名與函數設定於 .bashrc
  3. .bash_profile 中 source ~/.bashrc 確保登入 Shell 也載入互動式設定
  4. 使用 source 或 . 立即生效,無需重新登入
  5. 敏感設定 (SSH 金鑰、.netrc) 檔案權限必須 600

熟悉設定檔架構,能讓您精準控制 Linux 環境行為,提升開發與運維效率。

Copyright © Windows教程網 All Rights Reserved