Search code examples
debianfile-permissions

Is there a way to restore default file permissions in Debian squeeze?


I'm having a debian squeeze machine which has been changed recursively its file permissions to basically a position that now its unusable to start applications- terminals even. I googled but couldn't find any useful answers. Is there a way to restore all the default settings in debian squeeze ?


Solution

  • There really is no need to re-install or any other such drastic measures. With a little work the system will be fine, as long as you still have root access.

    You used the phrase "won't boot into any user account." From that I take you to mean that the system will boot you just can't log in as any user other than root.

    On any linux distro almost all files on the system except those in /home/[USERNAME] are owned by root.

    You are most likely authenticating as the other users just fine, but since their config files, etc. are owned by root the system cannot complete the login process. You can easily verify this by checking /var/log/auth.log

    The first thing I'd do is fix the file and directory permissions on the various user directories in /home to the appropriate user and group. This can be done from /home with a simple command.

    chown is the program you want. Read the man page for more info but basically just:

    chown [path to user's home directory (i.e. /home/user) -R username.username.
    

    Say for instance you had user 'foo'. You'd execute this command:

    chown -R foo.foo /home/foo
    

    Add a little for loop and you could change the perms in one fell swoop: (assuming you're using bash):

    for i in /home/*; do name=`basename $i`; chown -R $name.$name $i; done
    

    You should now be able to log in as any user just fine.