In this tutorial, I will give you all the command list which is useful for Magento 2. Sometimes, we need to perform some operations and we do that using programmatically but, it was also complete by just single line command execute. So, why we do programming operations. So, the command line interface saves your maximum time and execute operation very quickly.
I have some important command list which is used in Magento 2. You can use it in your local server/system or FTP server by SSH access.
You may also like this :
Magento 2 Useful Command List :
Create an admin user using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”php” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento admin:user:create --admin-user='admin' --admin-password='admin123' --admin-email='admin@xyz.com' --admin-firstname='Rohan' --admin-lastname='Hapani'
[/dm_code_snippet]
Unlock admin user account using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento admin:user:unlock username
[/dm_code_snippet]
Setup upgrades using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:upgrade
[/dm_code_snippet]
Setup upgrades without remove pub/static files using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:upgrade --keep-generated
[/dm_code_snippet]
Uninstalls the Magento application using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:uninstall
[/dm_code_snippet]
Cache clean using the CLI :
[dm_code_snippet background=”no” background-mobile=”yes” slim=”no” line-numbers=”no” bg-color=”#abb8c3″ theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:clean
[/dm_code_snippet]
Cache clean with specific type using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:clean cache_type
[/dm_code_snippet]
Disable cache using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:disable
[/dm_code_snippet]
Disable cache with specific type using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:disable cache_type
[/dm_code_snippet]
Enable cache using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:enable
[/dm_code_snippet]
Enable cache with specific type using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:enable cache_type
[/dm_code_snippet]
Flush cache using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:flush
[/dm_code_snippet]
Flush cache with specific type using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:flush cache_type
[/dm_code_snippet]
Check cache status using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cache:status
[/dm_code_snippet]
Static content deploy using the CLI : (Use -f for force deploy on 2.2.x or later)
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:static-content:deploy or php bin/magento -f setup:static-content:deploy
[/dm_code_snippet]
Deploys for specific language using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:static-content:deploy en_US
[/dm_code_snippet]
Deploys for Magento backend theme using the CLI :
[dm_code_snippet background=”yes” background-mobile=”yes” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:static-content:deploy --theme="Magento/backend"
[/dm_code_snippet]
Static content deploys for specific themes using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:static-content:deploy --theme Magento/luma --theme Magento/theme_number_two
[/dm_code_snippet]
Exclude themes on static content deploy and does not minify HTML files using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:static-content:deploy en_US --exclude-theme Magento/luma --no-html-minify
[/dm_code_snippet]
Creates resized product images using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento catalog:images:resize
[/dm_code_snippet]
Removes unused product attributes using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento catalog:product:attributes:cleanup
[/dm_code_snippet]
Set Magento crontab using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cron:install --force
[/dm_code_snippet]
Runs jobs by schedule using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cron:run
[/dm_code_snippet]
Remove Magento crontab using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento cron:remove
[/dm_code_snippet]
Reindexing using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento indexer:reindex
[/dm_code_snippet]
List of indexers using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento indexer:info
[/dm_code_snippet]
View indexer status using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento indexer:status
[/dm_code_snippet]
Show the mode of all indexers using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento indexer:show-mode
[/dm_code_snippet]
Resets indexer status to invalid using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento indexer:reset
[/dm_code_snippet]
Sets 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.
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento indexer:set-mode {schedule|realtime} [indexer]
[/dm_code_snippet]
Example:
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento indexer:set-mode schedule catalog_category_product catalog_product_category
[/dm_code_snippet]
Collects all phrases in the Magento with 4 columns using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin\magento i18n:collect-phrases -o "\var\www\html\magento\app\design\i18n\xx_YY.csv" -m
[/dm_code_snippet]
Collects all phrases in the Magento with 2 columns using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin\magento i18n:collect-phrases -o "\var\www\html\magento\app\design\i18n\xx_YY.csv" \var\www\html\magento\app\design\frontend
[/dm_code_snippet]
Uninstall language packages using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin\magento i18n:uninstall [-b|--backup-code] {language package name}
[/dm_code_snippet]
Set developer mode using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento deploy:mode:set developer
[/dm_code_snippet]
Set production mode using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento deploy:mode:set production
[/dm_code_snippet]
Check current mode using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento deploy:mode:show
[/dm_code_snippet]
DI compilation using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:di:compile
[/dm_code_snippet]
See all modules status using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento module:status
[/dm_code_snippet]
Enable module using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento module:enable VendorName_ModuleName
[/dm_code_snippet]
Disable module using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento module:disable VendorName_ModuleName
[/dm_code_snippet]
Uninstall module using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento module:uninstall VendorName_ModuleName
[/dm_code_snippet]
Prints list of available backup files using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento info:backups:list
[/dm_code_snippet]
List of available currencies using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento info:currency:list
[/dm_code_snippet]
List of available language locales using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento info:language:list
[/dm_code_snippet]
Displays the list of available timezones using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento info:timezone:list
[/dm_code_snippet]
Enable maintenance mode using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento maintenance:status
[/dm_code_snippet]
Enable maintenance mode for all clients except specific IPs :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento maintenance:enable --ip=127.0.0.1 --ip=127.0.0.2
[/dm_code_snippet]
Allow IP on maintenance mode using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento maintenance:allow-ips --ip=127.0.0.1 --ip=127.0.0.2
[/dm_code_snippet]
Clear the list of IPs using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento maintenance:enable --ip=none
[/dm_code_snippet]
Disable maintenance mode using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento maintenance:disable
[/dm_code_snippet]
Check maintenance mode status using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento maintenance:status
[/dm_code_snippet]
Displays the list of stores using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento store:list
[/dm_code_snippet]
Displays the list of websites using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento store:website:list
[/dm_code_snippet]
Takes backup of Magento Application code base, media and database using the CLI :
[dm_code_snippet background=”no” background-mobile=”no” slim=”no” line-numbers=”no” bg-color=”#fff” theme=”dark” language=”shell” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
php bin/magento setup:backup
[/dm_code_snippet]
I hope this blog is easy to understand about Magento 2 Command List. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution 🙂