溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

linux的環(huán)境變量怎么看

發(fā)布時間:2022-04-12 13:52:38 來源:億速云 閱讀:271 作者:zzz 欄目:建站服務器

今天小編給大家分享一下linux的環(huán)境變量怎么看的相關(guān)知識點,內(nèi)容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

linux環(huán)境變量有兩個位置:1、“/etc”目錄下的bashrc、profile和environment文件,文件內(nèi)是已經(jīng)配置好的環(huán)境變量;2、用戶目錄下的“.bashrc”和“.bash_profile”文件,這兩個文件是都是隱藏文件。

本教程操作環(huán)境:linux7.3系統(tǒng)、Dell G3電腦。

linux的環(huán)境變量在哪里

1、系統(tǒng)位置,/etc目錄下的bashrc、profile、environment三個文件

2、用戶目錄(root或普通用戶)下的.bashrc、.bash_profile兩個文件,注意這兩個文件前面都有點,是隱藏文件。

先說這3個系統(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文件中 */
/* 修改這個文件不是一個好主意,除非你知道自己在干什么。*/
/* 在/etc/profile.d/目錄下創(chuàng)建一個自定義腳本會是修改環(huán)境變量的更好方法 */
/* 但是會阻止在將來更新時合并的需要 */
# 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.
……………………………………………………………………
……………………………………………………………………
……………………………………………………………………

第三個文件environment文件打開是一個空文件,不表。

再說兩個用戶文件,貼上文件內(nèi)容(參考CentOS7)/**/為添加注釋

普通用戶:

linux的環(huán)境變量怎么看

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
fi
# .bash_profile
# Get the aliases and functions            /* 獲取別名和函數(shù)(功能)*/
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs    /* 用戶指定環(huán)境變量和啟動程序(linux開機啟動程序放在這里?還沒有試過) */
PATH=$PATH:$HOME/bin
export PATH

這幾個文件的注釋已經(jīng)說得很清楚了,bashrc文件是 用戶指定別名和函數(shù)(功能), bash_profile文件是用來獲取bashrc文件中的別名和函數(shù)(功能),用戶還可以在此文件中指定環(huán)境變量和開機啟動程序。在系統(tǒng)的bashrc、和bash_profile文件明確說明 在/etc/profile.d/目錄下創(chuàng)建一個自定義腳本會是修改環(huán)境變量的更好方法。如圖:

linux的環(huán)境變量怎么看

以上就是“l(fā)inux的環(huán)境變量怎么看”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI