Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using Ubuntu 13.04 x86_64.

I wanted to own whole stuff in my home directory. So I executed these two commands.

sudo chown -RcH rootkea ~  
sudo chown -RcL rootkea ~

Now due to those symbolic links linked to some other files in filesystem I have accidentally owned files which reside outside of my home directory.
The immediate consequences which I noticed are:

  1. sudo not working

    $ sudo  
    sudo: effective uid is not 0, is sudo installed setuid root?
    
  2. system has become so slow. It just gets hanged when I click on shutdown / reboot. Each time I have to manually power off the machine.
  3. creates a log file /var/log/cups/error_log of indefinite size which consumes the last byte of my hard drive (after considerable time). Last time it was 17.8 GB!
    The content of the file was only these two lines repeated uncountably:

    E [24/May/2013:02:27:52 +0530] File "/usr/lib/cups/notifier/dbus" has insecure permissions (0100755/uid=1000/gid=0).  
    W [24/May/2013:02:27:52 +0530] Notifier for subscription 531 (dbus://) went away, retrying!
    

So clearly cups program is screwed too.

Now I have no idea about how many other programs have gone to unusable state.

Is there any way to undo the effects of above mentioned two commands ?
How can I restore the default permission settings to whole filesystem ?

share|improve this question

marked as duplicate by Mitch, Radu Rădeanu, Kevin Bowen, Basharat Sialvi, belacqua Jul 3 '13 at 22:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
@gertvdijk- Beside reinstalling, 2 other solutions have been proposed there. But sadly I can't use any of them. Firstly I can't have similar ubuntu installation to run get-filesystem-acl script since I didn't freshly install the system. I upgraded it from 12.10 which was in turn was upgraded from 12.04. Now since my OS isn't a fresh install I simply can't use the live cd solution either as it will only update the permissions of Ubuntu 13.04 files. But what about files from previous installs? Will it work if they are not updated ? –  rootkea May 27 '13 at 8:00
    
Check my answer here: askubuntu.com/questions/265080/… –  don.joey May 27 '13 at 9:15
    
@Private- "... it will only update the permissions of Ubuntu 13.04 files. But what about files from previous installs? Will it work if they are not updated ?" –  rootkea May 27 '13 at 10:08

1 Answer 1

As gertvdijk suggests (by reference to this question), reinstalling is almost always the best and easiest way to fix this (and the only way you can be sure will completely fix it), especially if you don't know exactly where the permission were changed or what they were changed from.

This method, which private has suggested, might work, and you may consider it worth a try. However, there is some variation from version to version of where files and folders are and what their ownership and permissions should be. Furthermore, with any solution besides reinstalling, you'll never know if there are some files or folders with wrong permissions, which may at some point in the future cause problems.

You can usually fix--or at least make progress--on the problem of sudo not working (i.e., problem 1, as you've listed it) by fixing its ownership:

pkexec chown root:root /usr/bin/sudo

In a situation like yours, that's mainly useful as a convenience measure to make it easier to perform whatever administrative tasks you need to get done before reinstalling. (Or before attempting to apply some more complicated solution.) A backup is definitely in order now, if your backups of important files (e.g., documents) are not completely up-to-date.

Finally, please note that it's only ownership, and not permissions, that were modified. So you might try recursively changing directories' ownership back to root. However, that is not that likely to fix the problem either, because:

  • it's unclear if you know exactly what directories have been changed.
  • some files should not be owned by root because they have to be accessed by less privileged parts of the system; setting their ownership or permissions too restrictively could break the system.
  • some files could cause security vulnerabilities if owned by root. A setuid executable always runs as the user who owns it. Your system may contain setuid executables that are intended always to run as some non-privileged user; making them run as root could be bad. Or someone may have--intentionally or unintentionally--created an setuid file (without having permissions to make it owned by root). If you make it owned by root, it will execute as root, no matter who runs it. That could be very bad.

So, if this is a production system, you should just reinstall.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.