calm down, chmod changes the permissions of the file. I don't know whether it may be helpful to anyone, but do you mind telling us what you were trying to do when you accidentally typed that in? Also, I should point out that the contents of your home folder wont effect your system.
–
NilMar 23 '13 at 17:08

@Nil İ was trying to chmod for webserver configuration the folder which located inside home
–
heronMar 23 '13 at 17:10

@Nil /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 the nobody 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.
–
Eliah KaganMar 23 '13 at 17:10

2 Answers
2

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 +xpermission 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:

I will reinstall whole system. So don't worry about system files and folders) Please tell me one and only thing, what I need to do with my personal files? How to revert permission back to defaults?
–
heronMar 23 '13 at 17:59

@heron Only your personal files (and those of other human users on the system, if any) are affected! You didn't make any changes to the rest of the system. My answer is about how to change the permissions on your personal files. (@SEngstrom's answer is about this, too.) You really do not have to reinstall, though I guess you could.
–
Eliah KaganMar 23 '13 at 18:02

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 :)

You could do something like find /home/you/Documents -t f -exec chmod o-x \; on directories that only contain documents.
–
SEngstromMar 23 '13 at 17:24

Ok, so I do sudo chmod -R o-x /home take my files from home folder and reinstall?
–
heronMar 23 '13 at 17:25

No that would make all your directories non-searchable to processes not in your group and executable files would need to be addressed separately.
–
SEngstromMar 23 '13 at 17:27

So what I have to do, to my own files for reverting them back to right (default) permission before reinstalling?
–
heronMar 23 '13 at 17:28

Oic reinstall... it really depends on how much files are in there and what they are. If you have applications mixed in there it'll be a bit of a mess, but if it is basically only documents just flip them back with the find command above.
–
SEngstromMar 23 '13 at 17:29