Script to fix users home permissions?

akust0m

Well-Known Member
Feb 19, 2016
70
4
8
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!
 

cPAusaf

Linux Technical Analyst III
Staff member
Aug 24, 2016
41
11
133
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.
 

akust0m

Well-Known Member
Feb 19, 2016
70
4
8
Melbourne
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
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.

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.
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 :)
 
  • Like
Reactions: cPAusaf

Muhammed Fasal

Well-Known Member
Aug 9, 2017
54
10
8
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:

./fixperms user1 user2

You can see the script here , let me know if it helps.