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?
-
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
-
Log in to your hosting account via SSH.
-
Navigate to your Magento installation directory:
Bash cd ~/public_html -
The CLI tool is located in the
bindirectory:Bash bin/magento -
Run the command to see available options:
Bash php bin/magento list
Common Magento CLI Commands
Cache Management
-
Flush all caches:
Bash php bin/magento cache:flush -
Clean cache storage:
Bash php bin/magento cache:clean
Index Management
-
Reindex all data:
Bash php bin/magento indexer:reindex
Module Management
-
Enable a module:
Bash php bin/magento module:enable Vendor_ModuleName -
Disable a module:
Bash php bin/magento module:disable Vendor_ModuleName
Setup and Upgrades
-
Upgrade database schema and data:
Bash php bin/magento setup:upgrade -
Compile dependency injection:
Bash php bin/magento setup:di:compile -
Deploy static content:
Bash php bin/magento setup:static-content:deploy
User Management
-
Create a new admin user:
Bash 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
-
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.