Introduction
Are you a Magento 2 developer and you usually work with the command line interface? In this article, I share with you some of the Magento 2 command lines for your project. You can use it as a command line checklist to save time during your development process.
Command line to create and unblock an administrator account
In some cases, it is not possible to use the Magento dashboard to create an administrator. For example, if you don’t have the dashboard administrator, you can go to your account to create another user. If this happens you can try with the command line interface.
To create an administrator account
In order to create an Admin account, you can use the following php code:
php bin/magento admin:user:create
To unblock an admin account
To unblock an administrator account, use this code:
php bin/magento admin:user:unlock
Command line for creating, capturing or downloading the application
The php code for the Magento 2 command lines to create, capture or dump the application is as follows:
php bin/magento app:config:dump
Magento cache management
Whenever you make essential changes to your website, you should flush or flush the caches for those changes to take effect immediately. Using the command lines below, you can clean, list, disable or enable caches.
To clean up Magento caches
Here is an example of code you can use to clean up Magento caches:
php bin/magento cache:clean
To disable caches
In order to disable caches, you can use the following code:
php bin/magento cache:disable
To authorize Magento caches
The code to activate Magento caches is:
php bin/magento cache:enable
To empty Magento caches
Here is an example of code to empty Magento caches:
php bin/magento cache:flush
To check the status of Magento Caches.
If you want to check the status of Magento caches, you can use the following code:
php bin/magento cache:status
Manage the Magento catalog
To create resized product images, use the code:
php bin/magento catalog:images:resize
To remove attributes from unused products:
php bin/magento catalog:product:attributes:cleanup
Manage your Magento Cron projects
To run jobs on schedule, use:
php bin/magento cron:run
Upgrade client content according to the latest algorithm
For this you can use the following code:
php bin/magento customer:hash:upgrade
Deploy command lines
The code to define the application mode is:
php bin/magento deploy:mode:set
To view the current application mode use:
php bin/magento deploy:mode:show
Dev command lines
Dev Magento 2 command lines are used to collect and publish the theme source files. The following code can be used:
php bin/magento dev:source-theme:deploy
In order to perform tests use:
php bin/magento dev:tests:run
Generate URN catalog in * .xsd mappings for the IDE to highlight XML using code:
php bin/magento dev:urn-catalog:generate
Convert the XML file using XSL stylesheets with code:
php bin/magento dev:xml:convert
I18n command line
Discover phrases in the code database using the following:
php bin/magento i18n:collect-phrases
Saving the language pack with the code:
php bin/magento i18n:pack
Uninstall the language packs with:
php bin/magento i18n:uninstall
Indexer command lines
Display the allowed indexers with the following code:
php bin/magento indexer:info
Reindex the data with:
php bin/magento indexer:reindex
Reset the indexer status to invalid using:
php bin/magento indexer:reset
Define the type of indexing mode with the code:
php bin/magento indexer:set-mode
Display index mode using the following:
php bin/magento indexer:show-mode
Indicate the status of the indexer with:
php bin/magento indexer:status
Get more information with the command line
Display the Magento Admin URI using the code:
php bin/magento info:adminuri
Print the list of available backup files with:
php bin/magento info:backups:list
Display the list of available currencies using:
php bin/magento info:currency:list
The code allows you to indicate the number of dependencies on the Magento framework:
php bin/magento info:dependencies:show-framework
Indicate the number of dependencies between modules using the following:
php bin/magento info:dependencies:show-modules
To allow you to show how many circular dependencies between modules you can use:
php bin/magento info:dependencies:show-modules-circular
Display the list of available local languages with:
php bin/magento info:language:list
Display the list of available time zones using the following code:
php bin/magento info:timezone:list
Manage maintenance mode with the command line
Set the maintenance mode to exempt IPs using the code:
php bin/magento maintenance:allow-ips
Deactivate maintenance mode with:
php bin/magento maintenance:disable
Activate the use of maintenance mode:
php bin/magento maintenance:enable
View the maintenance mode status following this code:
php bin/magento maintenance:status
Manage modules with the command line
Disable the specified modules with the code:
module php bin/magento:disable
Authorize the use of specific modules:
module php bin/magento:enable
Display the status of the modules with:
php bin/magento module:status
Uninstall modules installed by composer using the following:
php bin/magento module:uninstall
Get and Manage Data Samples with the Command Line
Deploy the master data module by using the following code:
php bin/magento sampledata:deploy
Remove all sample data packets from composer.json with the code:
php bin/magento sampledata:remove
Reset all data type modules to reinstall them using:
php bin/magento sampledata:reset
Configuration management with command line of Magento 2
Support backup of Magento application code base, media and database using the following code:
php bin/magento setup:backup
Create or modify the deployment configuration using:
php bin/magento setup:config:set
Run the cron program provided for the setup application with:
php bin/magento setup:cron:run
Install and update the data in the database with the following code:
php bin/magento setup:db-data:upgrade
Install and update the DB schema using:
php bin/magento setup:db-schema:upgrade
Check if the DB schema or data needs to be updated with the following code:
php bin/magento setup:db:status
Generate the ID config and any missing classes which can be auto-generated using the code:
php bin/magento setup:di:compile
Install the Magento app with:
php bin/magento setup:install
Generate mounts using the following code:
php bin / magento setup: performance: generate-fixtures
Go back to the Magento application codebase, media and database with:
php bin/magento setup:rollback
Deploy static view files using the code:
php bin/magento setup:static-content:deploy
Install the store configuration with the code:
php bin/magento setup:store-config:set
Uninstall the Magento app with this code:
php bin/magento setup:uninstall
Update the Magento app, database data and schema using the following code:
php bin/magento setup:upgrade
Conclusion on Magento 2 Command Line Checklist
Please note that the above Magento 2 command line checklist is for the default Magento 2 website. For example, as you install modules or features, you may have more controls for your project. If you want to get the full list of commands available on your site, just type in the code:
php bin/magento list
Thanks for reading, if you like this article you might also like “Here are four different approaches to reset a Magento 2 Admin password”.
If you need help with your Magento project, you can Contact us .
Leave a comment