# Essential Magento 2 commands to run over SSH

> A quick reference for the most useful Magento 2 bin/magento commands, from clearing caches to managing modules over SSH.

Source: https://www.kualo.com/knowledgebase/magento-getting-started/essential-magento-2-commands-to-run-over-ssh
Updated: 2026-06-11

---

Magento 2 includes a powerful command-line tool, `bin/magento`, which is often the quickest way to handle routine maintenance: clearing caches, reindexing, enabling maintenance mode and more. All Kualo hosting plans include [SSH access](/knowledgebase/dev-cli/using-ssh-on-kualo-hosting-a-getting-started-guide), so these commands are available to you whenever you need them.

## Before you start

Connect via SSH and change to your Magento installation directory. Every command below is run from there:

```bash
cd /path/to/your/magento
```

If you are unsure of the path, check the [File Manager in cPanel](/knowledgebase/cpanel-files-ftp/how-to-use-file-manager-in-cpanel). Every command follows the same pattern: `php bin/magento` followed by the command name. To see the full list of available commands at any time, run:

```bash
php bin/magento list
```

You can also add `--help` to any command to see its options.

## Cache management

These two commands are the ones people mix up most. `cache:clean` removes only items Magento knows are outdated, while `cache:flush` empties the cache storage entirely. Clean is gentler and usually enough; flush is the better option when something is behaving strangely:

```bash
php bin/magento cache:clean
php bin/magento cache:flush
```

To see which cache types exist and whether they are enabled:

```bash
php bin/magento cache:status
```

## Indexing

If product changes are not appearing on the storefront, or the admin warns that one or more indexers are invalid, reindexing is usually the fix:

```bash
php bin/magento indexer:status
php bin/magento indexer:reindex
```

For day-to-day operation, set indexers to update by schedule rather than on save - this is much kinder to performance on busy stores:

```bash
php bin/magento indexer:set-mode schedule
```

:::info
Scheduled indexing relies on your Magento [cron jobs](/knowledgebase/cpanel-php/how-to-setup-a-cron-job-in-cpanel) running correctly.
:::

## Maintenance mode

Put the store into maintenance mode before upgrades or risky changes, then take it back out afterwards:

```bash
php bin/magento maintenance:enable
php bin/magento maintenance:disable
```

To keep working on the site yourself while visitors see the maintenance page, exempt your own IP address:

```bash
php bin/magento maintenance:enable --ip=203.0.113.10
```

## Admin users

Locked out of the admin, or need to create an account without using the dashboard? Both can be done from the command line:

```bash
php bin/magento admin:user:unlock yourusername
```

```bash
php bin/magento admin:user:create \
  --admin-user="newuser" \
  --admin-email="you@example.com" \
  --admin-firstname="First" \
  --admin-lastname="Last"
```

:::info
Note that we have deliberately left out the password. The command will prompt you for it, and your input stays hidden as you type. Avoid passing a password with the --admin-password option, as it would end up stored in your shell history. You can also run php bin/magento admin:user:create with no options at all and answer each prompt in turn.
:::

## After installing or updating a module

Whenever you install, update or remove a module via [Composer](/knowledgebase/dev-cli/how-to-use-composer-on-kualo-servers), run the following sequence to apply database changes, recompile and refresh static assets:

```bash
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f en_GB
php bin/magento cache:flush
```

Replace `en_GB` with the locales your store uses, separated by spaces. The compile and static-content steps are only required when the store is in production mode.

## Modules

To list installed modules and their status, or to [disable a misbehaving one](/knowledgebase/magento-performance/how-to-disable-unrequired-modulesextensions-in-magento-v2):

```bash
php bin/magento module:status
php bin/magento module:disable Vendor_ModuleName
php bin/magento module:enable Vendor_ModuleName
```

Always run `setup:upgrade` and flush the cache after enabling or disabling a module.

## Deploy mode

To check whether your store is running in developer or production mode:

```bash
php bin/magento deploy:mode:show
```

Live stores should always run in production mode. See our guide on [switching Magento 2 to production mode](/knowledgebase/magento-performance/speed-up-magento-2-by-switching-to-production-mode) for the details and the performance difference it makes.

If you need any further help, please contact our support team.

---

_Source: Kualo Knowledgebase — https://www.kualo.com/knowledgebase/magento-getting-started/essential-magento-2-commands-to-run-over-ssh · © Kualo Ltd._
