.profile.d 分散式的 profile 設定檔管理 - Linux

Ophelia avatar
By Ophelia
at 2017-04-19T16:57

Table of Contents

# .profile.d #
# 分散式的 profile 設定檔管理專案 #
<https://github.com/Lin-Buo-Ren/.profile.d>

.profile 為類 Unix 作業系統中使用者登入後會一次性載入並執行的設定檔,主要用來
設定使用者的環境變數(包含作為可執行檔搜索路徑的 `PATH` 環境變數)。

本專案是用來放置原本使用者會放置於`〈家目錄〉/.profile` 個人設定檔的腳本片段,
這樣就可以最小程度地讓使用者自訂的 .profile 片段汙染 GNU/Linux 作業系統散佈版
本提供的版本且讓該片段可以被重複利用。

您需要在家目錄中新建 .profile.d 目錄(如果該目錄原本還沒存在的話),然後將您的
profile 個人設定檔片段以 .source.sh 副檔名寫進 .profile.d 目錄中,.profile 中
的程式會自動引入(source)並執行。

## 特色 / Features ##
* 備有將指定目錄插入 shell 可執行檔搜尋路徑(`PATH` 環境變數)中的工具函式
* 如果指定目錄不存在或是 `PATH` 中已有相同路徑將不會添加,避免增加搜尋路徑的多
餘時間

## 設定 / Setup ##
1. 將本版控庫拓製(clone)或下載解開到家目錄中的 .profile.d 目錄,確定
`README.setup` 與其他檔案位於 ~/.profile.d 目錄中
2. 在 ~/.profile 設定檔中加入下列內容:

# Setup .profile.d/
# https://github.com/Lin-Buo-Ren/.profile.d
. "${HOME}/.profile.d/README.setup"

您需要重新登出再登入才能讓設定生效

## 注意 / Remark ##
.profile 為通用的 script 程式,應使用 [POSIX.1-2008 規範的 shell script 語法
](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html )而
非 Bash 等殼層程式的專有語法撰寫

## 授權條款 / License ##
GPLv3+

--
Tags: Linux

All Comments

Liam avatar
By Liam
at 2017-04-23T16:17
source 裡面放中文路徑?
Cara avatar
By Cara
at 2017-04-25T07:58
純補個血
Cara avatar
By Cara
at 2017-04-29T09:29
複製貼上一不小心就u8←→b5轉碼了 還是盡量避免啦
Blanche avatar
By Blanche
at 2017-04-29T21:05
其實不同 shell 基本上設定檔案不大一樣
centos 來說用 bash, bash 是有機會讀取 .profile
Bennie avatar
By Bennie
at 2017-05-03T14:34
但是那也是 .bash_profile 找不到這類才有機會使用到
Elma avatar
By Elma
at 2017-05-07T00:35
幫補
Kelly avatar
By Kelly
at 2017-05-09T11:18
一般 centos 的 .bash_profile 主要是讀入 .bashrc
source .profile 必要性?其實我感覺主要是使用者
要瞭解 shell 程式讀取檔案的項目,貿然套 .profile
Quanna avatar
By Quanna
at 2017-05-11T04:31
不一定也正確。有人用 csh 這類不就破工了? 檔名不同
Erin avatar
By Erin
at 2017-05-13T06:11
簡單說這篇文章陳述的內容考量部分比較少就是
Quintina avatar
By Quintina
at 2017-05-17T06:51
George avatar
By George
at 2017-05-22T03:53
原帖樓主可以裝一下redhat或是centos瞭解它的設定檔案
設定規劃流程
Regina avatar
By Regina
at 2017-05-25T01:56
整體來說個人覺得您這一篇整個幫助性不高
Liam avatar
By Liam
at 2017-05-28T16:01
其實你只需要提供簡單幾行 for 迴圈敘述就好了
Queena avatar
By Queena
at 2017-05-30T04:54
說明提供的一些腳本達能目的用途就好了
Caitlin avatar
By Caitlin
at 2017-06-04T02:37
釣老人也很好用 XD
Gilbert avatar
By Gilbert
at 2017-06-05T18:27
老人大多有自己一套方式
Delia avatar
By Delia
at 2017-06-06T04:36
Life finds a way...
Ursula avatar
By Ursula
at 2017-06-10T22:56
其實直接改 PATH 比較直觀,包成函數反而要想一下
Kristin avatar
By Kristin
at 2017-06-12T10:54
shell scripting 本來就是每個人用自已的
除非要寫 pyenv 這種工具,不用追求相容性
Todd Johnson avatar
By Todd Johnson
at 2017-06-17T00:22
如果直接用environment modules?

bash讀檔案多跑出一個空白鍵

Kelly avatar
By Kelly
at 2017-04-19T00:35
[恕刪] ※ 引述《ringal (皓呆)》之銘言: : 最後只好修改了python把位元數刪掉,雖然能執行成功 : 不過最後MAC號命名的時候發現檔案都多了一個空白 : 實際: : MAC:112233445566 結果生成檔案名稱112233445566 .bin : 也確認過mac.t ...

xorg.conf 一直沒有作用

Thomas avatar
By Thomas
at 2017-04-18T18:26
OS: Antergos GPU: AMD RX460 最近因為影音需求想增加幾個畫面更新率,直接使用 xrandr 可以使用像是 47.95、71.93hz 等更新率,但是重開機這些設 定就會消失,所以打算創個 xorg.conf 來解決這問題。 我先是 sudo Xorg :1 -configur ...

losetup指令的問題

Anonymous avatar
By Anonymous
at 2017-04-18T09:58
請問 losetup -e 在使用上與 losetup cryptsetup 有何差異嗎? 有請擅長Linux的朋友替我解惑 謝 ...

bash讀檔案多跑出一個空白鍵

Kelly avatar
By Kelly
at 2017-04-18T08:06
小弟試著寫一個bash,自己抓檔案內的資料,然後丟進一個python程式生成檔案 由於python程式中有自動偵測MAC超過12位元就跳出的情況 在跑程式的時候不斷顯示MAC超過的12位元導致執行失敗 最後只好修改了python把位元數刪掉,雖然能執行成功 不過最後MAC號命名的時候發現檔案都多了一個空白 ...

安裝linux問題

Victoria avatar
By Victoria
at 2017-04-17T23:56
小弟在acer altos g330 mk2安裝centos7,遇過問題請教大家: 1.這張照片代表何意? http://i.imgur.com/OXuYRm2.jpg 2.後來同時選了兩顆硬碟後是可以灌了,也安裝完成後重新開機,開機之後就只出現ㄧ個 游標在左上角的全黑畫面,無法下一步,為什麼呢? 3.後 ...