# Permission denied when creating files through terminal console

**URL:** <https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734>\
**Category:** Uncategorized\
**Created:** [September 16, 2020, 8:35am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734 "2020-09-16T08:35:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobet](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jobet](https://forum.hestiacp.com/u/jobet)\
**Post date:** [September 16, 2020, 8:35am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/1 "2020-09-16T08:35:30Z")

</div>

Hi,  
Just installed last Hestia version. I’m installing WordPress on Nginx, MariaDB and PHP stack.  
Created a dedicated user to manage WordPress. Gave him bash shell in order to use WP-CLI.

The problem comes out when I try to create any file on its home directory: “Permission denied”…

With previous Hestia version I never had this problem… something changed in this last version?

Thanks for any help!

Best regards,  
Roberto

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [September 16, 2020, 8:40am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/2 "2020-09-16T08:40:18Z")

</div>

Home directory has owner set to root due the chroot.

Any sub dir is should work without an issue

---

<div class="post-metadata">

**Author:** ![jobet](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jobet](https://forum.hestiacp.com/u/jobet)\
**Post date:** [September 16, 2020, 8:43am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/3 "2020-09-16T08:43:47Z")

</div>

Hi,

Here you can see directory ownership and permissions:

drwxr-xr-x+ 11 root root 4.0K Sep 16 09:51 user  
drwxr-xr-x 5 roberto roberto 4.0K Sep 16 09:50 roberto

The first user was created using HestiaCP and the second one manually using shell…

User directory shouldn’t be owned by user?

---

<div class="post-metadata">

**Author:** ![Raphael](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/raphael/32/5217_2.png) [@Raphael](https://forum.hestiacp.com/u/Raphael)\
**Post date:** [September 16, 2020, 8:54am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/4 "2020-09-16T08:54:55Z")

</div>

> [@jobet](#):
>
> User directory shouldn’t be owned by user?

Due to the sftp chroot implementation, it needs to be owned by root. There are already a few default folders created, like .composer or .cache and so on.

---

<div class="post-metadata">

**Author:** ![jobet](https://forum.hestiacp.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jobet](https://forum.hestiacp.com/u/jobet)\
**Post date:** [September 16, 2020, 9:09am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/5 "2020-09-16T09:09:54Z")

</div>

What should I do then to use WP-CLI with this user?

WP-CLI installs WP in this directory and modifies several files…

Should I add this user to the sudo group to solve this issue?

---

<div class="post-metadata">

**Author:** ![Raphael](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/raphael/32/5217_2.png) [@Raphael](https://forum.hestiacp.com/u/Raphael)\
**Post date:** [September 16, 2020, 10:07am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/6 "2020-09-16T10:07:01Z")

</div>

Why? Give the user bash shell under edit user, the wp cli script itself can be run inside of the public\_html directory.

---

<div class="post-metadata">

**Author:** ![eris](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/eris/32/1241_2.png) [@eris](https://forum.hestiacp.com/u/eris)\
**Post date:** [September 16, 2020, 10:40am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/7 "2020-09-16T10:40:23Z")

</div>

```
wp core download

Downloading WordPress 5.5.1 (en_US)...

**Warning:** Failed to create directory '/home/{user}/.wp-cli/cache/': mkdir(): Permission denied.

md5 hash verified: 72c6f56b4818ffd0e6e6a4ed8f3e8d4e

**Success:** WordPress downloaded.

```

I suggest creating .wp-cli for the user as root and chown it…

Or /usr/local/hestia/data/packages/

create package.sh (package.sh with name of package)

```
#!/bin/bash
mkdir /home/$1/.wp-cli
chown $1:$1 /home/$1/.wp-cli
```

---

<div class="post-metadata">

**Author:** ![mehargags](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/mehargags/32/12_2.png) [@mehargags](https://forum.hestiacp.com/u/mehargags)\
**Post date:** [September 16, 2020, 9:38pm UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/8 "2020-09-16T21:38:44Z")

</div>

Or just enable WP-CLI for root and use it anywhere on any site anytime. But after adding plugins/themes or any file operations you need to `chown -R <hestiauser>:<hestiauser> xxx/public_html` to reset permissions for the particular WP file to its user.

You can setup an alias like this in `. ~/.bashrc`  
`alias wp='wp --allow-root'`

---

<div class="post-metadata">

**Author:** ![Raphael](https://forum.hestiacp.com/user_avatar/forum.hestiacp.com/raphael/32/5217_2.png) [@Raphael](https://forum.hestiacp.com/u/Raphael)\
**Post date:** [September 17, 2020, 5:10am UTC](https://forum.hestiacp.com/t/permission-denied-when-creating-files-through-terminal-console/1734/9 "2020-09-17T05:10:42Z")

</div>

> [@mehargags](#):
>
> chown -R : xxx/public\_html

Please take care, there has been a permission change to prevent nginx errors in log files, the current permission set is user:www-data for public\_html and user:user for every file in it. If you set the chown as described, the permission for public\_html will aswell be set to user:user.
