Results 1 to 10 of 11

Thread: CLI - Command to change all 777 privileges to 755

Hybrid View

  1. #1
    Join Date
    Mar 2007
    Location
    Delfim Moreira MG, Brazil
    Beans
    Hidden!
    Distro
    Kubuntu Karmic Koala (testing)

    CLI - Command to change all 777 privileges to 755

    I am looking for a command that can change all instances of files and folders with 777 to 755.

    I have a server with several things installed and have had to use 777 on a number of files and folders. But after installing suexec and suphp, this is now unnecessary, even unwanted, so I have to change all to 755.

    This does not mean I want to change all files and folders to 755. Only those that has 777 privileges... It has to change on subfolders as well as far down as they go.

    Any good suggestions for command to run?
    Regards,

    Oceanwatcher
    Blog about free software: http://www.datahverdag.com/

  2. #2
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,907
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: CLI - Command to change all 777 privileges to 755

    Code:
    find /path/to/search -perm 777 -print
    Feel free to consult the manual:
    Code:
    man find
    Once you're sure that the list of files that you got back from above command is what you really really really want to change (e.g. no essential system files got listed !!) you can trigger a slight variation of the above command to do all those changes automatically for you.

    Code:
    find /path/to/search -perm 777 -print -exec chmod 755 {} \;
    Last edited by scorp123; October 20th, 2009 at 06:38 PM. Reason: Typo corrected :-/

  3. #3
    Join Date
    Mar 2007
    Location
    Delfim Moreira MG, Brazil
    Beans
    Hidden!
    Distro
    Kubuntu Karmic Koala (testing)

    Re: CLI - Command to change all 777 privileges to 755

    Fantastic! I knew there was someone out there that knew this!

    *Off to fix all*

    Thank you very much!!
    Regards,

    Oceanwatcher
    Blog about free software: http://www.datahverdag.com/

  4. #4
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,907
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: CLI - Command to change all 777 privileges to 755

    I just found a typo in my posting. I corrected it now.

  5. #5
    Join Date
    Aug 2005
    Location
    Sydney, Australia
    Beans
    456
    Distro
    Ubuntu Development Release

    Re: CLI - Command to change all 777 privileges to 755

    If you only wanted to change folders to 755 and change files to 644 then you could run the following:
    Code:
    chmod -R u=rwX, g=rX, o=rX
    The uppercase X character tells it to only set the execute permission on folders and not files. It won't work for you if you have some binary files in one of the (sub)folders that need 755 for executing as they will all get converted to 644 permissions.

  6. #6
    Join Date
    Mar 2007
    Location
    Delfim Moreira MG, Brazil
    Beans
    Hidden!
    Distro
    Kubuntu Karmic Koala (testing)

    Re: CLI - Command to change all 777 privileges to 755

    Is there a similar command to find files and folders with anything but the logged in user/owner?

    I also sometimes have problems with folders and files with the wrong owner.
    Regards,

    Oceanwatcher
    Blog about free software: http://www.datahverdag.com/

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •