v78*_*v78 1 linux ssh bash bashrc
我正在尝试在 sudo-less 用户中的远程主机上获取我的 .bashrc 文件。我收到以下回复。
sh-4.2$ source .bash_profile
sh-4.2$ source: .bash_profile: file not found
sh-4.2$ source ~/.bash_profile
[user@hera ~]$
Run Code Online (Sandbox Code Playgroud)
为什么会出现这种行为?
.bashrc 的内容
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
# added by Anaconda3 4.1.1 installer
export PATH="/home/tensorflow/anaconda3/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)
您正在 POSIX 模式下使用 bash。
从man bash下source filename [arguments]
如果filename 不包含斜杠,则使用PATH 中的文件名查找包含filename 的目录... 当bash 不处于posix 模式时,如果在PATH 中找不到文件,则搜索当前目录。
Bash 正在 posix 模式下运行,因为您已启动它sh而不是bash(因此命令提示符为sh-4.2)。您需要将 shell 更改/bin/bash为 以使用这样的“bash-isms”。