Useful Command List in Magento 2:

Below, you’ll find the list of all important Magento 2 SSH / CLI commands that you’ll often need when working on a project.

Create an admin user using the CLI:

php bin/magento admin:user:create –admin-user=’admin’ –admin-password=’admin123′ –admin-email=’admin@mysite.com’ –admin-firstname=’Json’ –admin-lastname=’Bourne’

Unlock admin user account using the CLI:

php bin/magento admin:user:unlock username

Setup upgrades using the CLI:

php bin/magento setup:upgrade

Setup upgrades without removing pub/static files using the CLI:

php bin/magento setup:upgrade –keep-generated

Uninstalling the Magento application using the CLI:

php bin/magento setup:uninstall

Cache cleaning using the CLI:

php bin/magento cache:clean

Cache cleaning with specific type using the CLI:

php bin/magento cache:clean cache_type

Disable cache using the CLI:

php bin/magento cache:disable

Disable cache with specific type using the CLI:

php bin/magento cache:disable cache_type

Enable cache using the CLI:

php bin/magento cache:enable

Enable cache with specific type using the CLI:

php bin/magento cache:enable cache_type

Flush cache using the CLI:

php bin/magento cache:flush

Flush cache with specific type using the CLI:

php bin/magento cache:flush cache_type

Check cache status using the CLI:

php bin/magento cache:status

Static content deploy using the CLI: (Use -f for force deploy on 2.2.x or later)

php bin/magento setup:static-content:deploy or php bin/magento -f setup:static-content:deploy

Deploy for specific language using the CLI:

php bin/magento setup:static-content:deploy en_US

Deploy for Magento backend theme using the CLI:

php bin/magento setup:static-content:deploy –theme=”Magento/backend”

Static content deploy for specific themes using the CLI:

php bin/magento setup:static-content:deploy –theme Magento/luma –theme Magento/theme_number_two

Exclude themes on static content deploy and does not minify HTML files using the CLI:

php bin/magento setup:static-content:deploy en_US –exclude-theme Magento/luma –no-html-minify

Creates resized product images using the CLI:

php bin/magento catalog:images:resize

Removes unused product attributes using the CLI:

php bin/magento catalog:product:attributes:cleanup

Set Magento crontab using the CLI:

php bin/magento cron:install –force

Run jobs by schedule using the CLI:

php bin/magento cron:run

Remove Magento crontab using the CLI:

php bin/magento cron:remove

Reindexing using the CLI:

php bin/magento indexer:reindex

List of indexers using the CLI:

php bin/magento indexer:info

View indexer status using the CLI:

php bin/magento indexer:status

Show the mode of all indexers using the CLI:

php bin/magento indexer:show-mode

Reset indexer status to invalid using the CLI:

php bin/magento indexer:reset

Set index mode type using the CLI:

  • realtime: Equivalent of M1 update on save
  • schedule: Sets the specified indexers to save according to the cron schedule.

php bin/magento indexer:set-mode {schedule|realtime} [indexer]

Example:

php bin/magento indexer:set-mode schedule catalog_category_product catalog_product_category

Collect all phrases in the Magento with 4 columns using the CLI:

php bin\magento i18n:collect-phrases -o “\var\www\html\magento\app\design\i18n\xx_YY.csv” -m

Collect all phrases in the Magento with 2 columns using the CLI:

php bin\magento i18n:collect-phrases -o “\var\www\html\magento\app\design\i18n\xx_YY.csv” \var\www\html\magento\app\design\frontend

Uninstall language packages using the CLI:

php bin\magento i18n:uninstall [-b|–backup-code] {language package name}

Set developer mode using the CLI:

php bin/magento deploy:mode:set developer

Set production mode using the CLI:

php bin/magento deploy:mode:set production

Check current mode using the CLI:

php bin/magento deploy:mode:show

DI compilation using the CLI:

php bin/magento setup:di:compile

See all modules status using the CLI:

php bin/magento module:status

Enable module using the CLI:

php bin/magento module:enable VendorName_ModuleName

Disable module using the CLI:

php bin/magento module:disable VendorName_ModuleName

Uninstall module using the CLI:

php bin/magento module:uninstall VendorName_ModuleName

Print list of available backup files using the CLI:

php bin/magento info:backups:list

List of available currencies using the CLI:

php bin/magento info:currency:list

List of available language locales using the CLI:

php bin/magento info:language:list

Display the list of available timezones using the CLI:

php bin/magento info:timezone:list

Enable maintenance mode using the CLI:

php bin/magento maintenance:status

Enable maintenance mode for all clients except specific IPs:

php bin/magento maintenance:enable –ip=127.0.0.1 –ip=127.0.0.2

Allow IP on maintenance mode using the CLI:

php bin/magento maintenance:allow-ips –ip=127.0.0.1 –ip=127.0.0.2

Clear the list of IPs using the CLI:

php bin/magento maintenance:enable –ip=none

Disable maintenance mode using the CLI:

php bin/magento maintenance:disable

Check maintenance mode status using the CLI:

php bin/magento maintenance:status

Display the list of stores using the CLI:

php bin/magento store:list

Display the list of websites using the CLI:

Display the list of websites using the CLI:

Take a backup of Magento Application code base, media, and database using the CLI:

php bin/magento setup:backup

Conclusion

This is the comprehensive list of all important and useful commands for Magento 2. We hope that you have now found what you’ve been looking for in managing the magento 2.x.x.x.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.