/etc/profile 是一个目录[关闭]

问题描述 投票:0回答:1

在我的 RHEL8 上,/etc/profile 是一个目录而不是文件,因此当启动与计算机的 ssh 连接时,我得到

bash: /etc/profile: is a directory
。我可以看到该目录,因为我可以
cd
进入其中,并且它包含多个 .sh 或 .csh 文件。我还可以在其中找到配置文件,指示执行路径应该是
/etc/profile/profile
而不是
/etc/profile

我需要解决这个问题的原因是因为我想将自定义的shell文件放在/etc/profile.d目录中,但只有在实际调用/etc/profile时才会调用它。在这种情况下,由于 /etc/profile 是目录错误而不会被调用。

我尝试执行

sudo cp /etc/profile/profile /etc/profile
,看看将文件路径复制到 /etc 目录是否有效;然而,我得到了
cp: '/etc/profile/profile' and '/etc/profile/profile' are the same file

我们将不胜感激!

linux bash redhat
1个回答
0
投票

在我的 RHEL8 上,/etc/profile 是一个目录而不是文件

我不知道这种情况是如何出现的,但这对于 RHEL8 来说是不正常的,并且对于 RHEL 的默认 shell Bash 来说也是不正确的。

我可以看到该目录,因为我可以通过 cd 进入该目录,并且它包含多个 .sh 或 .csh 文件。

你确定你不是在看

/etc/profile.d
吗?在 RHEL、Ubuntu 和其他一些发行版上,这确实是一个如您所描述的目录。

我还可以在其中找到配置文件,指示执行路径应该是

/etc/profile/profile
而不是
/etc/profile

我认为这表明您的系统配置已被破坏。我无法说这是有意的还是无意的,如果是故意的,是有益的还是恶意的。无论如何,它显然产生了一些不良影响。

我尝试执行

sudo cp /etc/profile/profile /etc/profile
,看看将文件路径复制到 /etc 目录是否有效;然而,我得到了
cp: '/etc/profile/profile' and '/etc/profile/profile' are the same file

要恢复到标准配置,请将目录

/etc/profile
重命名为其他名称,例如
/etc/profile.oops
。然后将
profile
脚本移出其正常位置:
sudo mv /etc/profile.oops/profile /etc/profile

但请注意,根据此问题的产生方式,可能还有其他问题需要解决。例如,当前位于

/etc/profile
目录中的某些脚本可能应该位于
/etc/profile.d
中。可能。或者,如果更改与计算机受到恶意攻击者的危害有关,那么您最好的选择可能是执行完全擦除并重新安装。

© www.soinside.com 2019 - 2024. All rights reserved.