By mistake I executed this command on Ubuntu 16.04

sudo chmod -R -x * && sudo chmod -R +X *

Now all the folder converted into files, which is not opening.

How can I fix it?

  • in which folder did you execute the command?
    – Yaron
    Aug 10, 2017 at 8:17
  • 1
    In addition to that ^, the second chmod probably never ran, since chmod would show an error because it couldn't descend into any directories on which it had already set -x.
    – muru
    Aug 10, 2017 at 8:21
  • @Yaron at root of my login
    – Pallavi
    Aug 10, 2017 at 8:28
  • See the link(ubuntuforums.org/showthread.php?t=2237478) for same case, but my systems Documents sub-folders get converted.
    – Pallavi
    Aug 10, 2017 at 8:30
  • 1
    @Zanna adds execute to directories and keeps it for files which already have it, iirc
    – muru
    Aug 10, 2017 at 10:59

1 Answer 1


You have removed execution-rights (and thereby access to) all directories and eventually files that where executable.

Start by giving back exec to directories:

find . -type d -exec chmod +x {} \;

If you had any executable programs, then for each of these do:

chmod +x filename

The +xin the commands above gives execute rights to all (user, group and others - the three different access levels in a linux/posix filesystem)). If you for some reason needs to restrict access to only user or user+group you can replace +x with u+x or ug+x to achieve this.

  • what do you mean "eventually"? Shouldn't OP start by giving x only to u?
    – Zanna
    Aug 10, 2017 at 11:09
  • @Zanna, you are right .. I will change the text.
    – Soren A
    Aug 10, 2017 at 11:12
  • Perhaps you could investigate which directories should not have x for u - I attempted it in my answer here Home files and folders permissions could not be determined
    – Zanna
    Aug 10, 2017 at 11:21
  • @Zanna .. I think that it is more relevant to identify directories that should ONLY have x for u .. but besides that, you are right.
    – Soren A
    Aug 10, 2017 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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