Accidentally ran command, now don't know what to do

Accidentally ran command

sudo chmod -R o+x /home

on my Ubuntu 12.10.

Now what me to do? is that dangerous? I have no backup of partition, so I think this command is not reversible. SO me to reinstall whole system because of this mistake?


The best way to fix this depends on details of how your system is set up. Fortunately, you probably know these details.

On files, +x means they can be run like a program. (Actually, it confers the permission to try. If they're not actual executable binaries or script files with a hashbang line, this will still fail.)

On directories (that is, folders), the +x permission means something else. Executable permissions on a folder confers the ability to enter into the folder and its subfolders (though its subfolders may not have the necessary permissions for this), and to attempt to access files inside the folder (the files may or may not have permissions that allow this to succeed).

This was o+x. o stands for other. That controls the permissions of users who don't own the file or folder, and also who are not members of the file or folder's "group owner."

If You Don't Currently Use Permissions To Share Files With Other Local Users

If a user (say, you) doesn't need to share files with other users, then it's safe to take away executable permissions for other, so long as you only do it everywhere inside your home folder. Your home folder is /home/username where username is replaced with your actual username. /home is not itself your home folder, but rather is the folder that contains all the home folders. Since /home itself is not actually owned by any human user of the computer, it is imperative that executable permissions for other not be removed from /home itself.

So, you can run:

cd ~

~ represents your home folder. (The shell interprets it as that, you can type exactly that.)

Then you can run:

chmod -R o-x .* *

Or if you want to prevent others from changing directory into your home folder itself as well:

chmod -R o-x ~

It's intentional that I haven't written sudo. You still own the files in your home folder, so you don't need sudo, and leaving it off will help to avoid changing permissions on the wrong files and folders by accident. (In particular, /home is owned by root, so by leaving off sudo, you make sure you're not accidentally changing the permissions for /home and making your system unusable.)

If You Do Currently Use Permissions To Share Files With Other Local Users

If you have some folders that you do share with other users on the machine (if you do, then you almost certainly know you do), then you can use the above method and then manually add executable permissions on those particular folders. But if you have too many for this to be practical, then especially if you're not worried about other users accessing things that they're not supposed to, you might want to just take away executable permissions from files, and not from folders. After doing this, you can then selectively take executable permissions away from some folders, of course.

To take away executable permissions for other from all the files in your own user's home folder, but not the directories, run:

find ~ -type f -exec chmod o-x \{\} \;

(You will note that this is similar to one of SEngstrom's suggestions. See man find for information about how this works.)