共計(jì) 2198 個(gè)字符,預(yù)計(jì)需要花費(fèi) 6 分鐘才能閱讀完成。
今天丸趣 TV 小編給大家分享一下 linux 的環(huán)境變量怎么看的相關(guān)知識(shí)點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識(shí),所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。
linux 環(huán)境變量有兩個(gè)位置:1、“/etc”目錄下的 bashrc、profile 和 environment 文件,文件內(nèi)是已經(jīng)配置好的環(huán)境變量;2、用戶目錄下的“.bashrc”和“.bash_profile”文件,這兩個(gè)文件是都是隱藏文件。
本教程操作環(huán)境:linux7.3 系統(tǒng)、Dell G3 電腦。
linux 的環(huán)境變量在哪里
1、系統(tǒng)位置,/etc 目錄下的 bashrc、profile、environment 三個(gè)文件
2、用戶目錄(root 或普通用戶)下的.bashrc、.bash_profile 兩個(gè)文件,注意這兩個(gè)文件前面都有點(diǎn),是隱藏文件。
先說這 3 個(gè)系統(tǒng)文件,列出文件內(nèi)容(參考 CentOS7)。/**/ 為添加注釋
# /etc/bashrc
# System wide functions and aliases /* 系統(tǒng)廣泛功能(函數(shù))和別名 */
# Environment stuff goes in /etc/profile /* 環(huán)境東西(環(huán)境變量)在 /etc/profile 文件中 */
/* 修改這個(gè)文件不是一個(gè)好主意,除非你知道自己在干什么。*/
/* 在 /etc/profile.d/ 目錄下創(chuàng)建一個(gè)自定義腳本會(huì)是修改環(huán)境變量的更好方法 */
/* 但是會(huì)阻止在將來更新時(shí)合并的需要 */
# It s NOT a good idea to change this file unless you know what you
# are doing. It s much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging(合并) in future updates.
……………………………………………………………………
……………………………………………………………………
……………………………………………………………………
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It s NOT a good idea to change this file unless you know what you
# are doing. It s much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
……………………………………………………………………
……………………………………………………………………
……………………………………………………………………
第三個(gè)文件 environment 文件打開是一個(gè)空文件,不表。
再說兩個(gè)用戶文件,貼上文件內(nèi)容(參考 CentOS7)/**/ 為添加注釋
普通用戶:
root 用戶
# .bashrc
# User specific aliases and functions /* 用戶指定的別名和函數(shù)(功能)*/
alias rm= rm -i
alias cp= cp -i
alias mv= mv -i
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
# .bash_profile
# Get the aliases and functions /* 獲取別名和函數(shù)(功能)*/
if [ -f ~/.bashrc ]; then
. ~/.bashrc
# User specific environment and startup programs /* 用戶指定環(huán)境變量和啟動(dòng)程序(linux 開機(jī)啟動(dòng)程序放在這里?還沒有試過) */
PATH=$PATH:$HOME/bin
export PATH
這幾個(gè)文件的注釋已經(jīng)說得很清楚了,bashrc 文件是 用戶指定別名和函數(shù)(功能),bash_profile 文件是用來獲取 bashrc 文件中的別名和函數(shù)(功能),用戶還可以在此文件中指定環(huán)境變量和開機(jī)啟動(dòng)程序。在系統(tǒng)的 bashrc、和 bash_profile 文件明確說明 在 /etc/profile.d/ 目錄下創(chuàng)建一個(gè)自定義腳本會(huì)是修改環(huán)境變量的更好方法。如圖:
以上就是“l(fā)inux 的環(huán)境變量怎么看”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,丸趣 TV 小編每天都會(huì)為大家更新不同的知識(shí),如果還想學(xué)習(xí)更多的知識(shí),請(qǐng)關(guān)注丸趣 TV 行業(yè)資訊頻道。