changing permissions of directory alone - Questions

This is a discussion on changing permissions of directory alone - Questions ; I somehow changed the permissions on all files on my home directory to 644. Now I am not able to enter directories. I need to add execute permission to directories but is there any way I can add it only ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: changing permissions of directory alone

  1. changing permissions of directory alone

    I somehow changed the permissions on all files on my home directory to
    644. Now I am not able to enter directories. I need to add execute
    permission to directories but is there any way I can add it only to
    the directories without affecting the files. I saw that chmod does not
    provide any such option. Any help is appreciated.

    Thanks in advance
    Pirabhu

  2. Re: changing permissions of directory alone

    On 11 Dec 2003 07:55:51 -0800, pirabhur@hotmail.com (Pirabhu) wrote:

    >I somehow changed the permissions on all files on my home directory to
    >644. Now I am not able to enter directories. I need to add execute
    >permission to directories but is there any way I can add it only to
    >the directories without affecting the files. I saw that chmod does not
    >provide any such option. Any help is appreciated.


    Recursive descent through all subdirectories of /starting/directory:

    find /starting/directory -type d -exec chmod a+x {} \;


    Just subdirectories of /starting/directory:

    find /starting/directory -maxdepth 1 -type d -exec chmod a+x {} \;


    --
    Lew Pitcher
    IT Consultant, Enterprise Technology Solutions
    Toronto Dominion Bank Financial Group

    (Opinions expressed are my own, not my employers')

  3. Re: changing permissions of directory alone

    pirabhur@hotmail.com (Pirabhu) writes:

    > I somehow changed the permissions on all files on my home directory
    > to 644. Now I am not able to enter directories. I need to add
    > execute permission to directories but is there any way I can add it
    > only to the directories without affecting the files. I saw that
    > chmod does not provide any such option. Any help is appreciated.


    find . -name '*' -type d -exec chmod 775 {} \;

    modify for whatever permissions you want the directories to have.

    Joe

  4. Re: changing permissions of directory alone

    pirabhur@hotmail.com (Pirabhu) wrote in message news:<9a31e2a2.0312110755.dfc435b@posting.google.com>...
    > I somehow changed the permissions on all files on my home directory to
    > 644. Now I am not able to enter directories. I need to add execute
    > permission to directories but is there any way I can add it only to
    > the directories without affecting the files. I saw that chmod does not
    > provide any such option. Any help is appreciated.
    >
    > Thanks in advance
    > Pirabhu


    I guess you want something like this?

    find $HOME -type d | awk '{printf("chmod +x %s\n",$1)}' | /bin/sh

    Obviously you can use octal rather than +x if you prefer.

  5. Re: changing permissions of directory alone

    pirabhur@hotmail.com (Pirabhu) wrote in message news:<9a31e2a2.0312110755.dfc435b@posting.google.com>...
    > I somehow changed the permissions on all files on my home directory to
    > 644. Now I am not able to enter directories. I need to add execute
    > permission to directories but is there any way I can add it only to
    > the directories without affecting the files. I saw that chmod does not
    > provide any such option. Any help is appreciated.
    >
    > Thanks in advance
    > Pirabhu


    Hi

    you can use find to exec a command on the results of the search. Tell
    it to find directories and chmod them:

    find . -type d -exec chmod 755 {} \;

    Good luck. Maybe you also want to check if you haven't made a file
    with passwords world-readable or similar stuff.

    Christian

  6. Re: changing permissions of directory alone

    comeand@kissmyfatarse.com (Mattias Honrendgard) writes:

    >pirabhur@hotmail.com (Pirabhu) wrote in message news:<9a31e2a2.0312110755.dfc435b@posting.google.com>...
    >> I somehow changed the permissions on all files on my home directory to
    >> 644. Now I am not able to enter directories. I need to add execute
    >> permission to directories but is there any way I can add it only to
    >> the directories without affecting the files. I saw that chmod does not
    >> provide any such option. Any help is appreciated.
    >>
    >> Thanks in advance
    >> Pirabhu


    >I guess you want something like this?


    >find $HOME -type d | awk '{printf("chmod +x %s\n",$1)}' | /bin/sh


    That may not work because the chmod commands may not have been executed
    before find wants to descend into the directory.

    Some systems allow for "chmod -R a+X " (capital X) where X means
    "add execute permissions if the file is a directory or already has an
    exexutable bit set.

    Casper
    --
    Expressed in this posting are my opinions. They are in no way related
    to opinions held by my employer, Sun Microsystems.
    Statements on Sun products included here are not gospel and may
    be fiction rather than truth.

+ Reply to Thread