.shash登陸ssh登錄[關閉]

當我進入運行Hardy 8.04的ubuntu-box時,個人.bashrc中的環境變量沒有設置。 shell

若是我作一個源.bashrc,變量是正確設置的,一切都很好。 ubuntu

爲何.bashrc不會在登陸時運行? bash


#1樓

我有像霍布豪斯這樣的狀況。 我想用命令 ssh

ssh myhost.com 'some_command'

而且'some_command'存在於'/ var / some_location'中,因此我嘗試經過編輯'$ HOME / .bashrc'在PATH環境中追加'/ var / some_location' spa

但那不起做用。 由於默認.bashrc(Ubuntu 10.4 LTS)阻止經過下面的代碼來源 code

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

因此若是你想改變ssh非登陸shell的環境。 你應該在該行之上添加代碼。 資源


#2樓

使用SSH登陸時,不會獲取.bashrc 。 您須要在.bash_profile它,以下所示: get

if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

#3樓

若是ayman的解決方案不起做用,請嘗試命名文件.profile而不是.bash_profile 。 這對我有用。 io


#4樓

有關bash調用如何工做的優秀資源,什麼dotfiles作什麼,以及如何使用/配置它們,請閱讀: 登錄

相關文章
相關標籤/搜索