/etc/init.d没有权限
时间: 2023-09-03 11:05:48 浏览: 22
如果您没有权限访问 /etc/init.d 目录,则可能需要以 root 用户身份登录系统或者使用 sudo 命令来执行相关操作。您可以尝试以下操作:
1. 以 root 用户身份登录系统,然后执行相关操作。
2. 在命令前加上 sudo,例如:
sudo command
其中 command 是您要执行的命令。
如果您不确定如何以 root 用户身份登录系统或使用 sudo 命令,请告诉我您的操作系统,我可以为您提供更具体的指导。
相关问题
rpm安装xinetd后没有/etc/init.d/xinetd
### 回答1:
如果你使用的是 RPM 包管理器,那么安装 xinetd 后,启动脚本应该位于 `/etc/rc.d/init.d/xinetd` 目录下,而不是 `/etc/init.d/xinetd`。
你可以尝试使用以下命令启动 xinetd 服务:
```
sudo /etc/rc.d/init.d/xinetd start
```
如果你仍然无法启动 xinetd 服务,可以尝试重新安装 xinetd 并检查启动脚本是否存在。如果启动脚本确实不存在,你可以手动创建一个启动脚本并将其放置在 `/etc/rc.d/init.d/` 目录下。
### 回答2:
在某些Linux发行版中,安装xinetd后,可能不会生成/etc/init.d/xinetd文件。这是因为xinetd服务被systemd所取代,并且systemd不使用传统的init.d脚本来管理服务。
使用systemd管理xinetd服务时,可以使用systemctl来控制服务的启动和停止等操作。下面是一些常用的systemctl命令:
- 启动xinetd服务:
sudo systemctl start xinetd
- 停止xinetd服务:
sudo systemctl stop xinetd
- 重启xinetd服务:
sudo systemctl restart xinetd
- 查看xinetd服务状态:
sudo systemctl status xinetd
- 设置xinetd服务开机自启动:
sudo systemctl enable xinetd
需要注意的是,以上命令需要使用root权限执行,也可以使用sudo命令提升权限。
此外,有些Linux发行版可能使用其他类似的工具来替代systemd,比如openrc或upstart。安装xinetd后,在/etc/init.d目录下可能会生成特定发行版所使用的脚本文件,如/etc/init.d/xinetd或/etc/init.d/xinet等。可以使用类似的命令来启动、停止和管理xinetd服务,如sudo service xinetd start/stop/restart。
总之,具体取决于所使用的Linux发行版和版本,xinetd服务的管理方式可能会有所不同。请根据具体情况使用相关命令来进行操作。
if [ -e /etc/init.d ];then #mv startppp.sh startppp.sh.bak cp /usr/local/dial/5g_test/startppp.sh /etc/init.d echo "文件移动成功" if [ -f /etc/init.d/startpp.sh ];then echo "文件存在" chmod -R 777 startppp.sh else echo "文件不存在" fi else echo "移动失败" fi为啥一直报文件不存在哪里出错了
在这段代码中,if [ -e /etc/init.d ]语句检查了/etc/init.d路径是否存在,如果存在,则执行cp命令将 /usr/local/dial/5g_test/startppp.sh 文件复制到/etc/init.d目录下,并重命名为startppp.sh 。之后,通过 if [ -f /etc/init.d/startpp.sh ] 语句再次检查/etc/init.d目录下是否存在startpp.sh文件,如果存在,则执行 chmod -R 777 startppp.sh 命令来修改startppp.sh文件的权限。
然而,你在修改权限时使用的是 startppp.sh 而不是 startpp.sh 。因此,你需要修改 chmod 命令中的文件名,将 startppp.sh 改为 startpp.sh 。
另外,建议你在 if [ -f /etc/init.d/startpp.sh ] 语句中使用正确的文件名,并且在检查文件是否存在之后再执行 chmod 命令。因此,你可以将代码修改为以下形式:
```
if [ -e /etc/init.d ]; then
#mv startppp.sh startppp.sh.bak
cp /usr/local/dial/5g_test/startppp.sh /etc/init.d/startpp.sh
echo "文件移动成功"
if [ -f /etc/init.d/startpp.sh ]; then
echo "文件存在"
chmod -R 777 /etc/init.d/startpp.sh
else
echo "文件不存在"
fi
else
echo "移动失败"
fi
```
这样就可以正确地移动文件并修改权限了。