Introduction

Are you a Magento 2 developers usually working with the command-line interface? In this post, I share with you some of the critical Magento command-line for your project. You can use it as a command-line cheat-list to save time during your development process.

Command-line to create and unlock an administrator account

In some cases, using the Magento dashboard to create an administrator is not possible. For instance, if you don't have the dashboard administrator, you can access your account to create another user. If that happens, you can try with the command-line interface.

To create an admin account

In order to create an Admin account you can use the following php code:
php bin/magento admin:user:create

To Unlock an admin account

For you to unlock an admin account, use this code:
php bin/magento admin:user:unlock

Command-line to create, snapshot or dump off the application

The php code for the command-line to create and snapshot or dump off the application is the following:
php bin/magento app:config:dump

Magento Cache management

Whenever you make essential changes on your website, you need to clear or flush caches for those changes to take effect immediately. With the below command lines, to can clean, list, disable or enable caches.To clean Magento cachesAn example of a code you can use to clean Magento caches is:
php bin/magento cache:clean
To disable cachesIn order to disable caches, you can use the following code:
php bin/magento cache:disable
To enable Magento CachesThe code to enable Magento Caches is:
php bin/magento cache:enable
To flush Magento Caches An example of code to flush Magento Caches is:
php bin/magento cache:flush
To check Magento Caches' status. If you want to check Magento Caches' status, you could use the following code:
php bin/magento cache:status

Manage Magento Catalog

To Create resized product images use the code:
php bin/magento catalog:images:resize
To remove unused product attributes:
php bin/magento catalog:product:attributes:cleanup

Manage your Magento Cron Jobs

To run  jobs by schedule, use:
php bin/magento cron:run

Upgrade customer's hash according to the latest algorithm

For this use:
php bin/magento customer:hash:upgrade

Deploy command lines

The code to set application mode is:
php bin/magento deploy:mode:set
To displays the current application mode use:
php bin/magento deploy:mode:show

Dev command lines

The dev  command lines are use to Collect and publish source files for the theme. The following code can be used:
php bin/magento dev:source-theme:deploy
In order to run tests use:
php bin/magento dev:tests:run
Generate the catalogue of URNs to *.xsd mappings for the IDE to highlight XML using the code:
php bin/magento dev:urn-catalog:generate 
Convert XML file using XSL style sheets with the code:
php bin/magento dev:xml:convert

i18n command line

Discover phrases in the codebase using the following:
php bin/magento i18n:collect-phrases
Save language package with the code:
php bin/magento i18n:pack
Uninstall language packages with:
php bin/magento i18n:uninstall

Indexer command lines

Show allowed Indexers with the following:
php bin/magento indexer:info
Reindex Data with:
php bin/magento indexer:reindex
Reset indexer status to invalid by using:
php bin/magento indexer:reset
Set index mode type with the code:
php bin/magento indexer:set-mode
Show Index Mode by using the following:
php bin/magento indexer:show-mode
Show status of Indexer with:
php bin/magento indexer:status

Get more info with command line

Display the Magento Admin URI using the code:
php bin/magento info:adminuri
Print 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
You can show the number of dependencies on Magento framework with the code:
php bin/magento info:dependencies:show-framework
Show number of dependencies between modules with the following:
php bin/magento info:dependencies:show-modules
For you to show number of circular dependencies between modules you can use:
php bin/magento info:dependencies:show-modules-circular
Display the list of available language locales with:
php bin/magento info:language:list
Display the list of available timezones using the following code:
php bin/magento info:timezone:list

Manage maintenance mode with command line

Set maintenance mode exempt IPs using the code:
php bin/magento maintenance:allow-ips
Disable maintenance mode with:
php bin/magento maintenance:disable
Enable maintenance mode using:
php bin/magento maintenance:enable
Display maintenance mode status following this code:
php bin/magento maintenance:status

Manage modules with command line

Disable specified modules with the code:
php bin/magento module:disable
Enable specified modules using:
php bin/magento module:enable
Display status of modules with:
php bin/magento module:status
Uninstall modules installed by composer using the following:
php bin/magento module:uninstall

Get and manage sample data with command line

Deploy sample data module using the following code:
php bin/magento sampledata:deploy
Remove all sample data packages from composer.json with the code:
php bin/magento sampledata:remove
Reset all sample data modules for re-installation using:
php bin/magento sampledata:reset

Setup management with command line

Take backup of Magento Application code base, media and database by using the following code:
php bin/magento setup:backup
Create or modify the deployment configuration using:
php bin/magento setup:config:set
Run cron job scheduled for setup application with:
php bin/magento setup:cron:run
Install and upgrade data in the DB with the following code:
php bin/magento setup:db-data:upgrade
Install and upgrade the DB schema using:
php bin/magento setup:db-schema:upgrade
Check if DB schema or data requires upgrade with the following code:
php bin/magento setup:db:status
Generate DI configuration and all missing classes that can be auto-generated using the code:
php bin/magento setup:di:compile
Install the Magento application with:
php bin/magento setup:install
Generate fixtures using the following code:
php bin/magento setup:performance:generate-fixtures
Roll back 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 application with this code:
php bin/magento setup:uninstall
Upgrade the Magento application, DB data, and schema by using the following code:
php bin/magento setup:upgrade

Conclusion about the Magento 2 Command-line cheat-list

Note that the above Command-line cheat-list is for the default Magento 2 website. For instance, as you install modules or features, you may have more commands for your project. If you want to get the complete list of command-line available on your site, just type the code:
php bin/magento list
Thanks for reading, if you love this article, you may 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.