- Common Magento 2 Commands
- Cache Clean:
- Cache Flush:
- Setup Upgrade:
- If you want pub/static files while installing or updating database then use following command:
- Setup Compile:
- Static Content Deploy(use -f for force deploy on developer mode in 2.2.x or later):
- Static Content Deploy For Particular Language:
- Static Content Deploy For Magento Backend Theme Using Command Line (Working on 2.1.1 or later)
- Static Content Deploy For Specific Themes (Working on 2.1.1 or later)
- Exclude Themes on Static Content Deploy and does not minify HTML files Using Command Line (Working on 2.1.1 or later)
- Reindex data:
- View the list of indexers:
- View indexer status:
- Show the mode of all indexers:
- Here is the list of commands in Magento 2
Common Magento 2 Commands
Cache Clean:
php bin/magento cache:clean
Cache Flush:
php bin/magento cache:flush
Setup Upgrade:
php bin/magento setup:upgrade
If you want pub/static files while installing or updating database then use following command:
php bin/magento setup:upgrade --keep-generated
Setup Compile:
php bin/magento setup:di:compile
Static Content Deploy(use -f for force deploy on developer mode in 2.2.x or later):
php bin/magento setup:static-content:deploy
Static Content Deploy For Particular Language:
php bin/magento setup:static-content:deploy en_US
Static Content Deploy For Magento Backend Theme Using Command Line (Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy --theme="Magento/backend"
Static Content Deploy For Specific Themes (Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy --theme Magento/luma --theme Magento/another_theme
Exclude Themes on Static Content Deploy and does not minify HTML files Using Command Line (Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy en_US --exclude-theme Magento/luma --no-html-minify
Reindex data:
php bin/magento indexer:reindex
View the list of indexers:
php bin/magento indexer:info
View indexer status:
php bin/magento indexer:status
Show the mode of all indexers:
php bin/magento indexer:show-mode
Here is the list of commands in Magento 2
Cache related commands:
- Cache Clean:
php bin/magento cache:clean
- Cache Flush:
php bin/magento cache:flush
- View cache status:
php bin/magento cache:status
- Enable Cache:
php bin/magento cache:enable [cache_type]
- Disable Cache:
php bin/magento cache:disable [cache_type]
Modes related commands:
- Check Current Mode:
php bin/magento deploy:mode:show
- Change To Developer Mode:
php bin/magento deploy:mode:set developer
- Change To Production Mode:
php bin/magento deploy:mode:set production
Module related commands:
- See all modules Status:
php bin/magento module:status
- Enable module:
php bin/magento module:enable Namespace_Module
- Disable module:
php bin/magento module:disable Namespace_Module
- Uninstall Module:
php bin/magento module:uninstall Namespace_Module
Site Maintenance Related Commands:
- Enable Maintenance Mode:
php bin/magento maintenance:enable
- To enable maintenance mode for all clients except 10.10.16.1 and 10.10.16.2:
php bin/magento maintenance:enable --ip=10.10.16.1 --ip=10.10.16.2
- To clear the list of IPs:
php bin/magento maintenance:enable --ip=none
- Disable Maintenance Mode:
php bin/magento maintenance:disable
- Check Maintenance Mode:
php bin/magento maintenance:status
- Allow IP on Maintenance Mode:
php bin/magento maintenance:allow-ips --ip=192.0.0.1 --ip=192.0.0.2
Other Commands:
- Run the single-tenant Compiler:
php bin/magento setup:di:compile
- Unlock Admin User:
php bin/magento admin:user:unlock adminusername
- Set Magento crontab:
php bin/magento cron:install --force Use --force to rewrite an existing Magento crontab.
- To view the crontab, enter the following command as the Magento file system owner.
crontab -l
- Remove Magento crontab:
php bin/magento cron:remove
Apart from the above, there are other Magento CLI which can be used to perform other functions. Below is a compilation of all the useful CLI commands for Magento 2.
Command description | Command | Shortcodes |
Displays help for a command | php bin/magento help (command) | php bin/magento h |
Check the list of all commands –This will help list all the commands for Magento2 | php bin/magento list | php bin/magento |
To clean cache | php bin/magento cache:clean | php bin/magento c:c |
To disable cache | php bin/magento cache:disable | php bin/magento c:d |
To enable cache | php bin/magento cache:enable | php bin/magento c:e |
To flush or refresh cache | php bin/magento cache:flush | php bin/magento c:f |
To check the status of the cache | php bin/magento cache:status | php bin/magento c:s |
To create user in Magento | php bin/magento admin:user:create | php bin/magento a:u:c |
To unlock your admin account | php bin/magento admin:user:unlock | php bin/magento a:u:u |
To create the dump of the application | php bin/magento app:config:dump | |
To import data from shared files to appropriate data storage | php bin/magento app:config:import | |
To resize an image | php bin/magento catalog:images:resize | php bin/magento c:i:r |
To remove unused product attribute | php bin/magento catalog:product:attribute:cleanup | php bin/magento c:p:a:c |
To set sensitive configuration values | php bin/magento config:sensitive:set | |
To change system configuration | php bin/magento config:set | |
To show configuration value for given path. If path not specified, then all values will be shown | php bin/magento config:show | |
To generate and install crontab for current user | php bin/magento cron:install | |
To remove the tasks from crontab | php bin/magento cron:remove | |
To run jobs as per schedule | php bin/magento cron:run | php bin/magento c:r |
To upgrade customer’s hash according to the latest algorithm | php bin/magento customer:hash:upgrade | php bin/magento c:h:u |
To set application mode | php bin/magento deploy:mode:set | php bin/magento d:m:set |
To display current application mode | php bin/magento deploy:mode:show | php bin/magento d:m:sho |
To get information on dependency injection configuration for the command | php bin/magento dev:di:info | |
To disable DB query logging | php bin/magento dev:query-log:disable | |
To enable DB query logging | php bin/magento dev:query-log:enable | |
To collect and publish source files for the theme. | php bin/magento dev:source-theme:deploy | php bin/magento d:s:d |
To disable frontend template hints. A cache flush required. | php bin/magento dev:template-hints:disable | |
To enable frontend template hints. A cache flush required. | php bin/magento dev:template-hints:enable | |
To runs tests | php bin/magento dev:tests:run | php bin/magento d:t:r |
To generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml. | php bin/magento dev:urn-catalog:generate | php bin/magento d:u:g |
To convert XML file using XSL style sheets | php bin/magento dev:xml:convert | php bin/magento d:x:c |
To shows allowed Indexers | php bin/magento indexer:info | php bin/magento i:i |
To reindexes Data | php bin/magento indexer:reindex | php bin/magento i:rei |
To reset indexer status to invalid | php bin/magento indexer:reset | php bin/magento i:res |
To set index mode type | php bin/magento indexer:set-mode | php bin/magento i:set |
To show index mode | php bin/magento indexer:show-mode | php bin/magento i:sho |
To shows status of indexer | php bin/magento indexer:status | php bin/magento i:sta |
To discover phrases in the codebase | php bin/magento i18n:collect-phrases | php bin/magento i1:c |
To saves language package | php bin/magento i18n:pack | php bin/magento i1:p |
To uninstall language packages | php bin/magento i18n:uninstall | php bin/magento i1:u |
Displays the Magento Admin URI | php bin/magento info:adminuri | php bin/magento i:a |
Prints list of available backup files | php bin/magento info:backups:list | php bin/magento i:b:l |
Displays the list of available currencies | php bin/magento info:currency:list | php bin/magento i:c:l |
Shows number of dependencies on Magento framework | php bin/magento info:dependencies:show-framework | php bin/magento i:d:show-f |
Shows number of dependencies between modules | php bin/magento info:dependencies:show-modules | |
Shows number of circular dependencies between modules | php bin/magento info:dependencies:show-modules-circular | |
Displays the list of available language locales | php bin/magento info:language:list | php bin/magento i:l:l |
Displays the list of available timezones | php bin/magento info:timezone:list | php bin/magento i:t:l |
Sets maintenance mode exempt IPs | php bin/magento maintenance:allow-ips | php bin/magento m:a |
Disables maintenance mode | php bin/magento maintenance:disable | php bin/magento ma:d |
Enables maintenance mode | php bin/magento maintenance:enable | php bin/magento ma:e |
Displays maintenance mode status | php bin/magento maintenance:status | php bin/magento ma:s |
Disables specified modules | php bin/magento module:disable | php bin/magento mo:d |
Enables specified modules | php bin/magento module:enable | php bin/magento mo:e |
Displays status of modules | php bin/magento module:status | php bin/magento mo:s |
Uninstalls modules installed by composer | php bin/magento module:uninstall | php bin/magento m:u |
Deploy sample data modules | php bin/magento sampledata:deploy | php bin/magento sa:d |
Remove all sample data packages from composer.json | php bin/magento sampledata:remove | php bin/magento sa:rem |
Reset all sample data modules for re-installation | php bin/magento sampledata:reset | php bin/magento sa:res |
Takes backup of Magento Application code base, media and database | php bin/magento setup:backup | php bin/magento s:b |
Creates or modifies the deployment configuration | php bin/magento setup:config:set | php bin/magento s:c:s |
Runs cron job scheduled for setup application | php bin/magento setup:cron:run | php bin/magento s:c:r |
Installs and upgrades data in the DB | php bin/magento setup:db-data:upgrade | php bin/magento s:db-d:u |
Installs and upgrades the DB schema | php bin/magento setup:db-schema:upgrade | php bin/magento s:db-s:u |
Checks if DB schema or data requires upgrade | php bin/magento setup:db:status | php bin/magento s:d:s |
Generates DI configuration and all missing classes that can be auto-generated | php bin/magento setup:di:compile | php bin/magento s:d:c |
Installs the Magento application | php bin/magento setup:install | php bin/magento s:i |
Generates fixtures | php bin/magento setup:performance:generate-fixtures | php bin/magento s:p:g |
Rolls back Magento Application codebase, media and database | php bin/magento setup:rollback | php bin/magento se:r |
Deploys static view files | php bin/magento setup:static-content:deploy | php bin/magento s:s:d |
Installs the store configuration. Deprecated since 2.2.0. Use config:set instead | php bin/magento setup:store-config:set | php bin/magento s:s:s |
Uninstalls the Magento application | php bin/magento setup:uninstall | php bin/magento s:un |
Upgrades the Magento application, DB data, and schema | php bin/magento setup:upgrade | php bin/magento s:up |
Displays the list of stores | php bin/magento store:list | |
Displays the list of websites | php bin/magento store:website:list | |
Uninstalls theme | php bin/magento theme:uninstall | php bin/magento t:u |
Generates varnish VCL and echos it to the command line | php bin/magento varnish:vcl:generate |
Thank you for reading. Happy a great day…!