I compiled this Magento 2 Commands list that is useful to anyone who is creating, maintaining, developing, or migrating a magento store. Developers use magento commands all the time when configuring the Magento store.
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
In this article, I am sharing the useful Magento 2 command.
Admin Commands
Create Admin Account
php bin/magento admin:user:create
Unlock Admin User Using Command Line
php bin/magento admin:user:unlock adminusername
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
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
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
Deploying Apps
Set application mode
php bin/magento deploy:mode:set
Displays current application mode
php bin/magento deploy:mode:show
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
Also Read: How to Reindex Magento 2 from SSH/CLI or Admin Panel?
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
Setup Commands
Takes backup of Magento Application code base, media and database
php bin/magento Setup:backup
Installs the Magento application
php bin/magento Setup:install
Generates fixtures
php bin/magento Setup:performance:generate-fixtures
Rolls back Magento Application codebase, media and database
php bin/magento Setup:rollback
Deploys static view files
php bin/magento Setup:static-content:deploy
Installs the store configuration. Deprecated since 2.2.0. Use config:set instead
php bin/magento Setup:store-config:set
Uninstalls the Magento application
php bin/magento Setup:uninstall
Upgrades the Magento application, DB data, and schema
php bin/magento setup:upgrade
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
Also Read
- How to Install Magento 2.4 with Command Line?
- What are MySQL Triggers and How to create them?
- How to Change Magento 2 Base URL?
- Magento 2 Requirements that You Must Take care of
Wrapping Up
I hope these Magento 2 commands can help you in managing the Magento. This is a list of important and most used SSH/CLI commands for Magento 2.
Magento is surely a powerful CMS for eCommerce. However, it is a complicated program, and developers handle lots of things from the back-end.
If there are more important commands that I missed, mention them in the comment.
1 thought on “Magento 2 Commands: A Useful list for Magento Developers”
Very useful set of commands. Thank you.