Magento 2 SSH/CLI Commands List

Do you ever get problems to remember  Magento 2 commands (SSH/CLI) while developing sites ?

I started with Magento 2 with the basic things. While developing site, I noticed on each step you must know few Magento 2 commands in order to deploy and run your website successfully.

During development of Magento 2 websites you must aware with these Magento 2 commands which is essential to make your way easy and save your lot of time.

It is just waste of time juggling through other websites to find each commands. Here in this article I have consolidated all comprehensive Magento 2 SSH/CLI commands for you.

Important :

To use these commands you must have SSH access to your server or use command line for local access .

Below is the list of most important SSH / CLI commands for Magento 2 that I have found useful.

Let’s start

  1. 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

  1. Cache Clean Using Command Line
php bin/magento cache:clean

  1. Cache Flush Using Command Line
php bin/magento cache:flush

  1. View cache status Using Command Line
php bin/magento cache:status

  1. Enable Cache Using Command Line
php bin/magento cache:enable [cache_type]

  1. Disable Cache Using Command Line
php bin/magento cache:disable [cache_type]

  1. Static Content Deploy Using Command Line (Use -f for force deploy on 2.2.x or later)
php bin/magento setup:static-content:deploy

  1. Static Content Deploy For Particular Language Using Command Line
php bin/magento setup:static-content:deploy en_US

  1. 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"

  1. Static Content Deploy For Specific Themes Using Command Line (Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy --theme Magento/luma --theme Magento/second_theme

  1. 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

  1. Reindexing Using Command Line
php bin/magento indexer:reindex

  1. View the list of indexers Using Command Line
php bin/magento indexer:info

  1. View indexer status Using Command Line
php bin/magento indexer:status

  1. Show the mode of all indexers Using Command Line
php bin/magento indexer:show-mode

  1. See all modules Status Using Command Line
php bin/magento module:status

  1. Enable module Using Command Line
php bin/magento module:enable Namespace_Module

  1. Disable module Using Command Line
php bin/magento module:disable Namespace_Module

  1. Uninstall Module Using Command Line
php bin/magento module:uninstall Namespace_Module

  1. Check Current Mode Using Command Line
php bin/magento deploy:mode:show

  1. Change To Developer Mode Using Command Line
php bin/magento deploy:mode:set developer

  1. Change To Production Mode Using Command Line
php bin/magento deploy:mode:set production

  1. Run the single-tenant Compiler Using Command Line
php bin/magento setup:di:compile

  1. Unlock Admin User Using Command Line
php bin/magento admin:user:unlock adminusername

  1. Enable Maintenance Mode Using Command Line
php bin/magento maintenance:enable

  1. 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

  1. To Clear the list of IPs.
php bin/magento maintenance:enable --ip=none

  1. Disable Maintenance Mode Using Command Line
php bin/magento maintenance:disable

  1. Check Maintenance Mode Status Using Command Line
php bin/magento maintenance:status

  1. Allow IP on Maintenance Mode Using Command Linee
php bin/magento maintenance:allow-ips --ip=192.0.0.1 --ip=192.0.0.2

  1. Set Magento crontab Using Command Line
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


  1. Remove Magento crontab Using Command Line
php bin/magento cron:remove

 Conclusion

I hope this Magento 2 commands technical note will help you and save your time while developing website with Magento 2.

Also I appriciate your comments below.

Please do specify in comments section if any other handy commands which I have not listed.

If you like, share this post for others to make their life easy with Magento 2 development journey.

51

Leave a Reply

Your email address will not be published. Required fields are marked *