Blog | Admin | Archives

Useful Linux Command

Today I was searching for a good way to change permissions recursively, but only on directories or only on files, because of the vast difference in meaning for the executable flag between the two. Google is a great friend, and led me to a site, whose address I do not exactly remember, but whose advice was perfect:

find . -type d -name public_html -exec chmod 0755 {} \;

Just strip out the -name argument, and change between -type d and -type f to chmod only files or only directories, recursively from the current directory. A great way to correct past misconceptions about the setgid and setuid bits!

4 Responses to “Useful Linux Command”

  1. Bernie Zimmermann Says:

    Bookmarked!

  2. Ryan Says:

    Notice the \ before the semi-colon. I have no idea what that does exactly, but when I used it that way, it worked, so I didn’t ask questions. I have just noticed that in wordpress, I have to double-backslah to get the single backslash. Looks like an addslashes/stripslashes mismatch!

  3. nordsieck Says:

    I think this is what you are looking for… I am assuming that this was taken from a Bash Script…

    http://www.gnu.org/software/bash/manual/bashref.html#SEC9

    “A non-quoted backslash `’ is the Bash escape character…”

  4. nordsieck Says:

    google knows all…

Leave a Reply