WSL的CentOS7使用systemctl和service命令時(shí)報(bào)錯(cuò)Failed to get D-Bus connection: Operation not permitted
,
解決辦法是更換systemctl文件
首先備份systemctl文件
mv /usr/bin/systemctl /usr/bin/systemctl.old
然后執(zhí)行
curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py > /usr/bin/systemctl
或者直接打開(kāi)這個(gè)網(wǎng)站https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py景醇,將頁(yè)面的所有內(nèi)容復(fù)制,再使用vim打開(kāi)systemctl文件并粘貼進(jìn)去保存
vim /usr/bin/systemctl
可能會(huì)出現(xiàn)卡頓
最后執(zhí)行
chmod +x /usr/bin/systemctl