Magento2 Command Collection

In Magento, we have to do lots of work from the command line, command line works quickly. For example, in Magento, we run index management command in command line interface. A command-line interface is also known as a command line user interface. If a user runs a command from the command line, then specified code will run.

Here are some examples of commands line in Magento2.

For cache clean
php bin/magento cache:clean

Cache Flush
php bin/magento cache:flush

Cashe Status
php bin/magento cache:status

Cache Enable
php bin/magento cache:enable

Cache Disable
php bin/magento cache:disable

Run Cron
php bin/magento cron:run

Reindex
php bin/magento indexer:reindex

Permission Command
chmod -R 777 var pub generated

Check Mode
php bin/magento deploy:mode:show

Set Developer Mode
php bin/magento deploy:mode:set developer
Set Production Mode
php bin/magento deploy:mode:set production
Upgrade
php bin/magento setup:upgrade

Setup Compile
php bin/magento setup:di:compile

Content Deploy
php bin/magento setup:static-content:deploy
Content Deploy (Force)
php bin/magento setup:static-content:deploy -f
Content Deploy (Theme only)
php bin/magento setup:static-content:deploy –theme Vendor/theme_name
Enable Maintenance Mode
php bin/magento maintenance:enable
Disable Maintenance Mode  

php bin/magento maintenance:disable

Enable Maintenance Mode (Except IP)
bin/magento maintenance:enable –ip=192.168.32.11 –ip=192.168.65.11
(Change IP address with your IP address)
Set Memory Limit
php -dmemory_limit=2G bin/magento setup:static-content:deploy
 
Template Hint Enable
php bin/magento dev:template-hints:enable
php bin/magento cache:flush
chmod -R 777 var pub generated

Template Hint Disable
php bin/magento dev:template-hints:disable
php bin/magento cache:flush
chmod -R 777 var pub generated

Magento version check
php bin/magento –version

Uninstall Module
php bin/magento module:uninstall Vendor_ModuleName
php bin/magento module:uninstall Vendor_ModuleName–clear-static-content

Module List(With Status)
php bin/magento module:status

Enable Module
php bin/magento module:enable Vendor_ModuleName

Disable Module
php bin/magento module:disable Vendor_ModuleName

Index Status
php bin/magento indexer:info
php bin/magento indexer:status

Index Reset
php bin/magento indexer:reset
php bin/magento indexer:reset cataloginventory_stock

Sample Data

php bin/magento sampledata:deploy
Public Key: xxxxxxxxxxxxxxxxxxxxxxxxxxx (Get From Magento Store)
Private Key: xxxxxxxxxxxxxxxxxxxxxxxxxxx (Get From Magento Store)
php bin/magento setup:upgrade

Create Magento Admin User
php bin/magento admin:user:create –admin-user=”admin” –admin-firstname=”Admin” –admin-lastname=”A” –admin-email=”example@example.com” –admin-password=”admin@123″

Admin user unlock
php bin/magento admin:user:unlock admin

To change base url directly from command
bin/magento config:set web/unsecure/base_url http:/store.example.com/
bin/magento config:set web/secure/base_url http://store.example.com/
bin/magento cache:clean