Important SSH/CLI Commands for Magento 2
If you use the Magento 2 CMS, you must have struggled to locate the specific SSH/CLI command you needed to perform a task, such as flushing the cache, restarting the indexer, etc. I’ve created a list of the most important SSH/CLI Magento 2 commands below. You will need SSH access to your server or local command-line access to use these commands.
To view a list of all Magento 2 commands
php bin/magento list
php bin/magento l
To display guidance for the command (-help as a flag works too)
php bin/magento help [command]
To display the active and inactive modules
php bin/magento module:status
php bin/magento mo:s
To enables cache type(s)
php bin/magento cache:enable
php bin/magento c:e
To disables cache type(s)
php bin/magento cache:disable
php bin/magento c:d
To clean cache type(s)
php bin/magento cache:clean
php bin/magento c:c
To Flush cache storage used by cache type(s)
php bin/magento cache:flush
php bin/magento c:f
To set the application mode
php bin/magento deploy:mode:set [mode name]
php bin/magento d:m:set [mode name]
php bin/magento deploy:mode:set developer #To switch to developer mode
php bin/magento deploy:mode:set production #To switch to production mode
To display the current application mode
php bin/magento deploy:mode:show
php bin/magento d:m:sho
To create a new Magento admin user
php bin/magento admin:user:create --admin-user username --admin-password password --admin-email email_address --admin-firstname firstname --admin-lastname lastname
To unlock the Magento admin user
php bin/magento admin:user:unlock
php bin/magento a:u:u
To create and set up a crontab for the current user
php bin/magento cron:install
To remove tasks from crontab
php bin/magento cron:remove
To run cronjobs by schedule
php bin/magento cron:run
php bin/magento c:r
To view the list of indexers
php bin/magento indexer:info
php bin/magento i:i
To view the indexer status
php bin/magento indexer:status
php bin/magento i:sta
To show the mode of all indexers
php bin/magento indexer:show-mode
php bin/magento i:sho
To reset indexer status to invalid
php bin/magento indexer:reset IndexType
php bin/magento i:res IndexType
To reindex the data
php bin/magento indexer:reindex
php bin/magento i:rei
To display the Magento Admin URI
php bin/magento info:adminuri
php bin/magento i:a
To display the status of modules
php bin/magento module:status
php bin/magento mo:s
To enable the module
php bin/magento module:enable Module_name
php bin/magento mo:e Module_name
To disable the module
php bin/magento module:disable Module_name
php bin/magento mo:d Module_name
To uninstall the modules installed by the composer
php bin/magento module:uninstall
php bin/magento m:u
To set maintenance mode exempt IPs
php bin/magento maintenance:allow-ips
php bin/magento m:a
To enable maintenance mode
php bin/magento maintenance:enable
php bin/magento ma:e
To disable maintenance mode
php bin/magento maintenance:disable
php bin/magento ma:d
To display the maintenance mode status
php bin/magento maintenance:status
php bin/magento ma:s
To deploy sample data modules
php bin/magento sampledata:deploy
php bin/magento sa:d
To remove all sample data packages from composer.json
php bin/magento sampledata:remove
php bin/magento sa:rem
To reset all sample data modules for re-installation
php bin/magento sampledata:reset
php bin/magento sa:res
To display the configuration value for the specified path. All saved values will be displayed if the path is not specified.
php bin/magento config:show
To change the system configuration
php bin/magento config:set
To Install the Magento application
php bin/magento setup:install
php bin/magento s:i
To uninstall the Magento application
php bin/magento setup:uninstall
php bin/magento s:un
To upgrade the Magento application, DB data, and schema
php bin/magento setup:upgrade
php bin/magento s:up
To deploy static view files
php bin/magento setup:static-content:deploy -f
php bin/magento s:s:d -f
To create the DI configuration and all necessary classes that can be created automatically
php bin/magento setup:di:compile
php bin/magento s:d:c
I hope you found what you were looking for using these Magento 2 commands. You should bookmark this page for future use as it contains a complete list of all important Magento 2 commands 🙂