bash:/home/x/.bash_profile:权限被拒绝

时间:2020-07-18 09:28:46

标签: linux bash unix

我正在尝试打开bash_profile文件,但结果如下

~/.bash_profile 
bash: /home/x/.bash_profile: Permission denied

搜索后,我在互联网上找到了该解决方案

source ~/.bash_profile

但是此命令给出以下输出

The program 'the' is currently not installed. You can install it by typing:
sudo apt install the

当我输入时,它会给出结果

sudo apt install
[sudo] password for x:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove, and 0 not upgraded.
x@ubuntu:~$ source ~/.bash_profile
The program 'the' is currently not installed. You can install it by typing:
sudo apt install the

请帮助我解决问题。

谢谢大家。

3 个答案:

答案 0 :(得分:1)

要查看bash_profile,请执行以下操作: cat ~/.bash_profile

编辑: vi ~/.bash_profile

如果您拒绝了权限,请在catvi命令之前使用sudo。

答案 1 :(得分:1)

你好

仅用于创建自己的内容而不进行编辑...

set -x && $(type -p touch) ${HOME}"/.bash_profile"; set +x

...如果已经存在,则仅修改时间在更改。 我写了一个简单的命令cryptic,因为set -x显示了正在发生的事情,set +x退出了调试模式。

答案 2 :(得分:0)

澄清之后,让我告诉您发生了什么事。

〜/ .bash_profile文件是用于配置用户环境的配置文件。用户可以修改默认设置并在其上添加任何其他配置。在您的情况下,文件为空,并且会引发错误,因为在文件中您有单词“ the”。

您的Linux Server试图运行命令“ the”,因此出现错误的原因是您对该命令没有执行特权。我从未听说过一个名为“ the”的程序,但是给您的错误也许是程序在那儿。如果该程序不存在,那么您将获得“无此文件或目录”。

用这种文件所需的最少内容替换.bash_profile的内容:

$ cat ~/.bash_profile
# .bash_profile

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

# User specific environment and startup programs

export PATH=.:$PATH:$HOME/.local/bin:$HOME/bin