Magento2, Magento2 Commands

Magento 2 Useful CLI Commands List

Magento 2 Useful CLI Commands List

In this blog, we will discuss about Command Line Inteface (CLI) in Magento 2. As you know, from Magento 2, they add many commands in bin magento. Merchants that use Magento 2 know it has a console command line.

Below is the list of most important SSH / CLI commands for Magento 2 that I have found useful. To use these commands you will need to have SSH access to your server or use the Command Line for local access.

Displays help for a command

php bin/magento help

Lists commands

php bin/magento list

Magento CLI Version

php bin/magento --version

View cache status Using Command Line

php bin/magento cache:status

Enable Cache Using Command Line

php bin/magento cache:enable cache_type

Disable Cache Using Command Line

php bin/magento cache:disable cache_type

Cache Clean Using Command Line

php bin/magento cache:clean

Cache Flush Using Command Line

php bin/magento cache:flush

Enable frontend template hints

php bin/magento dev:template-hints:enable

Displays the Magento Admin URI

php bin/magento info:adminuri

Disable frontend template hints

php bin/magento dev:template-hints:disable

Setup Upgrade Using Command Line

php bin/magento setup:upgrade

If you donโ€™t want to remove pub/static files while installing/updating database then use following command

php bin/magento setup:upgrade --keep-generated

Static Content Deploy Using Command Line

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

Static Content Deploy For Particular Language Using Command Line

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

Static Content Deploy For Magento Backend Theme Using Command Line

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

Static Content Deploy For Specific Themes Using Command Line

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

Exclude Themes on Static Content Deploy and does not minify HTML files Using Command Line

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

Reindexing Using Command Line

php bin/magento indexer:reindex

View the list of indexers Using Command Line

php bin/magento indexer:info

View indexer status Using Command Line

php bin/magento indexer:status

Show the mode of all indexers Using Command Line

php bin/magento indexer:show-mode

See all modules Status Using Command Line

php bin/magento module:status

Enable module Using Command Line

php bin/magento module:enable Namespace_Module

Disable module Using Command Line

php bin/magento module:disable Namespace_Module

Uninstall Module Using Command Line installed by composer

php bin/magento module:uninstall Namespace_Module

Check Current Mode Using Command Line

php bin/magento deploy:mode:show

Change To Developer Mode Using Command Line

php bin/magento deploy:mode:set developer

Change To Production Mode Using Command Line

php bin/magento deploy:mode:set production

Generates DI configuration and all missing classes that can be auto-generated

php bin/magento setup:di:compile

Creates an administrator

php bin/magento admin:user:create

Unlock Admin User Using Command Line

php bin/magento admin:user:unlock adminusername

Enable Maintenance Mode Using Command Line

php bin/magento maintenance:enable

To enable maintenance mode for all clients except 192.0.0.1 and 192.0.0.2:

php bin/magento maintenance:enable --ip=192.0.0.1 --ip=192.0.0.2

To clear the list of IPs

php bin/magento maintenance:enable --ip=none

Disable Maintenance Mode Using Command Line

php bin/magento maintenance:disable

Check Maintenance Mode Status Using Command Line

php bin/magento maintenance:status

Allow IP on Maintenance Mode Using Command Line

php bin/magento maintenance:allow-ips --ip=192.0.0.1 --ip=192.0.0.2

Set Magento crontab Using Command Line

php bin/magento cron:install --force

Remove Magento crontab Using Command Line

php bin/magento cron:remove

Creates resized product images

php bin/magento catalog:images:resize

Prints list of available backup files

php bin/magento info:backups:list

Displays the list of available currencies

php bin/magento info:currency:list

Displays the list of available language locales

php bin/magento info:language:list

Displays the list of available timezones

php bin/magento info:timezone:list

Deploy sample data modules

php bin/magento sampledata:deploy

Remove all sample data packages from composer.json

php bin/magento sampledata:remove

Reset all sample data modules for re-installation

php bin/magento sampledata:reset

Takes backup of Magento Application code base, media and database

php bin/magento setup:backup

Creates or modifies the deployment configuration

php bin/magento setup:config:set

Installs and upgrades data in the DB

php bin/magento setup:db-data:upgrade

Installs and upgrades the DB schema

php bin/magento setup:db-schema:upgrade

Checks if DB schema or data requires upgrade

php bin/magento setup:db:status

Installs the Magento application

php bin/magento setup:install

Rolls back Magento Application codebase, media and database

php bin/magento setup:rollback

Uninstalls the Magento application

php bin/magento setup:uninstall

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

Disable merge JS

php bin/magento config:set dev/js/merge_files 0

Disable JS Bundling

php bin/magento config:set dev/js/enable_js_bundling 0

Disable minify JS

php bin/magento config:set dev/js/minify_files 0

Disable merge CSS

php bin/magento config:set dev/css/merge_css_files 0

Disable minify CSS

php bin/magento config:set dev/css/minify_files 0

If require then also use php version like php7.2 bin/magento cache:clean.

If you get any memory related error then use -dmemory_limit=2G.

php -dmemory_limit=2G bin/magento cache:clean.

๐Ÿ™‚ Happy Coding.

Keep Liking & Sharing ๐Ÿ’ป


DevDocs

Home
Tagged , , ,