Magento 2 Console Commands

Magento 2 provides powerful CLI commands via bin/magento to help manage your store efficiently. These commands can handle everything from installation and deployment to cache, indexers, modules, and more.

🧠 Basic Command Format

All Magento 2 CLI commands are run from the Magento root directory using:

php bin/magento <command-name>
  

🛠️ Setup & Deployment

  • Upgrade database schema and data:
    php bin/magento setup:upgrade
          

  • Compile DI:
    php bin/magento setup:di:compile
          

  • Deploy static content:
    php bin/magento setup:static-content:deploy
          

🧹 Cache Management

  • Clean cache:
    php bin/magento cache:clean
          

  • Flush all cache:
    php bin/magento cache:flush
          

⚙️ Indexer Commands

  • Reindex all:
    php bin/magento indexer:reindex
          

  • List indexers:
    php bin/magento indexer:status
          

🧪 Module Management

  • Enable module:
    php bin/magento module:enable Vendor_Module
          

  • Disable module:
    php bin/magento module:disable Vendor_Module
          

  • Check module status:
    php bin/magento module:status
          

👥 Admin User Management

  • Create a new admin user:
    php bin/magento admin:user:create
          

🔄 Maintenance Mode

  • Enable maintenance mode:
    php bin/magento maintenance:enable
          

  • Disable maintenance mode:
    php bin/magento maintenance:disable
          

🧠 Quick Memory Cheats

Action Command
Upgrade Magento setup:upgrade
Compile Code setup:di:compile
Deploy Static setup:static-content:deploy
Clear Cache cache:clean
Reindex indexer:reindex

✅ Summary

  • Use bin/magento for all CLI tasks in Magento 2
  • Learn the most-used commands for setup, cache, and modules
  • Remember the pattern: php bin/magento command