Accidentally (chmod 755) the whole thing
I meant to run
find . -type d -exec chmod 755 {} \; on a certain folder, but did it to / by mistake. I ctrl+c'd pretty quick, but I think it did some damage cause now I get an error on one of my webpages (I'm running apahce and mysql). The error is: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/tmp/#sql_5916_0.MYI' (Errcode: 13) When trying to install magento |
chmod 1777 /tmp
Code:
drwxrwxrwt 5 root root 4096 Mar 20 04:02 /tmp |
The best bet could be to reinstall ALL the packages in your system, if your package manager allows that at all, if not I guess that everything will be fixed with the time as packages get updated.
The most important bit if you are running servers of any kind is to revise by hand the permissions in your server directories and files, and in everything under /home and /etc. |
cool
|
By the way, I see this same problem regularly but I've never seen anyone doing a backup or the file permissions, it could be a worthy idea to consider if you are afraid of mistakes like these. I never though of this myself, but the idea just came to me and it would be very simple to do so. Something like the following code should backup all the permissions in your system and save them into a plain text file, that you can use for either future reference or even to restore them all using a simple loop to feed chmod:
Code:
find /path/to/ -exec stat --format="%a %n" "{}" \; > chmod.txt Just a random idea I had. Not sure if anyone will care about it :) |
Quote:
grtz, Marvelade |
Quote:
Code:
find /path/to/ -exec stat --format="%a %n" "{}" \; > chmod.txt Code:
find /path/to/ Code:
-exec stat --format="%a %n" "{}" \; Code:
> chmod.txt This information could be used in these cases to restore the permissions either manually, or using a self made script that reads from this file, and chmods everything accordingly. I don't know if some serious tool exist for this, but seeying how amazingly simple would be to develop one and the number of persons that ask this same question from time to time here and in another forums, I am surprised that I have never heard of such a tool. And I suspect that maybe it doesn't exist, which is strange. This is just a quick idea, but it would be simple enough to implement it even with shell scripting. The simples case would be this: Code:
while read LINE; do PERMS=${LINE%% *}; FILE=${LINE#* }; chmod $PERMS "$FILE"; done < chmod.txt A simple backup system for file permissions. I can't see any downside to using this, BUT if you decide to use this, make your tests. I don't wanna feel responsible if my oneliners fry your pc or kill your kitten hehe :) EDIT: Fixed find command EDIT: Fixed line to restore |
or you could use R1Soft hot copy software which is free. the software allows you to take a snapshot of the system before making changes, and once the changes are made you can always revert back to the point before the change all on the CLI.
|
I do periodic (daily) / and /home backups using rsync. Rsync copies permissions.
So, faced with this disaster, I could either copy back the rsync'ed files to change the permissions, or I could construct the necessary permissions file as previously suggested, then use it to make repairs. I can't speak to all the backup programs out there, but I would expect that most would also backup permissions automatically. |
Quote:
|
watch out for symlinks, stat will return 777 for them, but if you use that value later via chmod it will change the permissions on the file/directory it points to, not the symlink.
So, Code:
find /path/to ! -type l -exec stat --format="%a %n" "{}" \; >perms.backup |
This is an interesting thread because I once did a chown -r tred:tred .* as root from my home directory and wondered (too late!!) why it was taking more than a moment to complete (think about it).
I reinstalled :( and I learnt to be better with backups. @pwc101, It might be thoughtful to post your refinements to i92guboj's script here. |
Yes, this is great stuff. So thanks to all, especially i92guboj, pwc101 and GazL
cheers, |
Quote:
Code:
find . -type d -exec echo chmod 755 {} \; |
Quote:
Quote:
|
All times are GMT -5. The time now is 08:05 PM. |