Skip to content

Instantly share code, notes, and snippets.

@jonathonbyrdziak
Last active May 29, 2020 20:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jonathonbyrdziak/2bf5ada5bd4f04c56d7474ceb0fb6b7f to your computer and use it in GitHub Desktop.
Save jonathonbyrdziak/2bf5ada5bd4f04c56d7474ceb0fb6b7f to your computer and use it in GitHub Desktop.
Magento 2 CLI Cheat Sheet

List all available commands

php bin/magento --list

Installing/Upgrading Magento

php bin/magento setup:upgrade
php bin/magento deploy:mode:set production

Migrating Magento

php bin/magento migrate:settings vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.2.4/config.xml
php bin/magento migrate:data vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.2.4/config.xml
php bin/magento migrate:delta vendor/magento/data-migration-tool/etc/ce-to-ce/1.9.2.4/config.xml

php bin/magento admin:user:create --admin-user="admin" --admin-password="1q2w3e4r" --admin-email="admin@example.com" --admin-firstname="Admin" --admin-lastname="ADev"

Common Commands

sudo rm -rf var/generation
sudo rm -rf var/static

php bin/magento cache:flush
php bin/magento cache:clean
php bin/magento indexer:reindex

File Permissions

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.php
chown -R root:www-data .
chmod u+x bin/magento

chmod -R 777 var
chmod -R 777 app/etc
chmod -R 777 pub/media
chmod -R 777 pub/static

Managing Magento

cd pub/static && find . -depth -name .htaccess -prune -o -delete && cd ../.. 
chmod -R 777 pub/static
rm -rf var/cache/ var/composer_home var/generation/ var/page_cache/ var/view_preprocessed/ 
php bin/magento setup:static-content:deploy

Compile

cd pub/static && find . -depth -name .htaccess -prune -o -delete && cd ../.. 
chmod -R 777 pub/static
rm -rf var/cache/ var/composer_home var/generation/ var/page_cache/ var/view_preprocessed/ var/di/
php bin/magento setup:di:compile
#!/bin/bash
ROOT=/var/www/html
cd $ROOT/pub/static && find . -depth -name .htaccess -prune -o -delete
chmod -R 777 $ROOT/pub/static
rm -rf $ROOT/var/cache/ $ROOT/var/composer_home $ROOT/var/generation/ $ROOT/var/page_cache/ $ROOT/var/view_preprocessed/
php $ROOT/bin/magento setup:di:compile
php $ROOT/bin/magento setup:static-content:deploy
cd $ROOT
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.php
chown -R root:www-data .
chmod u+x bin/magento
chmod -R 777 var
chmod -R 777 app/etc
chmod -R 777 pub/media
chmod -R 777 pub/static
@pptyasar
Copy link

php bin/magento dev:template-hints:enable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment