Magento command-line reference

Categorized reference for the php bin/magento command-line tool on TurboStack, covering setup, cache, indexers, modules and cron.

Magento 2 (Adobe Commerce) ships a command-line interface (CLI) at bin/magento. You run it over SSH to install modules, clear caches, rebuild indexes and switch deployment modes. This page groups the common commands by task. For where the files live and the scheduled jobs, see Magento reference.

How to run it

Connect over SSH, change into the project root, then call the tool with PHP:

cd ~/public_html
php bin/magento <command>

Here ~ is your system user's home directory (for example /var/www/prod/). Run every bin/magento command from ~/public_html.

Run php bin/magento list for the full command list, and php bin/magento help <command> for the options of a single command.

Setup and maintenance

Command What it does
setup:install Installs Magento with DB and admin configuration.
setup:uninstall Uninstalls Magento and removes configuration.
setup:upgrade Applies DB schema/data changes from modules.
setup:upgrade --keep-generated Keeps generated code during upgrade (for production).
setup:di:compile Compiles dependency injection code.
setup:static-content:deploy Deploys static view files for frontend.
setup:static-content:deploy -f Forces deployment even in developer mode.
setup:config:set Sets configuration values like DB or admin URL.
setup:db:status Shows database upgrade status.
setup:db:status --show-config Shows current DB connection settings.
maintenance:enable / maintenance:disable / maintenance:status Enables, disables maintenance mode, or shows its status.

Cache management

Command What it does
cache:clean Clears enabled cache types.
cache:flush Clears all cache backends (e.g., Redis).
cache:enable / cache:disable Enables or disables specified cache types.
cache:status Displays cache types and their status.

Index management

Command What it does
indexer:reindex Rebuilds indexers (e.g. product/category data).
indexer:reindex catalogsearch_fulltext Reindexes product search data.
indexer:status Shows indexer status.
indexer:reset Resets indexers that failed.
indexer:info Lists all indexers.
indexer:show-mode Displays indexer mode (schedule/realtime).
indexer:set-mode {schedule\|realtime} [indexer] Sets mode for a specific indexer.

Module management

Command What it does
module:status Lists all modules and their status.
module:enable <Module_Name> Enables a module.
module:disable <Module_Name> Disables a module.
module:uninstall <Module_Name> Uninstalls a module and optionally removes its data.

Admin users

Command What it does
admin:user:create Creates a new admin user.
admin:user:unlock <username> Unlocks a locked admin account.
admin:user:delete <username> Deletes an admin user.

Security

Command What it does
security:passwords:upgrade Upgrades customer password hash format.
security:hash:upgrade Upgrades internal hash algorithms for better security.

Deployment mode and developer tools

Command What it does
deploy:mode:show Shows current deployment mode.
deploy:mode:set {developer\|production\|default} Changes deployment mode.
deploy:mode:set production --skip-compilation Skips DI compilation during mode switch.
dev:profiler:enable / dev:profiler:disable Enables or disables the performance profiler.
dev:template-hints:enable / dev:template-hints:disable Displays or hides template hints in frontend.
dev:source-theme:deploy Deploys source files (e.g. LESS) for custom themes.

Store configuration

Command What it does
config:set <path> <value> Sets a configuration value.
config:set catalog/search/engine elasticsearch7 Sets Elasticsearch as the search engine.
config:show <path> Shows a configuration value.
config:sensitive:set <path> <value> Marks config value as sensitive (e.g., passwords).
config:sensitive:remove <path> Removes sensitive flag from a config.

EAV attributes

Magento stores product attributes in an Entity-Attribute-Value (EAV) model.

Command What it does
eav:attribute:remove <attribute_code> Removes a custom attribute from the EAV model.

Inventory reservations

Command What it does
inventory:reservation:list-inconsistencies Lists mismatches in stock reservations.
inventory:reservation:create-compensations Fixes reservation issues by creating compensation records.

Logs

Command What it does
dev:log:clean Clears system and exception logs.

Testing

Command What it does
dev:tests:run {unit\|integration\|functional} Runs specified test suite.

Backup and restore

Command What it does
setup:backup --code --media --db Creates backup of codebase, media, and DB.
setup:rollback --code-file=<file> --db-file=<file> Restores from specified backup files.

Cron and message-queue consumers

Command What it does
cron:run Executes scheduled cron jobs immediately.
cron:install Installs Magento cron jobs into system crontab.
queue:consumers:list List the message-queue consumers
queue:consumers:start <name> Start a single consumer

TurboStack installs the Magento cron entries for your system user automatically. On a busy store, run each message-queue consumer as a persistent user service instead of relying on cron alone - see Magento best practices.