Magento command-line reference
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.
Note
To run a command with a specific Portable Hypertext Preprocessor (PHP) version, call that version's binary directly. Each installed version has its own binary at /usr/bin/php<version>, for example:
/usr/bin/php8.4 bin/magento setup:upgrade
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
Cache management
Index management
Module management
Admin users
Security
Deployment mode and developer tools
Store configuration
EAV attributes
Magento stores product attributes in an Entity-Attribute-Value (EAV) model.
Inventory reservations
Logs
Testing
Backup and restore
Warning
The setup:backup and setup:rollback commands are deprecated in current Magento releases. For a reliable, off-host copy of your store, use the platform backups instead.
Cron and message-queue consumers
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.
Tip
After deploying code on a production store, run the commands in this order: setup:upgrade --keep-generated -> setup:di:compile -> setup:static-content:deploy -> cache:flush.
Note
The n98-magerun2 tool is also installed on your host as magerun2. It adds convenience commands (for example magerun2 sys:info) on top of bin/magento. Run magerun2 list to see them.
Warning
cache:flush, maintenance:enable and deploy:mode:set change how the live storefront behaves. Run them during a quiet window and confirm the store still serves pages afterwards.
Related
- Magento reference
- Deploy Magento on TurboStack
- Magento best practices
- How to run multiple Magento store views
- Troubleshooting Magento
- How to switch PHP version
- Connect over SSH