On this page
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.
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, 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:
cd /path/to/your/magento
If you are unsure of the path, check the 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:
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:
php bin/magento cache:clean
php bin/magento cache:flush
To see which cache types exist and whether they are enabled:
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:
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:
php bin/magento indexer:set-mode schedule
Scheduled indexing relies on your Magento cron jobs running correctly.
Maintenance mode
Put the store into maintenance mode before upgrades or risky changes, then take it back out afterwards:
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:
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:
php bin/magento admin:user:unlock yourusername
php bin/magento admin:user:create \
--admin-user="newuser" \
--admin-email="[email protected]" \
--admin-firstname="First" \
--admin-lastname="Last"
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, run the following sequence to apply database changes, recompile and refresh static assets:
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:
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:
php bin/magento deploy:mode:show
Live stores should always run in production mode. See our guide on switching Magento 2 to production mode for the details and the performance difference it makes.
If you need any further help, please contact our support team.