---
title: "Usage"
weight: 30
description: "General syntax, built-in help and daily use of Dolicli."
source_hash: "99853ac1"
---

# Usage

## General syntax

All Dolicli commands follow the same structure:

```bash
./dolibarr <category> <command> [parameters] [options]
```

- **Parameters** are passed in the form `key=value`
- **Options** (flags) are prefixed with `--` (for example `--force`, `--help`)

## Built-in help

Each command has help accessible with `--help`:

```bash
./dolibarr user add --help
./dolibarr repair run --help
./dolibarr system upgrade --help
```

To display the list of all command categories, run Dolicli without argument:

```bash
./dolibarr
```

To display the sub-commands of a category, indicate only the category:

```bash
./dolibarr user
./dolibarr module
./dolibarr system
```

## User management

### Listing users

```bash
./dolibarr user list
```

Displays a table with the login, last name, first name and email address of each user.

### Showing a user's details

```bash
./dolibarr user show login=admin
```

Displays the complete information: identity, contact details, status, rights, login dates, groups and address.

### Creating a user

```bash
./dolibarr user add login=jdupont firstname=Jean lastname=Dupont
```

Required parameters: `login`, `firstname`, `lastname`.

Optional parameters:

| Parameter | Description | Default |
|-----------|-------------|---------|
| `password` | Password (asked interactively if absent) | - |
| `email` | Email address | empty |
| `admin` | Administrator rights (`0` or `1`) | `0` |

Complete example:

```bash
./dolibarr user add login=jdupont firstname=Jean lastname=Dupont password=MyPass123 email=jean@example.com admin=0
```

### Changing a password

```bash
./dolibarr user password login=admin newpass=NewPassword
```

If the `newpass` parameter is omitted, the password is asked interactively.

The `--force` option disables Dolibarr's password security rules:

```bash
./dolibarr user password login=admin --force
```

### Locking or unlocking an account

```bash
./dolibarr user edit login=jdupont --lock
./dolibarr user edit login=jdupont --unlock
```

### Generating an API token

```bash
./dolibarr user token login=admin
```

If a token already exists, the command displays a warning and stops. Use `--force` to regenerate a new token:

```bash
./dolibarr user token login=admin --force
```

The generated token is displayed only once. Keep it safe.

## Module management

### Listing modules

```bash
./dolibarr module list
```

Displays a table with the identifier, name, version, external character, visibility, update need and publisher of each module.

### Enabling a module

```bash
./dolibarr module activate name=modFacture
```

The `name` parameter corresponds to the module's technical name (for example `modFacture`, `modSociete`, `modUser`).

To enable all available modules:

```bash
./dolibarr module activate --all
```

> **Warning:** enabling all modules can cause conflicts. Use this option with caution, for example on a test environment.

### Disabling a module

```bash
./dolibarr module deactivate name=modFacture
```

To disable all active modules (except the critical `modUser` and `modSysLog` modules):

```bash
./dolibarr module deactivate --all
```

## System management

### Upgrading Dolibarr

#### Checking available updates

```bash
./dolibarr system upgrade --check
```

#### Listing available versions

```bash
./dolibarr system upgrade --list
```

#### Minor upgrade

Updates to the latest minor version of the current branch (for example 21.0.3 to 21.0.5):

```bash
./dolibarr system upgrade --minor
```

#### Major upgrade

Updates to the latest major version available:

```bash
./dolibarr system upgrade --major
```

#### Upgrade to a specific version

```bash
./dolibarr system upgrade --version=22.0.0
```

#### Database migration only

If you have already updated the files manually, run only the database migration:

```bash
./dolibarr system upgrade
```

The `--force` option forces the migration even if the versions seem compatible. The `--skip-backup` option skips the backup confirmation request.

> **Warning:** always back up your database before any upgrade. Test on a pre-production environment for major upgrades.

### Maintenance mode

#### Checking the status

```bash
./dolibarr system maintenance status
```

#### Enabling maintenance mode

```bash
./dolibarr system maintenance enable
./dolibarr system maintenance enable login=admin
```

Without the `login` parameter, the first super-administrator found is used.

#### Disabling maintenance mode

```bash
./dolibarr system maintenance disable
```

> **Warning:** do not log out of your session before disabling maintenance mode, on pain of no longer being able to access Dolibarr.

### Scheduled tasks security key (CRON_KEY)

The `CRON_KEY` constant is the value of the `securitykey` parameter required in the URL `public/cron/cron_run_jobs.php?securitykey=...` when triggering scheduled tasks over HTTP. It is stored in the `llx_const` table and respects the current entity in multi-company mode.

#### Showing the current key

```bash
./dolibarr system cronkey show
```

#### Setting a specific key

```bash
./dolibarr system cronkey set key=mySecretKey
```

The provided value overwrites the existing key.

#### Generating a random key

```bash
./dolibarr system cronkey generate
```

Generates a 32-character hexadecimal key (16 random bytes) and saves it. The new value is displayed at the end of the command.

#### Deleting the key

```bash
./dolibarr system cronkey clear
```

Deletes the `CRON_KEY` constant. No security key is then required to trigger the scheduled tasks.

> **Warning:** if you modify or delete the key, remember to update the system cron task (crontab, scheduler, etc.) that calls `cron_run_jobs.php`, on pain of seeing the scheduled tasks fail with an invalid key error.

## Database repair

### Running a repair action

```bash
./dolibarr repair run action=ACTION [mode=test|confirmed]
```

The `test` mode (default) shows what would be done without modifying the database. The `confirmed` mode actually executes the repair.

### Available actions

| Action | Description |
|--------|-------------|
| `standard` | Runs the SQL repair scripts and synchronizes extrafields |
| `force_disable_modules` | Disables modules whose files are not found |
| `restore_logos` | Restores third-party logos |
| `restore_pictures` | Restores user photos |
| `rebuild_thumbs` | Rebuilds product thumbnails |
| `clean_linked_elements` | Cleans the linked elements table |
| `clean_menus` | Cleans the menus table |
| `clean_orphan_dirs` | Deletes orphan directories |
| `clean_stock_batch` | Cleans the product stock batch table |
| `clean_permissions` | Cleans the permissions table |
| `set_time_spent` | Initializes empty time-spent amounts |
| `force_utf8` | Forces UTF-8 encoding on tables (MySQL/MariaDB) |
| `force_utf8mb4` | Forces UTF-8 MB4 encoding on tables (MySQL/MariaDB) |
| `rebuild_sequences` | Rebuilds sequences (PostgreSQL) |
| `repair_dispatch_links` | Repairs links between receptions and supplier orders |

Example:

```bash
./dolibarr repair run action=clean_menus mode=test
./dolibarr repair run action=clean_menus mode=confirmed
```

Maintenance mode is automatically enabled during the repair execution, then disabled at the end.

## Third-party management

### Listing third parties

```bash
./dolibarr thirdparty list
```

Optional parameters:

| Parameter | Description |
|-----------|-------------|
| `limit=N` | Limits the number of results |
| `offset=N` | Offsets the results (pagination) |
| `search=text` | Filters by third-party name |

Example:

```bash
./dolibarr thirdparty list limit=10 search=Dupont
```

### Recalculating accounting codes

```bash
./dolibarr thirdparty accountingnumber
```

Recalculates each third party's (customers and prospects) customer accounting code according to the numbering rules configured in Dolibarr. Displays a table with the old and the new code.

> **Warning:** this command directly modifies the accounting codes in the database. The script stops at the first error encountered.

## Backup

### Exporting the database

```bash
./dolibarr backup --database
```

Generates an SQL file via `mysqldump` in the system's temporary directory.

### Exporting documents

```bash
./dolibarr backup --documents
```

Creates a ZIP archive of Dolibarr's data directory (`.log` files are excluded).

### Exporting modules

```bash
./dolibarr backup --modules
```

Creates a ZIP archive of Dolibarr's `htdocs/` directory.

### Choosing the destination directory

```bash
./dolibarr backup --database dir=/path/to/backups
```

Files are named after the current date: `YYYYMMDD-database.sql`, `YYYYMMDD-documents.zip`, `YYYYMMDD-modules.zip`.

## Anonymization

### Preview (dry run)

```bash
./dolibarr anonymize run
```

Displays a summary of what would be anonymized, without modifying the database.

### Execution

```bash
./dolibarr anonymize run --confirm
```

An interactive confirmation (`YES` in uppercase) is requested before execution. Maintenance mode is automatically enabled during the operation.

### Options

| Option | Description |
|--------|-------------|
| `--confirm` | Actually executes the anonymization (required) |
| `--skip-thirdparties` | Ignore third parties and contacts |
| `--skip-users` | Ignore user accounts |
| `--skip-members` | Ignore members |
| `--skip-bank` | Ignore bank data |
| `keep-admin=LOGIN` | Login of the administrator to preserve (by default: first super-admin) |

### Anonymized data

- Third parties: names, addresses, phones, emails, SIREN/SIRET, VAT
- Contacts: names, addresses, phones, emails, dates of birth
- Users: names, logins, emails, phones, addresses, salaries, API keys
- Members: names, emails, phones, addresses, identifiers
- Bank data: IBAN, BIC, account numbers, card details
- Communications: email addresses, subjects, contents, IP addresses
- Mailings: recipients' names and emails
- Employment contracts: salary data
- Email collectors: identifiers and passwords
- Notes: all `note_private` and `note_public` fields
- Locked log and sessions: fully purged

### Data not anonymized

- Financial amounts (invoice totals, order amounts)
- Document references (FA2024-001, etc.)
- Product catalog
- The administrator account specified by `keep-admin`
- Files on disk (documents, attachments)
- Extrafields (custom fields)

> **Warning:** anonymization is **irreversible**. Always make a full backup of your database before running this command.
