LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   chmod -R 777 in root directory, please help (https://www.linuxquestions.org/questions/linux-newbie-8/chmod-r-777-in-root-directory-please-help-833017/)

beumont 09-18-2010 07:32 AM

chmod -R 777 in root directory, please help
 
I have unfortunately typed "chmod -R 777" in my "/" root directory...

I have some big issues know, please let me know if when I reboot the system the permissions gona change back to what they should be ?

MTK358 09-18-2010 07:41 AM

Quote:

Originally Posted by beumont (Post 4101639)
when I reboot the system the permissions gona change back to what they should be ?

Of course not.

beumont 09-18-2010 08:05 AM

So best thing do to is boot from cdrom and change permissions by hand ?

MTK358 09-18-2010 08:13 AM

Maybe. Perhaps someone else can make more suggestions.

Kenny_Strawn 09-18-2010 09:05 AM

I wonder what the default mode is for the root files (I'd say probably 644). Maybe you can change the permissions back to what they were, perhaps from the Live CD. If not, the only choice may be to reinstall, as many of the root directory files, albeit in other directories, have many different permissions.

Here's what I suggest: Boot from the live CD, and type this:

Code:

sudo chmod -R 644 /media/<your root drive>| grep -v home/*
This will change mode to 644 in all directories except /home.

MTK358 09-18-2010 09:18 AM

Quote:

Originally Posted by Kenny_Strawn (Post 4101712)
Code:

sudo chmod -R 644 /media/<your root drive>| grep -v home/*
This will change mode to 644 in all directories except /home.

NO, IT WON'T!

It will change all directories to 644, and if chmod prints each file it changes (which I doubt), it just won't print the ones for /home, but it will change them to 644.

Also, it will remove executable permission for directories, which means you won't be able to access them!

druuna 09-18-2010 09:30 AM

Hi,
Quote:

Originally Posted by beumont
I have unfortunately typed "chmod -R 777" in my "/" root directory...

You now have a big problem if you did this as root user.
Quote:

Originally Posted by beumont
So best thing do to is boot from cdrom and change permissions by hand ?

That would be theoretically possible, but not very practical. Do you know all the permissions of all the thousands of files and directories on your system?? (I have 496391 files and directories at present).

I would suggest backing up all the data (which you probably can restore to their intended permissions by hand), reinstalling your system and restoring the fixed back-up files.

Only way to be sure all is well again.

bathory 09-18-2010 09:44 AM

For Slackware you can use MANIFEST.bz2 and the smprms script to reset permissions.
Also for rpm based distros there is a solution here

Regards

whk 09-18-2010 10:30 AM

Reinstall.(period)
Chock it up to learning the hard way.
BTW, this might give you a reason to check out other Linux distros.
Also, check out other really bad moves with recursive.

jmc1987 09-18-2010 11:09 AM

Do you have a backup on your system? If you have critical info on your system you should away do a backup befor installing new software or system modifications so you can roll back with ease.

Reinstalling would be the easier solution but I know you can change all the files back with time and effort. Try to google a script or something that will help you perhaps.

trist007 09-18-2010 11:13 AM

Jeez. At least now you've learned how damaging things can be when you run as root.

I would just reinstall. However if for some reason you can't and you're not running slackware, I would run these two commands to at least get off to a start.

find / -type d -exec chmod 755 {} \;
find / -type f -exec chmod 644 {} \;

The first one finds all the directories and changes them to 755. The 2nd one find all the files and changes them to 644. Generally you want executable permissions on a directory so you or a program can 'cd' into them.

This will take care of the bulk of the filesytem. Then you still need to go in and modify all the stuff you want protected. There's actually a ton of stuff. You will have to go in and set permissions for all the things that should be secure.

Honestly you should just reinstall.

beumont 09-18-2010 03:41 PM

This is a good move to turn my system in too a virtual machine, the hard way...

I am runnning fedora 13 and when I ssh to the system I always use the root user, what is bad practice :(

Ssh is now not working anymore so I have to use the vnc viewer destkop, I will reinstll tomorow :)


All times are GMT -5. The time now is 04:53 AM.