简体   繁体   English

bash:/home/x/.bash_profile:权限被拒绝。 如何解决这个问题?

[英]bash: /home/x/.bash_profile: Permission denied. How to fix this issue?

I am trying to open the bash_profile file but it gives the following result我正在尝试打开 bash_profile 文件,但它给出了以下结果

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

After searching I found this solution on the internet经过搜索,我在互联网上找到了这个解决方案

source ~/.bash_profile

But this command gives the following output但是这个命令给出了以下 output

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

when I typed it gives this result当我输入时,它给出了这个结果

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

please help me how to fix it.请帮我解决它。

Thank you All.谢谢你们。

For viewing the bash_profile: cat ~/.bash_profile查看 bash_profile: cat ~/.bash_profile

For editing: vi ~/.bash_profile编辑: vi ~/.bash_profile

If you get a permission denied, use sudo before cat or vi commands.如果您的权限被拒绝,请在catvi命令之前使用 sudo。

Hello你好

And for only creating your own without editing it...并且只创建自己的而不编辑它......

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

... if already exists then only the modification time is changing. ...如果已经存在,那么只有修改时间在改变。 I wrote the simple command cryptic because set -x shows what going on and set +x exits the debug mode.我写了一个神秘的简单命令,因为set -x显示发生了什么并且set +x退出调试模式。

After the clarifications, let me tell you what is happening.在澄清之后,让我告诉你发生了什么。

The ~/.bash_profile file is a configuration file for configuring user environments. ~/.bash_profile 文件是用于配置用户环境的配置文件。 The users can modify the default settings and add any extra configurations on it.用户可以修改默认设置并在其上添加任何额外的配置。 In your case, the file is empty and it is throwing an error because inside the file you have the word "the".在您的情况下,该文件是空的并且它会引发错误,因为在文件中您有单词“the”。

You Linux Server is trying to run the command "the", so the reason for the error you are getting is that you have no execution privileges over it.您 Linux 服务器正在尝试运行命令“the”,因此您收到错误的原因是您没有执行权限。 I've never ever heard of a program called "the", but giving your error perhaps the program is there.我从来没有听说过一个叫做“the”的程序,但是给出你的错误也许程序就在那里。 If the program did not exist, you would have gotten "No such file or directory".如果该程序不存在,您将得到“没有这样的文件或目录”。

Replace the content of the.bash_profile with the minimum content you need for this kind of file:将 .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
    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM