Here’s a list of Magento 2 Commands that can be useful to anyone who is creating, maintaining, developing, or migrating a Magento store. Magento developers use Magento commands all the time when configuring Magento stores. You can install Magento 2 using CLI.
To use these commands, you have to get SSH access to your server. You can use the CLI for local access.
How To Use Magento Command-Line Interface (CLI)?
Follow these steps to configure and run Magento CLI:
- Login to your account with SSH
- Change the directory to Magento folder from the Command Prompt
- Make the CLI executable with this command:
chmod 744 bin/magento
- To find the available command option, type this command:
bin/magento
How To Use Magento Command-Line Interface (CLI) in Breeze?
Here are a few simple steps to use the CLI from the Breeze dashboard:
- Login to your Breeze Platform
- Select the Company you would like to work on
- Click on the ‘Sites’ to open the site list.
- Open the ‘Store’ whose Backup you like to download.
- Click the ‘Tool’’ option from the list.
- Scroll down to find ‘Web IDE and Terminal’ option
- Open the Web IDE and Terminal an use the username-password to login
- Open the terminal to run the command
Now let’s see some common commands.
Common Magento 2 CLI Commands for Magento Developers:
Admin Commands
Create Admin Account:
php bin/magento admin:user:create
Unlock Admin User Using Command Line:
php bin/magento admin:user:unlock adminusername
Upgrades Commands
Setup upgrades using the CLI:
php bin/magento setup:upgrade
Setup upgrades without removing pub/static files using the CLI:
php bin/magento setup:upgrade --keep-generated
Uninstalling the Magento application using the CLI:
php bin/magento setup:uninstall
Maintenance Mode Commands
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
Mode Commands
Set developer mode using the CLI:
php bin/magento deploy:mode:set developer
Set production mode using the CLI:
php bin/magento deploy:mode:set production
Check current mode using the CLI:
php bin/magento deploy:mode:show
Cache Commands
Clean Cache type:
Php bin/magento cache:clean
Enables Cache type:
Php bin/magento cache:enable
Flushes cache storage used by cache type(s):
php bin/magento cache:flushv
Checks cache status:
php bin/magento cache:status
Resize product images:
php bin/magento catalog:images:resize
Upgrade customer’s hash according to the latest algorithm:
php bin/magento customer:hash:upgrade
Deploy Commands
Static content deploy using the CLI: (Use -f for force deploy on 2.2.x or later):
php bin/magento setup:static-content:deploy or php bin/magento -f setup:static-content:deploy
Deploy for specific language using the CLI:
php bin/magento setup:static-content:deploy en_US
Deploy for Magento backend theme using the CLI:
php bin/magento setup:static-content:deploy --theme="Magento/backend"
Static content deploy for specific themes using the CLI:
php bin/magento setup:static-content:deploy --theme Magento/luma --theme Magento/theme_number_two
Exclude themes on static content deploy and does not minify HTML files using the CLI:
php bin/magento setup:static-content:deploy en_US --exclude-theme Magento/luma --no-html-minify
Cron Commands
Generates and installs crontab for current user:
php bin/magento cron:install
Removes tasks from crontab:
php bin/magento cron:remove
Runs jobs by schedule:
php bin/magento cron:run
Indexer Commands
Shows allowed Indexers:
php bin/magento indexer:info
Reindexes Data:
php bin/magento indexer:reindex
Resets indexer status to invalid:
php bin/magento indexer:reset
Sets index mode type:
php bin/magento indexer:set-mode
Shows Index Mode:
php bin/magento indexer:show-mode
Shows status of Indexer:
php bin/magento indexer:status
Info Commands
Displays the Magento Admin URI:
php bin/magento info:adminuri
Prints list of available backup files:
php bin/magento Info:backups:list
Displays the list of available currencies:
php bin/magento info:currency:list
Shows number of dependencies on Magento framework:
php bin/magento Info:dependencies:show-framework
Shows number of dependencies between modules:
php bin/magento info:dependencies:show-modules
Prints list of available backup files:
php bin/magento info:backups:list
Store Commands
Displays the list of stores:
php bin/magento store:list
Displays the list of websites:
php bin/magento store:website:list
Uninstalls theme:
php bin/magento Theme:uninstall
Generates Varnish VCL and echos it to the command line:
php bin/magento varnish:vcl:generate
List Commands
Print list of available backup files using the CLI:
php bin/magento info:backups:list
List of available currencies using the CLI:
php bin/magento info:currency:list
List of available language locales using the CLI:
php bin/magento info:language:list
Display the list of available timezones using the CLI:
php bin/magento info:timezone:list
Display the list of stores using the CLI:
php bin/magento store:list
Display the list of websites using the CLI:
php bin/magento store:website:list
Wrap Up
If you are Magento developers and use CLI often, you will find these commands helpful.
Magento is a powerful CMS for ecommerce websites, and CLI makes it easier to manage and run. However, platforms like Breeze can manage a lot of things:
- Clearing the cache
- Deploying static content
- Managing Elasticsearch
- Deploying stage
Take the Breeze Demo to see how it saves hours of time everyday.
If there are more important commands that I missed, mention them in the comment