Skip to content

Using the Magento Command-Line Interface (CLI)

Magento includes a powerful command-line interface (CLI) that lets you perform common administrative tasks quickly and efficiently. On ruachost.com, the CLI is especially useful for automation, troubleshooting, and performance tuning.

  • Faster than using the admin panel for repetitive tasks.
  • Enables automation with scripts and cron jobs.
  • Provides advanced options for developers and administrators.
  • Essential for managing large or complex Magento stores.
  1. Log in to your hosting account via SSH.

  2. Navigate to your Magento installation directory:

    Terminal window
    cd ~/public_html
  3. The CLI tool is located in the bin directory:

    Terminal window
    bin/magento
  4. Run the command to see available options:

    Terminal window
    php bin/magento list
  • Flush all caches:

    Terminal window
    php bin/magento cache:flush
  • Clean cache storage:

    Terminal window
    php bin/magento cache:clean
  • Reindex all data:

    Terminal window
    php bin/magento indexer:reindex
  • Enable a module:

    Terminal window
    php bin/magento module:enable Vendor_ModuleName
  • Disable a module:

    Terminal window
    php bin/magento module:disable Vendor_ModuleName
  • Upgrade database schema and data:

    Terminal window
    php bin/magento setup:upgrade
  • Compile dependency injection:

    Terminal window
    php bin/magento setup:di:compile
  • Deploy static content:

    Terminal window
    php bin/magento setup:static-content:deploy
  • Create a new admin user:

    Terminal window
    php bin/magento admin:user:create \
    --admin-user="newadmin" \
    --admin-password="StrongPassword123" \
    --admin-email="admin@example.com" \
    --admin-firstname="John" \
    --admin-lastname="Doe"
  • Always back up your site before running upgrade or deployment commands.
  • Use CLI commands in a staging environment before applying them to production.
  • Some commands may require elevated permissions depending on your hosting plan.