
我有兩個同名的一致配置文件,如下所示:
/root/.unison/theprofile.prf
/home/users/itsme/.unison/theprofile.prf
兩者的內容不同。它們以相同的遠端伺服器為目標(透過 SSH),但在該伺服器上有自己的目錄。
我執行以下命令:
sudo unison theprofile
我預計其中的個人資料/root/.unison/theprofile.prf
已被獲取,但出於某種原因我不明白其中的個人資料/home/users/itsme/.unison/theprofile.prf
已被獲取。
這是為什麼?我怎麼才能允許root
擁有自己的一致配置文件,而不與配置文件發生衝突itsme
(反之亦然)?理想情況下,他們甚至對彼此一無所知。
答案1
當您使用 just 時sudo
,您可以切換用戶,但保留舊用戶的環境變數。因此itsme
使用來自的配置文件,因為它仍然是當前的主目錄。
如果您想完全切換到 root,包括所有環境變量,則必須使用該-i
參數執行 sudo,以便它建立一個登入 shell。
sudo -i unison theprofile
然後它將使用根主目錄中的設定檔。