linux - 别名在 Linux 机器上不起作用

标签 linux bash alias

我在 root 下的 .bash_profile 中创建了一堆别名,但这些别名不起作用。任何人都可以帮助我做错什么

 # .bash_profile
 #shopt -s expand_aliases
 # Get the aliases and functions
 if [ -f ~/.bashrc ]; then
     . ~/.bashrc
 fi

# User specific environment and startup programs

export JAVA_HOME=/opt/app/java
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin

export PATH

#Alias 
alias jfiles="cd /opt/app/Projects"
alias jscripts='cd /opt/app/Config'
alias jmres='cd /opt/app/tomcat/jmresources'
alias llrt='ll -r -t'

最佳答案

别名的正确位置应该是 .bashrc 而不是 .bash_profile 在 .bashrc 中添加别名后,开始新的登录 session 或只运行 .bashrc 文件,即 ./.bashrc

关于linux - 别名在 Linux 机器上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44222823/

相关文章:

perl - 如何让 Perl 运行我在 BASH 中定义的别名?

linux - 从不受限用户运行时如何在文件上保留 SELinux 上下文

bash - 输入文件为输出文件错误

regex - 从遵循 bash 脚本模式的单行中删除主机名

bash:模式 x 和 y 之间的单独行 block

mysql - 在Mysql中更改属性名称

SELECT * 列的 MySQL 别名

linux - 制作安装和环境变量

linux - 管道到不接受管道的命令

linux - sed 命令编辑多个文件(插入,替换行)