Skip to content

Instantly share code, notes, and snippets.

@yogeshdubey2006
Last active August 30, 2019 18:28
Show Gist options
  • Save yogeshdubey2006/6616799e1630621f76a3aa186cf474b2 to your computer and use it in GitHub Desktop.
Save yogeshdubey2006/6616799e1630621f76a3aa186cf474b2 to your computer and use it in GitHub Desktop.
Magento 2 Command Shortcuts
## For deployment correct order
php bin/magento deploy:mode:set production
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
## if developer mode is enabled
php bin/magento setup:static-content:deploy -f
## delete subfolders under var directory
rm -rf var/di/ var/generation/ var/cache/ var/log/ var/page_cache/ var/session/ var/view_preprocessed/ pub/static/
## For refresh custom.css
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
## Disabled the modules
php bin/magento module:disable Magento_Weee
php bin/magento module:disable Magento_Review
## Maintenace status
php bin/magento maintenance:status
php bin/magento maintenance:disable
php bin/magento maintenance:enable
# exec script through and file permission
sudo php bin/magento setup:static-content:deploy -f
sudo php bin/magento setup:static-content:deploy en_GB -f
rm -rf pub/static/frontend/* var/view_preprocessed/ var/*cache/*
sudo rm -rf var/view_preprocessed/ var/*cache/*
sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo php bin/magento cache:flush
sudo chmod 777 -R var pub/static/*
sudo chmod 777 -R var/*
## Useful commands
# To check Magento2 Version
php bin/magento --version
# To check indexer status
php bin/magento indexer:status
# To Re-index
php bin/magento indexer:reindex
# To show indexer modes
php bin/magento indexer:show-mode
# To set indexer modes (From update on save to update by schedule)
php bin/magento indexer:set-mode schedule INDEXER_NAME
# Ex: php bin/magento indexer:set-mode schedule catalog_product_category
# To set indexer modes (From update by scedule to update on save)
php bin/magento indexer:set-mode realtime INDEXER_NAME
# Ex: php bin/magento indexer:set-mode realtime catalog_product_category
# To run the cron
php bin/magento cron:run
# To enable cache
php bin/magento cache:enable
# To disable cache
php bin/magento cache:disable
# To check Cache status
php bin/magento cache:status
# For Flushing Cache
php bin/magento cache:flush
# For Cleaning Cache
php bin/magento cache:clean
# For Compilation
php bin/magento setup:di:compile
# For Compilation(If you have multi-tenant)
php bin/magento setup:di:compile-multi-tenant
# For Upgrading: When we make any changes/install/set up in magento module you have to execute this command. Once this command execution completes, this will ask to run the compilation command.
php bin/magento setup:upgrade
# To check Magento Mode: production/default OR developer
php bin/magento deploy:mode:show
php bin/magento deploy:mode:set developer
php bin/magento deploy:mode:set production
# To check Magento Module Status
php bin/magento module:status
# To deploy static view files
php bin/magento setup:static-content:deploy
# Magento 2 did not sign in correctly or your account is temporarily disabled
php bin/magento admin:user:unlock ADMINUSERNAME
## DB
dev/css/merge_css_files = 1 dev/css/minify_files = 1 dev/js/enable_js_bundling = 1 dev/js/merge_files = 1 dev/js/minify_files = 1
## DB backup
php bin/magento setup:backup --db
# Re: after upgrade tp 2.3 i now get Backup functionality is currently disabled
# Stores / Configuration / Advanced / System / Backup Settings
# Change Enable Backup to Yes
# Deploy Sample Data from Composer Repository
php bin/magento sampledata:deploy
# This command enables you to update sample data before you update the Magento application.
# To prepare sample data for updating, enter the following command:
php bin/magento sampledata:reset
# to completely remove sample data
php bin/magento sampledata:remove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment