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.
Why Use the Magento CLI?
Section titled “Why Use the Magento CLI?”- 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.
Getting Started
Section titled “Getting Started”-
Log in to your hosting account via SSH.
-
Navigate to your Magento installation directory:
Terminal window cd ~/public_html -
The CLI tool is located in the
bindirectory:Terminal window bin/magento -
Run the command to see available options:
Terminal window php bin/magento list
Common Magento CLI Commands
Section titled “Common Magento CLI Commands”Cache Management
Section titled “Cache Management”-
Flush all caches:
Terminal window php bin/magento cache:flush -
Clean cache storage:
Terminal window php bin/magento cache:clean
Index Management
Section titled “Index Management”-
Reindex all data:
Terminal window php bin/magento indexer:reindex
Module Management
Section titled “Module Management”-
Enable a module:
Terminal window php bin/magento module:enable Vendor_ModuleName -
Disable a module:
Terminal window php bin/magento module:disable Vendor_ModuleName
Setup and Upgrades
Section titled “Setup and Upgrades”-
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
User Management
Section titled “User Management”-
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"
Important Notes
Section titled “Important Notes”- 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.