List of Useful Magento 2 Commands

Running a Magento 2 store may not be as easy as it seems. There are lots of things you have to take care of, such as sales, orders, clients, etc., to say nothing of the development part. You should know how to run static content deploy or reindex Magento 2, as well as be aware of some other commands.

It's impossible to keep in mind all the commands for every single situation when you just start. So, that's why we created a list of useful Magento 2 commands that will save time and lessen the possibility of any errors. 

Want to know more about Magento commands? Keep reading, this article is just what you need. 

SSH

Command

Description 

php bin/magento list

Generates a list of commands

help

Shows help for a command

Cache

Command

Description

php bin/magento cache:clean Cleanes the cache types
php bin/magento cache:enable Enables the cache types
php bin/magento cache:disable Disables the cache types
php bin/magento cache:flush Flushes the cache types 
php bin/magento cache:status Displays the cache status

Setup

Command

Description

php bin/magento setup:upgrade Upgrades the application, DB schema, and data
php bin/magento setup:di:compile Creates the DI setting and the missing classes that can be generated automatically
php bin/magento setup:static-content:deploy Deploys the static content 
php bin/magento setup:db-data:upgrade Installs and upgrades the data in the DB
php bin/magento setup:db:status Shows the status of the DB, and whether it needs any upgrades
php bin/magento setup:backup Creates a backup of the file system, database, and media directory
php bin/magento setup:cron:run Runs the scheduled cron job 
php bin/magento setup:performance:generate-fixtures Generates fixtures
php bin/magento setup:rollback Rolls back the Magento file system, database, and media directory
php bin/magento setup:config:set Creates or tweaks the deployment configuration 
php bin/magento setup:store-config:set Sets the store configuration
php bin/magento setup:install Installs the application
php bin/magento setup:uninstall Uninstalls the application

Deploy

Command

Description

php bin/magento deploy:mode:set Sets the deploy mode
php bin/magento deploy:mode:show Shows the current deploy mode

Catalog

Command

Description

php bin/magento catalog:images:resize Resizes the images
php bin/magento catalog:product:attributes:cleanup Cleares unused attributes

Indexers

Command

Description

php bin/magento indexer:info Shows the available indexers
php bin/magento indexer:reindex Reindexes data
php bin/magento indexer:reset Makes the indexer's status invalid
php bin/magento indexer:set-mode Sets indexer's mode 
php bin/magento indexer:show-mode Shows the indexer's mode 
php bin/magento indexer:status Shows the status of the indexer

Maintenance

Command

Description

php bin/magento maintenance:enable Enables the maintenance mode 
php bin/magento maintenance:disable Disables the maintenance mode 
php bin/magento maintenance:status Shows the status of the maintenance mode 
php bin/magento maintenance:allow-ips Sets the IP addresses for the maintenance mode 

Module

Command

Description

php bin/magento module:enable Enables a specific module 
php bin/magento module:disable Disables a specific module
php bin/magento module:status Shows the status of the module
php bin/magento module:uninstall Uninstalls the module installed using the composer  

Admin

Command

Description 

php bin/magento admin:user:create

Creates an admin user

php bin/magento admin:user:unlock Unlocks admin account

Config

Command

Description

php bin/magento config:sensitive:set Sets the sensitive configuration values
php bin/magento config:set Adds changes to the system configuration 
php bin/magento config:show Shows the configuration value of the particular path

Info

Command

Description

php bin/magento info:adminuri Shows the Magento admin URL
php bin/magento info:backups:list Displays the available backups 
php bin/magento info:currency:list Shows the available currencies
php bin/magento info:dependencies:show-framework Displays the dependencies in the Magento framework
php bin/magento info:dependencies:show-modules Displays the modules between the dependencies 
php bin/magento info:dependencies:show-modules-circular Shows the circular dependencies between modules 
php bin/magento info:language:list Shows the list of the used language locales 
php bin/magento info:timezone:list Displays the available timezones

Cron

Command

Description

php bin/magento cron:run Runs the cron according to the schedule

Dev

Command

Description

php bin/magento dev:source-theme:deploy Collects and displays the source theme files
php bin/magento dev:tests:run Runs tests 
php bin/magento dev:urn-catalog:generate Generates the URN catalog
php bin/magento dev:xml:convert Converts XML files using the XML style samples

Store

Command

Description

php bin/magento store:list Shows the list of the available stores
store:website:list Shows the available websites

Theme

Command

Description

php bin/magento theme:uninstall Uninstalls the theme

Varnish

Command

Description

php bin/magento varnish:vcl:generate Generates Varnish VCL and echos it to the command line

Queue

Command

Description

php bin/magento queue:consumers:list List of MessageQueue consumers
php bin/magento queue:consumers:restart Restart MessageQueue
php bin/magento queue:consumers:start Start MessageQueue consumer

Remote storage

Command

Description

php bin/magento remote-storage:sync Synchronize media files with remote storage

Media content

Command

Description

php bin/magento media-content:sync Synchronize content with assets

Command

Description

php bin/magento media-gallery:sync Synchronize media storage and media assets in the database

Sample data

Command

Description

php bin/magento sampledata:deploy Deploys the sample data modules 
php bin/magento sampledata:remove Removes the sample data packages from composer.json
php bin/magento sampledata:reset Resets the sample data modules for re-installation 

i18n

Command

Description

php bin/magento i18n:collect-phrases Collects phrases in the codebase
php bin/magento i18n:pack Saves language package
php bin/magento i18n:uninstall Uninstalls language packages

Customer

Command

Description

php bin/magento customer:hash:upgrade Upgrades customer's hash 


So, here you have all the most commonly used Magento 2 commands. Hopefully, this list will help you to be more confident in Magento development and optimizing the store management.

However, if you want a shortcut, you can refer to the Magento 2 command shortcuts and, perhaps, they will be easier to remember.