6

I'm very new to Ubuntu. During work on my home pc, I accidentally made the following command:

sudo chmod -R o+x /home

I want to know if it's dangerous to open access for other users and, if so, how can I revert it?

0

3 Answers 3

6

This question originally asked about sudo chmod o+x /home and not sudo chmod -R o+x /home. This answer pertains to that version. This was then re-asked, for the recursive (-R) version of the command. Subsequently this question was edited, and more answers were posted. I've left this answer with the intention that it may be helpful to others who perform non-recursive chmod operations on /home.

The command chmod o+x /home gives others--that is, people who don't own /home and aren't in its "group owner" either--execute permissions on /home.

For a folder, execute permissions means something special--it means you can go into the directory and attempt to access files inside it.

/home has o+x set by default. The command you ran changed nothing. /home has to allow "others" to access files inside because it contains all the machine's human users' home directories, and *none of those users is /home's owner or a member of its group owner!

Therefore, you don't have to worry about anything. Furthermore, attempting to "fix" this will break your system. If you were to remove the executable bit for "others" on /home, then no user would be able to access their own home directory. The system would be rendered unusable. You would have to enter recovery mode or boot from a live CD/DVD/USB to fix it. (And the way you'd fix it would be to run a command like what you ran before. Except this time it would have an effect.)

If you have already attempted to "fix" this and broken your system, and you need help fixing it, I recommend posting a new question asking for help. After all, that's a different questions from this one.

3
  • 1
    THe problem is, I did it recursively. I mean all folders inside home are now o +x
    – heron
    Mar 23, 2013 at 12:09
  • @heron The command sudo chmod o+x /home is not recursive. Did you use the -R flag? Did you actually run sudo chmod -R o+x /home? Mar 23, 2013 at 12:11
  • yes I ran sudo chmod -R o+x /home
    – heron
    Mar 23, 2013 at 14:54
3

In case you ran the command recursively, as sudo chmod -R o+x /home you have allowed every user who is not the owner and not a member of the group the file/folder belongs to, to 'open' all directories under /home. This is considered a security risk since it allows everyone to obtain file and folder listing, which might reveal some information (or the existence of it).

Furthermore, if you have any scripts inside /home, they become executable by others. This can be a security risk depending on the situation. If any of the scripts have set uid or set gid bits set, then this is surely a security risk, the intensity of which depends on the script contents. It is a severe security risk if you also have both setuid bit and other writable bit (o+w) set since any user will be able to perform tasks as you. (Previlige escalation)

In case you do not have any executable files that need to be executable by 'others' under /home (which is a common case unless the user installs something under home or has placed some executables otherwise), you can revert this by doing sudo chmod -R o-x /home/*

Do note the /home/* instead of /home since /home needs o+x for the system to function propery.

This will remove the executable bit for 'others' from every file and folder inside /home.

2

+ adds, - takes away. Try:

sudo chmod -R o-x /home/*

to recursively remove x permission from others for each subfolder (but not /home/ itself).

If you use -X (or +X) instead of the usual lower-case x, it affects only:

  • directories (so you don't accidentally change permissions on non-directory files), and
  • files with the x permission set for anyone (that is, for user, group, and/or other)

See also ... the man page.

0

Not the answer you're looking for? Browse other questions tagged .