bash如何重置/etc的默认权限?

分享于 

1分钟阅读

ubuntu

  繁體

问题

我对/etc错误地进行了权限更改,现在它给我以下错误消息:


bash: /etc/bash.bashrc: Permission denied 


I have no name!@chandan-Inspiron-5520:~$ sudo /etc/init.d/apache2 restart 


sudo: unable to stat /etc/sudoers: Permission denied 


sudo: no valid sudoers sources found, quitting 


sudo: unable to initialize policy plugin 




答案1

执行以下操作:


$ sudo su


chown -R root:root /etc


find /etc -type f -exec chmod 644 {} +


find /etc -type d -exec chmod 755 {} +


chmod 755 /etc/init.d/* /etc/rc.local /etc/network/* /etc/cron.*/*


chmod 400 /etc/ssh/ssh*key




答案2

在ubuntu服务器的全新安装中,运行以下命令:


find /etc -type f -executable | awk '{printf("chmod a+x %sn",$0);}' > setexec.sh




答案3


gksudo chown -R root:root /etc/


gksudo chmod -R u+x /etc/


gksudo chmod -R a+r /etc/





DEF  默认  BASH  重设  permission  
相关文章