2

I am looking for a quick, easy reference for the most popular CLI commands and how they are used in Magento 2.

10 Answers 10

7

enter magento root via CLI

compile & deploy when adding/changing modules, adjust language(s) as needed

php bin/magento module:enable Vendor_Module Vendor_Module2
php bin/magento setup:upgrade
php -d memory_limit=1024M bin/magento setup:di:compile
rm -rf var/di var/generation/* var/view_preprocessed pub/static/*
php bin/magento setup:static-content:deploy en_US en_CA xx_XX

clear out cache, pub, var & reindex, as needed

php bin/magento cache:flush
php bin/magento cache:clean
rm -rf var/di var/generation/* var/view_preprocessed pub/static/*
php bin/magento indexer:reindex

adjust deploy mode

php bin/magento deploy:mode:show
php bin/magento deploy:mode:set developer

deploy sample data

php bin/magento sampledata:deploy

set permissions after deploy

find ~/magentoroot/pub -type f -exec chmod 644 -R {} \;
find ~/magentoroot/pub -type d -exec chmod 755 -R {} \;

upgrade via composer

composer require magento/product-community-edition 2.1.0 --no-update
composer update
| improve this answer | |
6

This is a list of magento 2 commands:

Magento CLI version 2.0.4

Usage:
 command [options] [arguments]

Options:
 --help (-h)           Display this help message
 --quiet (-q)          Do not output any message
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version
 --ansi                Force ANSI output
 --no-ansi             Disable ANSI output
 --no-interaction (-n) Do not ask any interactive question

Available commands:
 help                                      Displays help for a command
 list                                      Lists commands
admin
 admin:user:create                         Creates an administrator
 admin:user:unlock                         Unlock Admin Account
cache
 cache:clean                               Cleans cache type(s)
 cache:disable                             Disables cache type(s)
 cache:enable                              Enables cache type(s)
 cache:flush                               Flushes cache storage used by cache type(s)
 cache:status                              Checks cache status
catalog
 catalog:images:resize                     Creates resized product images
cron
 cron:run                                  Runs jobs by schedule
customer
 customer:hash:upgrade                     Upgrade customer's hash according to the latest algorithm
deploy
 deploy:mode:set                           Set application mode.
 deploy:mode:show                          Displays current application mode.
dev
 dev:source-theme:deploy                   Collects and publishes source files for theme.
 dev:tests:run                             Runs tests
 dev:urn-catalog:generate                  Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml.
 dev:xml:convert                           Converts XML file using XSL style sheets
i18n
 i18n:collect-phrases                      Discovers phrases in the codebase
 i18n:pack                                 Saves language package
 i18n:uninstall                            Uninstalls language packages
indexer
 indexer:info                              Shows allowed Indexers
 indexer:reindex                           Reindexes Data
 indexer:set-mode                          Sets index mode type
 indexer:show-mode                         Shows Index Mode
 indexer:status                            Shows status of Indexer
info
 info:adminuri                             Displays the Magento Admin URI
 info:backups:list                         Prints list of available backup files
 info:currency:list                        Displays the list of available currencies
 info:dependencies:show-framework          Shows number of dependencies on Magento framework
 info:dependencies:show-modules            Shows number of dependencies between modules
 info:dependencies:show-modules-circular   Shows number of circular dependencies between modules
 info:language:list                        Displays the list of available language locales
 info:timezone:list                        Displays the list of available timezones
maintenance
 maintenance:allow-ips                     Sets maintenance mode exempt IPs
 maintenance:disable                       Disables maintenance mode
 maintenance:enable                        Enables maintenance mode
 maintenance:status                        Displays maintenance mode status
module
 module:disable                            Disables specified modules
 module:enable                             Enables specified modules
 module:status                             Displays status of modules
 module:uninstall                          Uninstalls modules installed by composer
sampledata
 sampledata:deploy                         Deploy sample data modules
 sampledata:remove                         Remove all sample data packages from composer.json
 sampledata:reset                          Reset all sample data modules for re-installation
setup
 setup:backup                              Takes backup of Magento Application code base, media and database
 setup:config:set                          Creates or modifies the deployment configuration
 setup:cron:run                            Runs cron job scheduled for setup application
 setup:db-data:upgrade                     Installs and upgrades data in the DB
 setup:db-schema:upgrade                   Installs and upgrades the DB schema
 setup:db:status                           Checks if DB schema or data requires upgrade
 setup:di:compile                          Generates DI configuration and all non-existing interceptors and factories
 setup:di:compile-multi-tenant             Generates all non-existing proxies and factories, and pre-compile class definitions, inheritance information and plugin definitions
 setup:install                             Installs the Magento application
 setup:performance:generate-fixtures       Generates fixtures
 setup:rollback                            Rolls back Magento Application codebase, media and database
 setup:static-content:deploy               Deploys static view files
 setup:store-config:set                    Installs the store configuration
 setup:uninstall                           Uninstalls the Magento application
 setup:upgrade                             Upgrades the Magento application, DB data, and schema
theme
 theme:uninstall                           Uninstalls theme
| improve this answer | |
4

I just found this blog: magento 2 useful commands list, but being a beginner I just rely on the official guide, as it explains when each command is needed, and the magento command list (above) can be shown in CLI using :

$ bin/magento list
| improve this answer | |
1

In future(Magento 2.2) release there are couple of new commands for Magento2, like

system config value(Very useful),

php bin/magento config:show : Shows configuration value for given path. If path is not specified, all saved values will be shown

php bin/magento config:set : Change system configuration

php bin/magento config:sensitive:set : Set sensitive configuration values

For app

php bin/magento app:config:dump : Create dump of application

php bin/magento app:config:import : Import data from shared configuration files to appropriate data storage

| improve this answer | |
0

Most useful commands

php bin/magento setup:upgrade 
php bin/magento setup:static-content:deploy 
php bin/magento cache:clean
php bin/magento cache:flush

php bin/magento module:status
php bin/magento module:enable Modulename_HelloWorld

php bin/magento setup:static-content:deploy --theme Magento/luma --theme Magento/secothe nd_theme

For more commands follow link.

http://www.emiprotechnologies.com/technical_notes/magento-technical-notes-60/post/magento-2-useful-commands-list-391

| improve this answer | |
0

In this post you can find all usefull commands above. But I was require command script which is helpfull to frontend developer as well as client who can run magento commands without open SSH.

So, I have created one GUI script and added on GIT. Please refer below link.

https://github.com/Darshanmodi1427/Magento2_commands_script

| improve this answer | |
0

Enter Magento Root via CLI, and use following command according to your requirements.

Setup Upgrade Using Command Line

php bin/magento setup:upgrade

If you don’t want to remove pub/static files while installing/updating database then use following command

php bin/magento setup:upgrade --keep-generated

Cache Clean Using Command Line

php bin/magento cache:clean

Cache Flush Using Command Line

php bin/magento cache:flush

View cache status Using Command Line

php bin/magento cache:status

Enable Cache Using Command Line

php bin/magento cache:enable [cache_type]

Disable Cache Using Command Line

php bin/magento cache:disable [cache_type]

Static Content Deploy Using Command Line

php bin/magento setup:static-content:deploy

Static Content Deploy For Particular Language Using Command Line

php bin/magento setup:static-content:deploy en_US

Static Content Deploy For Magento Backend Theme Using Command Line

php bin/magento setup:static-content:deploy --theme="Magento/backend"

Static Content Deploy For Specific Themes Using Command Line

php bin/magento setup:static-content:deploy --theme Magento/luma --theme Magento/second_theme

Exclude Themes on Static Content Deploy and does not minify HTML files Using Command Line

php bin/magento setup:static-content:deploy en_US --exclude-theme Magento/luma --no-html-minify

Reindexing Using Command Line

php bin/magento indexer:reindex

View the list of indexers Using Command Line

php bin/magento indexer:info

View indexer status Using Command Line

php bin/magento indexer:status

Show the mode of all indexers Using Command Line

php bin/magento indexer:show-mode

See all modules Status Using Command Line

php bin/magento module:status

Enable module Using Command Line

php bin/magento module:enable Namespace_Module

Disable module Using Command Line

php bin/magento module:disable Namespace_Module

Uninstall Module Using Command Line

php bin/magento module:uninstall Namespace_Module

Check Current Mode Using Command Line

php bin/magento deploy:mode:show

Change To Developer Mode Using Command Line

php bin/magento deploy:mode:set developer

Change To Production Mode Using Command Line

php bin/magento deploy:mode:set production

Run the single-tenant Compiler Using Command Line

php bin/magento setup:di:compile

Unlock Admin User Using Command Line

php bin/magento admin:user:unlock adminusername

Enable Maintenance Mode Using Command Line

php bin/magento maintenance:enable

To enable maintenance mode for all clients except 192.0.0.1 and 192.0.0.2

php bin/magento maintenance:enable --ip=192.0.0.1 --ip=192.0.0.2

To clear the list of IPs

php bin/magento maintenance:enable --ip=none

Disable Maintenance Mode Using Command Line

php bin/magento maintenance:disable

Check Maintenance Mode Status Using Command Line

php bin/magento maintenance:status

Allow IP on Maintenance Mode Using Command Line

php bin/magento maintenance:allow-ips --ip=192.0.0.1 --ip=192.0.0.2

Set Magento crontab Using Command Line

php bin/magento cron:install --force

To view the crontab, enter the following command as the Magento file system owner

crontab -l

Remove Magento crontab Using Command Line

php bin/magento cron:remove

| improve this answer | |
0

To install new extension-
php bin/magento module:enable Packagename_Modulename --clear-static-content
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
chmod 777 -R var
chmod 777 -R pub

To clear cache -
php bin/magento cache:flush
php bin/magento cache:clean
rm -rf var/cache/*

For reindexing -
php bin/magento indexer:reindex

| improve this answer | |
0

Command Shortcut for Setup Upgrade

php bin/magento s:up

If you don’t want to remove pub/static files while installing/updating database then use the following command.

php bin/magento s:up --keep-generated

Command Shortcut for Cache Clean

php bin/magento c:c

Command Shortcut for Cache Flush

php bin/magento c:f

Command Shortcut for Disable Cache

php bin/magento c:d

Command Shortcut for Enable Cache

php bin/magento c:e

Command Shortcut for Reindexing

php bin/magento i:rei

Command Shortcut for View the list of indexers

php bin/magento i:i

Command Shortcut for View indexer status

php bin/magento i:st

Command Shortcut for View indexer Resets

php bin/magento i:res

Command Shortcut for Show the mode of all indexers

php bin/magento i:sh

Command Shortcut for Static Content Deploy

php bin/magento s:s:d

Command Shortcut for Static Content Deploy For Particular Language

php bin/magento s:s:d en_US

Command Shortcut for Static Content Deploy For Magento Backend theme

php bin/magento s:s:d --theme="Magento/backend"

Command Shortcut for Static Content Deploy For Specific Themes

php bin/magento s:s:d --theme Magento/luma --theme Magento/second_theme

Command Shortcut for Exclude Themes on Static Content Deploy and does not minify HTML

php bin/magento s:s:d en_US --exclude-theme Magento/luma --no-html-minify

Command Shortcut for Di Compile

php bin/magento s:d:c

Command Shortcut for See all modules Status

php bin/magento mo:s

Command Shortcut for Enable module

php bin/magento mo:e Namespace_Module

Command Shortcut for Disable module

php bin/magento mo:d Namespace_Module

Command Shortcut for Uninstall Module

php bin/magento mo:u Namespace_Module

Command Shortcut for Check Current Mode

php bin/magento d:m:sh

Command Shortcut for Change To Developer Mode

php bin/magento d:m:se developer

Command Shortcut for Change To Production Mode

php bin/magento d:m:se production

| improve this answer | |
0

Here is Magento 2 Useful CLI Command list

http://magelara.com/magento-2-useful-commands-list/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.