运行以下命令时,我无法在主机帐户上扩展别名:
ssh user@server "bash -c \"alias\""
我的.bashrc文件是:
echo .bashrc
# .bashrc
shopt -s expand_aliases
# Source global definitions (commenting this out does nothing)
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
alias php="php55"
alias composer="php ~/bin/composer.phar"
当我运行上面的ssh命令时,我确实看到了“ .bashrc”回显。但是,如果我尝试运行别名,我将一无所获。
我可以尝试“ bash -ic”,但这实际上是在脚本中,我无法轻易对其进行更改,并且我想知道为什么它不起作用。
输出 ssh user@server "bash -c \"shopt\""
.bashrc
autocd off
cdable_vars off
cdspell off
checkhash off
checkjobs off
checkwinsize off
cmdhist on
compat31 off
compat32 off
compat40 off
dirspell off
dotglob off
execfail off
expand_aliases off
extdebug off
extglob off
extquote on
failglob off
force_fignore on
globstar off
gnu_errfmt off
histappend off
histreedit off
histverify off
hostcomplete on
huponexit off
interactive_comments on
lithist off
login_shell off
mailwarn off
no_empty_cmd_completion off
nocaseglob off
nocasematch off
nullglob off
progcomp on
promptvars on
restricted_shell off
shift_verbose off
sourcepath on
xpg_echo off
输出 ssh user@server "bash -c \"echo $SHELL\""
.bashrc
/bin/bash
~/.local/bin
在/etc/profile
处理时将其自动添加到您的PATH中。您也可以. /etc/profile
在创建文件夹后立即将其添加到您的PATH中,而无需重新启动或注销/登录。
$PATH
为~/bin:$PATH
它工作得很好。