新安装的hirsute = 21.04安装在软件包之外,创建我自己的个人帐户,默认的.bashrc在我的家庭中存在,并确保有一个.bash_aliases。都提到了alias ll='ls -alF',但登录后这个别名仍然不可用。这是窃听器还是我漏掉了什么?
NAME="Ubuntu"
VERSION="21.04 (Hirsute Hippo)"
karel@schal:~$ pwd ; ls -al .bash*
/home/karel
-rwxr-xr-x 1 karel users 53 Sep 26 06:22 .bash_aliases
-rw------- 1 karel users 9834 Sep 26 06:23 .bash_history
-rw-r--r-- 1 karel users 3771 Aug 31 23:17 .bashrc
karel@schal:~$ cat .bash_aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
karel@schal:~$ ll
ll: command not found编辑后,一个不太友好的评论,以补充:
karel@wiske:~$ ssh karel@192.168.0.210
karel@192.168.0.210's password:
Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-34-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
0 updates can be applied immediately.
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Last login: Sun Sep 26 09:37:21 2021
karel@schal:~$ alias
karel@schal:~$ /bin/bash
karel@schal:~$ alias
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'而且这种行为是相同的,无论是在每个ssh中,还是在本地图形环境中,还是在本地文本专用控制台(dev/tty5 5和类似的)中。
此外,根据要求,摘自~/..bashrc:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fikarel@schal:~$ ls -al ~/.bash_profile ~/.bash_login ./.profile
ls: cannot access '/home/karel/.bash_profile': No such file or directory
ls: cannot access '/home/karel/.bash_login': No such file or directory
ls: cannot access './.profile': No such file or directory
karel@schal:~$ ps -p $ | tail -n1 | awk '{print $NF}'
bash发布于 2021-09-26 13:06:32
在通过ssh登录时,您正在运行的是一个交互式登录shell,而不是一个交互式的非登录shell,这是当您打开一个终端登录时会发生的情况。登录shell不读取~/.bashrc,而是读取~/.profile、~/.bash_profile和~/.bash_login。这就是你的化名不存在的原因。有关此问题的详细信息以及各种shell类型的初始化文件之间的差异,请参见为什么忽略/etc/profile.d/中的脚本(全系统bash别名)?。这也是为什么您在运行/bin/bash时会得到别名的原因,因为它启动了一个非登录shell并将读取~/.bashrc。
尽管如此,Ubuntu的默认~/.profile文件包括以下几行:
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi因此,它实际上也应该是阅读您的~/.bashrc。如果没有发生这种情况,我怀疑以下情况之一:
~/.bash_profile文件。这将导致忽略~/.profile文件。正如在man bash中所解释的:当bash作为一个交互式登录shell调用,或者作为一个具有- login选项的非交互式shell调用时,它首先从文件/etc/profile中读取和执行命令,如果该文件存在。读取该文件后,it将按照该顺序查找~/..bash_profile、~/..bash_login和~/.profile,并从第一个存在且可读性的文件中读取和执行com- mands。当shell开始抑制此行为时,可以使用--noprofile选项.因此,如果存在~/.bash_profile或~/.bash_login,那么~/.profile中的任何内容都会被忽略。~/.profile,它不是~/.bashrc的源。ps -p $ | tail -n1 | awk '{print $NF}'来检查这一点。如果输出不是bash,则运行不同的shell。也许您已经将默认的登录shell设置为sh,这是Ubuntu上的dash。您可以使用echo $SHELL检查当前值,也可以用chsh更改它。根据您最近的编辑,您的情况似乎是:
~/.profile。而且,根据您上一次编辑,情况似乎是这样的。因此,只要从.profile中复制默认的/etc/skel,下次登录时就会很好: cp /etc/skel/..profile ~/发布于 2021-09-26 14:31:04
@terdon说得对:不知出于什么原因,我家里没有.profile。一切都好--就像建议的-- cp /etc/skel/.profile ~
https://askubuntu.com/questions/1365828
复制相似问题