0

I have made a script which creates a folder (website) in the public path of a website that belongs to a website control panel (CyberPanel):

mkdir /home/example.com/website/

But this command does not give enough permissions to the panel user to create or edit files inside it, the permissions are:

ls -la /home/example.com/website/

total 8
drwxr-xr-x 2 root      root    4096 Dec 14 11:49 .
drwxr-xr-x 4 softs4939 nogroup 4096 Dec 14 11:49 ..

when I create a folder in the panel, I get the permissions:

ls -la /home/example.com/website/

total 8
drwxr-xr-x 2 softs4939 softs4939 4096 Dec 14 11:48 .
drwxr-xr-x 4 softs4939 nogroup   4096 Dec 14 11:49 ..

which lets the panel user to edit anything in it.

How do I make the folder and all its file inside it (made in terminal) to be editable by panel user?

1 Answers1

2

Three options:

  1. Run the command as the target user, not as root.

    sudo -u softs4939 mkdir /home/example.com/website/
    
  2. run chown afterwards

    mkdir /home/example.com/website/
    chown softs4939:softs4939 /home/example.com/website/
    
  3. use install

    install -o softs4939 -g softs4939 -d /home/example.com/website/
    

Personally, I prefer option 3 in such scripts.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89