Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Script to fix users home permissions?

Discussion in 'General Discussion' started by akust0m, Oct 21, 2017.

  1. akust0m

    akust0m Well-Known Member

    Joined:
    Feb 19, 2016
    Messages:
    63
    Likes Received:
    4
    Trophy Points:
    8
    Location:
    Melbourne
    cPanel Access Level:
    Root Administrator
    Hello,

    I don't have a permissions issue currently, but I was just wondering whether there is a script provided by cPanel that fixes up a users home directory in case it gets messed up for some reason?

    As I understand, the primary domain and add-on domains wont work if the group isn't set to "nobody" (using Litespeed). And also things like "etc" in a users home directory needs to have the group set to "mail".

    Is there a script that goes through and fixes up all owner/group permissions of all the various files and folders in a users home directory?

    Thanks!
     
  2. RicardoFC

    RicardoFC Member

    Joined:
    Oct 21, 2017
    Messages:
    20
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Hi,

    You can use this commands:

    cd /home/cpaneluser
    ls -all | grep public_html
    chown -R cpaneluser.cpaneluser public_html
     
  3. cPAusaf

    cPAusaf Linux Technical Analyst II
    Staff Member

    Joined:
    Aug 24, 2016
    Messages:
    25
    Likes Received:
    1
    Trophy Points:
    78
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hello,

    The main issue is knowing which PHP handler is being used and adjusting the permissions and ownership accordingly. cPanel does not provide any scripts that automatically fixes this unfortunately. There are a few places online which have permission/ownership scripts that usually work good when using the suPHP handler. If using DSO or CGI, that is where issues may occur if using one of the scripts incorrectly.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. akust0m

    akust0m Well-Known Member

    Joined:
    Feb 19, 2016
    Messages:
    63
    Likes Received:
    4
    Trophy Points:
    8
    Location:
    Melbourne
    cPanel Access Level:
    Root Administrator
    Unfortunately this wouldn't work for all situations I'm afraid, especially if you are using lsapi with Litespeed as public_html and addon document roots need to have 'nobody' as the group.

    I was more looking at an script to fix everything within a users home directory, not just public_html.

    No worries at all. It would be amazing if cPanel developed a script that would fix permissions with auto handler recognition :)

    I'll look around, but I might end up trying to write my own bash script :)
     
    cPAusaf likes this.
  5. Muhammed Fasal

    Muhammed Fasal Active Member

    Joined:
    Aug 9, 2017
    Messages:
    39
    Likes Received:
    3
    Trophy Points:
    8
    Location:
    India
    cPanel Access Level:
    Root Administrator
    This is a simple bash script I wrote to fix the permissions and ownership of files within a cpanel account. To use, simply copy the script into your server, chmod 755, and pass the usernames as arguments:


    You can see the script here , let me know if it helps.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice