Thursday, November 19, 2015

linux - how to recover from chmod 0644 -R /*



I had a big mistake



I run this command on a centos 6.8 server:



chmod 0644 -R /* instead of chmod 0644 -R ./*



now directory listing on root directory / and all files failed
when I run this command:



chmod 0775 -R /*


I get this error:




bash: /bin/chmod: Permission denied


how can I fix it without reinstall my centos?


Answer



Reinstalling the OS is by far the easiest and quickest way to fix this. Take an image backup first so you can recover anything that hadn't made it to your regular backup before the disaster happened.



The alternative is to boot from CentOS installation media or some other Linux live media, mount your CentOS system partitions on /mnt, and and then manually fix the permissions on every file and directory. Note that setting 775 globally is not enough to make your system usable again. There are files and directories that must have different permissions settings in order to work. This is long and tedious work, and you'll wish you had heeded the advice to reinstall.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...