HestiaCP CLI: automate tasks with v-add and v-delete commands

Use the HestiaCP CLI to create and remove users, domains and databases from the shell. Covers v-add-user, v-add-domain, v-add-database and their v-delete counterparts.

  • Advanced
  • Linux VPS
  • 5 min read

By RunRacks Team · Published

HestiaCP CLI commands let you create and remove hosting accounts, domains and databases from a shell instead of clicking through the web panel. This guide walks through the v-add-* and v-delete-* scripts you need to script provisioning on a Linux VPS, with the exact syntax and the checks that catch mistakes before they hit production.

The commands are small shell wrappers that live in /usr/local/hestia/bin/. They talk to the same backend as the panel, so anything you create from the CLI shows up in the dashboard immediately.

Before you start

You need:

  • A Linux VPS with HestiaCP already installed. If you have not done that yet, follow how to install HestiaCP on a Linux VPS.
  • Root access, or a sudo user. The v- scripts must run as root.
  • The name of a hosting package that exists on the server. List them with v-list-user-packages.
  • A note of what you are about to create. Write the usernames and domains down first so you do not create duplicates.

Open a root shell:

Terminal
sudo -i

If you prefer to stay as your sudo user, remember that sudo resets PATH, so /usr/local/hestia/bin will not be on it. Call the full path, for example sudo /usr/local/hestia/bin/v-list-users.

How HestiaCP CLI v-add and v-delete commands work

Every command follows the same shape: a verb, a resource and positional arguments.

Text
v-add-<resource>   <user> <name> <extra arguments>
v-delete-<resource> <user> <name>

The first argument is almost always the hosting user the resource belongs to. Names are case-sensitive. If you get the argument order wrong, the script usually fails with a usage line rather than doing something unexpected, but check the output every time.

Useful discovery commands:

Terminal
v-list-users
v-list-user-packages
v-list-web-domains deploy
v-list-databases deploy

Create a user, domain and database with v-add

Add a hosting user

Terminal
v-add-user deploy 'StrongPass!23' [email protected] default

The arguments are username, password, email and package. The package name must already exist on the server. If you leave it out, HestiaCP uses the default package.

Confirm it landed:

Terminal
v-list-user deploy

Add a domain

v-add-domain is the wrapper that creates everything the package allows — web, DNS and mail:

Terminal
v-add-domain deploy example.com

If you only want a web vhost and no DNS or mail records, use the narrower command:

Terminal
v-add-web-domain deploy example.com

Add a database

Terminal
v-add-database deploy appdb deployuser 'DbPass!23' mysql

The arguments are user, database name, database user, password and type. HestiaCP prefixes the database and database user with the hosting username, so the real names become deploy_appdb and deploy_deployuser. Use those full names in your application config.

Issue a Let's Encrypt certificate

Terminal
v-add-letsencrypt-domain deploy example.com www.example.com

The domain must already resolve to your server's IP and port 80 must be reachable from the internet. Pass any aliases as extra arguments; check the script header in /usr/local/hestia/bin/v-add-letsencrypt-domain if your release expects a different separator.

Add a cron job for the user

Terminal
v-add-cron-job deploy '0 3 * * *' 'php /home/deploy/web/example.com/public_html/cron.php'

This is handy when you want the same schedule for every account you provision. See schedule tasks with cron on Linux for the time field syntax.

List and check what you created

Before deleting anything, list it. This is the single best habit when working from the CLI.

Terminal
v-list-web-domains deploy
v-list-databases deploy
v-list-cron-jobs deploy

To see the raw config HestiaCP wrote for a domain:

Terminal
cat /usr/local/hestia/data/users/deploy/web.conf

Remove resources with v-delete

Delete in the reverse order you created things. Remove the database before the user, and the domain before the user.

Terminal
v-delete-database deploy appdb
v-delete-domain deploy example.com
v-delete-user deploy

The narrower equivalents work the same way:

Terminal
v-delete-web-domain deploy example.com
v-delete-mail-domain deploy example.com
v-delete-cron-job deploy 1

Check it works

  1. Log in to the HestiaCP dashboard and confirm the user, domain and database appear under the expected account.
  2. Run v-list-web-domains deploy and check the domain is listed with the status you expect.
  3. Request the site over HTTP: curl -I http://example.com should return a response from your server, not a connection error.
  4. Connect to the database with the full prefixed name: mysql -u deploy_deployuser -p deploy_appdb.
  5. After a delete, re-run the matching v-list-* command and confirm the entry is gone.

Troubleshooting

  • `Error: user deploy already exists` — the username is taken. Run v-list-users and pick another name, or delete the old account first.
  • `Error: package default does not exist` — the package name is wrong or was never created. Run v-list-user-packages and use one of the names it prints.
  • `Permission denied` or `command not found` — you are not root, or sudo dropped /usr/local/hestia/bin from PATH. Open a root shell with sudo -i or use the full path.
  • Let's Encrypt validation fails — the domain does not resolve to this server yet, or port 80 is blocked. Check DNS with dig +short example.com and confirm your firewall allows HTTP. See delete, insert and reorder UFW rules safely if you need to adjust rules.
  • Database connection refused with the short name — HestiaCP prefixes database and user names with the hosting username. Use deploy_appdb, not appdb.

Next steps

Was this guide helpful?

Still stuck?

Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.

Control panels

CyberPanel: back up and restore a website

Create on-demand and scheduled website backups in CyberPanel, download the archives off the server, and restore a site from a backup when something breaks.

  • Intermediate
  • Linux VPS
  • 6 min read