Magento 2 has one command-line interface that performs both installation and configuration tasks. Console component is one of the new features in Magento 2. Find various command here.
Debug
There are three mode default, developer, production.
To check the current mode:
php bin/magento deploy:mode:show
Set new mode
php bin/magento deploy:mode:set developer
php bin/magento --skip-compilation deploy:mode:set production
Deploy
The static view files deployment command enables you to write static files to the Magento file system.
php bin/magento setup:static-content:deploy
For specific theme
php bin/magento setup:static-content:deploy --theme Magento/backend --theme Tilkor/default
For specific language
php bin/magento setup:static-content:deploy en_US
To enable a component/extension
php bin/magento module:enable --clear-static-content Component_Name e.g. php bin/magento module:enable --clear-static-content Tilkor_TDebugHints php bin/magento setup:upgrade
To disable a component/extension
php bin/magento module:disable --clear-static-content Component_Name e.g. php bin/magento module:disable --clear-static-content Tilkor_TDebugHints
Reindex
php bin/magento indexer:info php bin/magento indexer:status php bin/magento indexer:reset php bin/magento indexer:reindex
Remove symlink
find pub/static -type l -exec rm '{}' \;
Flush/clean
php bin/magento cache:disable rm -rf var/cache/ var/di/ var/generation/ var/page_cache/ php bin/magento cache:flush php bin/magento cache:clean
Compile
php bin/magento setup:di:compile
Magento 2 files and folders permission
Below are the permissions needed to run the magento2, execute each command one by one.
find . -type f -exec chmod 644 {} ; // 644 permission for files find . -type d -exec chmod 755 {} ; // 755 permission for directory find ./var -type d -exec chmod 777 {} ; // 777 permission for var folder find ./pub/media -type d -exec chmod 777 {} ; find ./pub/static -type d -exec chmod 777 {} ; chmod 777 ./app/etc chmod 644 ./app/etc/*.xml
Upgrade Magento 2
Upgrading Magento 2 from older version to new version. Suppose Magento 2.2.4 has installed version and need to upgrade from 2.2.4 to latest 2.2.6 version. Follow steps.
php bin/magento maintenance:enable composer require magento/product-community-edition 2.2.6 --no-update composer update rm -rf var/di var/generation php bin/magento cache:clean php bin/magento cache:flush php bin/magento setup:upgrade php bin/magento indexer:reindex php bin/magento maintenance:disable
Admin User
Unlock user
php bin/magento admin:user:unlock ADMINUSERNAME
Create user
php bin/magento admin:user:create --admin-user='testuser' --admin-password='test@1234' --admin-email='tilkor.team@gmail.com' --admin-firstname='tilkor' --admin-lastname='software'
Image resize
Command to resize the images.
php php bin/magento catalog:images:resize
Uninstall extension using composer
php bin/magento module:disable <ExtensionProvider_ExtensionName> --clear-static-content php bin/magento setup:upgrade composer remove VendorName/VendorExtensionRepository Example: php bin/magento module:status php bin/magento module:disable Ebizmarts_MailChimp --clear-static-content php bin/magento setup:upgrade composer remove mailchimp/mc-magento2 php bin/magento setup:static-content:deploy -f