Magento 2: Command Line Commands

Magento 2 has cosole command line which is very useful for fast reindex or flush cache or admin user create, etc.. See below for the complete list of command line commands available on Magento 2.

Command Lists

Lists commands.


php bin/magento --list

Create new Admin User

Creates an administrator



php bin/magento admin:user:create –admin-firstname="FirstName" -admin-lastname="LastName" –admin-email="" –admin-user="username" -admin-password="password"

Unlock an Admin User

Unlock Admin Account


php bin/magento admin:user:unlock username

Cache Clean

Cleans cache type(s)


php bin/magento cache:clean
php bin/magento cache:clean config
php bin/magento cache:clean layout
php bin/magento cache:clean block_html
php bin/magento cache:clean collections
php bin/magento cache:clean reflection
php bin/magento cache:clean db_ddl
php bin/magento cache:clean eav
php bin/magento cache:clean customer_notification
php bin/magento cache:clean target_rule
php bin/magento cache:clean full_page
php bin/magento cache:clean config_integration
php bin/magento cache:clean config_integration_api
php bin/magento cache:clean translate
php bin/magento cache:clean config_webservice

Cache Disable

Disables cache type(s)


php bin/magento cache:disable
php bin/magento cache:disable config
php bin/magento cache:disable layout
php bin/magento cache:disable block_html
php bin/magento cache:disable collections
php bin/magento cache:disable reflection
php bin/magento cache:disable db_ddl
php bin/magento cache:disable eav
php bin/magento cache:disable customer_notification
php bin/magento cache:disable target_rule
php bin/magento cache:disable full_page
php bin/magento cache:disable config_integration
php bin/magento cache:disable config_integration_api
php bin/magento cache:disable translate
php bin/magento cache:disable config_webservice

Cache Enable

Enables cache type(s)


php bin/magento cache:enable
php bin/magento cache:enable config
php bin/magento cache:enable layout
php bin/magento cache:enable block_html
php bin/magento cache:enable collections
php bin/magento cache:enable reflection
php bin/magento cache:enable db_ddl
php bin/magento cache:enable eav
php bin/magento cache:enable customer_notification
php bin/magento cache:enable target_rule
php bin/magento cache:enable full_page
php bin/magento cache:enable config_integration
php bin/magento cache:enable config_integration_api
php bin/magento cache:enable translate
php bin/magento cache:enable config_webservice

Cache flush

Flushes cache storage used by cache type(s)


php bin/magento cache:flush
php bin/magento cache:flush config
php bin/magento cache:flush layout
php bin/magento cache:flush block_html
php bin/magento cache:flush collections
php bin/magento cache:flush reflection
php bin/magento cache:flush db_ddl
php bin/magento cache:flush eav
php bin/magento cache:flush customer_notification
php bin/magento cache:flush target_rule
php bin/magento cache:flush full_page
php bin/magento cache:flush config_integration
php bin/magento cache:flush config_integration_api
php bin/magento cache:flush translate
php bin/magento cache:flush config_webservice

Cache Status

Checks cache status


php bin/magento cache:status

Catalog Image Resize

Creates resized product images based on the view.xml on the theme folder.


php bin/magento catalog:images:resize

Product attribute cleanup

Removes unused product attributes.


php bin/magento catalog:product:attributes:cleanup

Run Cron

Runs jobs by schedule


php bin/magento cron:run
php bin/magento cron:run --group=index
php bin/magento cron:run --group=staging
php bin/magento cron:run --group=default
php bin/magento cron:run --group=catalog_event


Magento 2: Command Line Commands

Magento 2: Cannot create symlink, error code(1314)

The issue with the CSs/JS/Images not loading on the Magento2 frontend and admin side. I I I I have installed the Magento2 on xampp. The soultion for this is:

Open the xampp control with Administrator priviligies and start the Apache server, this solved the symlink problem with xampp and windows. Right click on the xampp icon and seklect the option “Run as Administrator”

REF: symlink(): Cannot create symlink, error code(1314) #81

Go to file app/etc/di.xml
Find out the below code part


Replace this with below:


Magento 2: Cannot create symlink, error code(1314)

Magento: Reindex via SSH

The fastest way to reindex Magento data is manually via SSH. To reindex the Magento data manually, you need to have an SSH access to your web hosting account. All you need to do to reindex your Magento data manually is to log in your hosting account via SSH, go to your Magento installation directory (e.g. /var/www/html) and execute the following command:

php shell/indexer.php reindexall

To reindex individual items execute the below commands:

Category Flat Data:
php shell/indexer.php --reindex catalog_category_flat

Product Flat Data:
php shell/indexer.php --reindex catalog_product_flat

Stock Status:
php shell/indexer.php --reindex cataloginventory_stock

Catalog product price:
php shell/indexer.php --reindex catalog_product_price

Category URL Rewrites:
php shell/indexer.php --reindex catalog_url_category

Product URL Rewrites:
php shell/indexer.php --reindex catalog_url_product

URL Redirects:
php shell/indexer.php --reindex url_redirect

Catalog Category/Product Index:
php shell/indexer.php --reindex catalog_category_product

Catalog Search Index:
php shell/indexer.php --reindex catalogsearch_fulltext

Tag Aggregation Data:
php shell/indexer.php --reindex tag_summary

Product Attributes:
php shell/indexer.php --reindex catalog_product_attribute

Magento: Reindex via SSH