Skip to content

Instantly share code, notes, and snippets.

@ppcdias
Last active February 3, 2023 07:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppcdias/e0d7250250033396e60ca333b17af4cf to your computer and use it in GitHub Desktop.
Save ppcdias/e0d7250250033396e60ca333b17af4cf to your computer and use it in GitHub Desktop.
Magento 2 Useful CLI/SSH Commands List
# setup update and deploy if developer mode is enabled
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush
# set production mode and deploy
php bin/magento deploy:mode:set production
php bin/magento cache:clean
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
# cache commands
php bin/magento cache:flush
php bin/magento cache:clean
php bin/magento cache:enable
php bin/magento cache:disable
# reindex
php bin/magento indexer:reindex
# useful modules commands
php bin/magento module:status
php bin/magento module:enable Module_Name
php bin/magento module:disable Module_Name
# deploy mode commands
php bin/magento deploy:mode:show
php bin/magento deploy:mode:set developer
php bin/magento deploy:mode:set production
# enable/disable debug logging (flush the cache after)
bin/magento setup:config:set --enable-debug-logging=true
bin/magento setup:config:set --enable-debug-logging=false
# remove autogenerated files
rm -rf pub/static/*
rm -rf generated/*
rm -rf var/view_preprocessed/*
rm -rf var/di/*
rm -rf var/generation/*
rm -rf var/cache/*
rm -rf var/log/*
rm -rf var/page_cache/*
rm -rf var/session/*
# useful maintenance commands
php bin/magento maintenance:status
php bin/magento maintenance:enable
php bin/magento maintenance:enable --ip=192.0.3.26 --ip=192.0.4.27
php bin/magento maintenance:disable
php bin/magento maintenance:disable --ip=none
# check Magento version
php bin/magento --version
# cron commands
php bin/magento cron:run
php bin/magento cron:install
php bin/magento cron:disable
# database backup
php bin/magento setup:backup --db
# after upgrade to 2.3 backup functionality is currently disabled
# Stores / Configuration / Advanced / System / Backup Settings
# change Enable Backup to Yes
# reset directories and files permissions
find . -type f -exec chmod 644 {} +;
find . -type d -exec chmod 755 {} +;
find app/etc generated pub/static var -type d -exec chmod 755 {} +;
find app/etc generated pub/static var -type f -exec chmod 664 {} +;
chmod u+x bin/magento
# developer mode
chmod 777 -R var/* generated/* pub/static/*
# create new admin user
php bin/magento admin:user:create \
--admin-user="admin" \
--admin-password="admin123" \
--admin-email="admin@example.com" \
--admin-firstname="Admin" \
--admin-lastname="Admin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment