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 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 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.)
You just changed file permissions on all user files to executable (and directories to searchable, which is default) for all users - probably not what you want but also probably not the end of the world - especially if you are the only user on the machine.
One think you could do is to do a find
on document directories and turn that executable flag off for regular files if it bothers you there.
If the system is fresh I might consider a re-install just to get it nice and clean :)
find /home/you/Documents -t f -exec chmod o-x \;
on directories that only contain documents.
Mar 23, 2013 at 17:24
sudo chmod -R o-x /home
take my files from home folder and reinstall?
home
/home
is not the user's home folder. It is the folder that contains users' home folders. So on a multi-user system, this does have bad security ramifications and should be fixed. (And even on a machine with just one human user, a number of processes run with reducecd privileges, like as thenobody
user, so there are still good security reasons to avoid everyone having executable permissions on every file in a home folder.) Furthermore, on regular files,+x
marks them executable, which will make many attempts to open them try to execute them. That's annoying, and worth fixing.