🔥 Just Launched! Werra Premium Template for HyväSee it in Action

List of Useful Magento 2 SSH/CLI Commands

By Sanjay JethvaUpdated on Jun 16, 2025 5 min read

If you are working with Magento 2 CMS, you must have experienced the trouble of finding the particular Magento 2 SSH/CLI command to complete your task such as disable the cache, run cron, reset indexer, etc.

Instead of running for that commands, why not bookmark this post for any future requirements as it is the compilation of all useful Magento 2 SSH commands. You need to have SSH access to your server or use the Command Line for local access.

List of Useful Magento 2 SSH Commands

TypeSSH CommandShortcutDescription
Available commandshelphDisplays help for a command
php bin/magento listphp bin/magento lLists commands
adminphp bin/magento admin:user:createphp bin/magento a:u:cCreates an administrator
php bin/magento admin:user:unlockphp bin/magento a:u:uUnlock Admin Account
appphp bin/magento app:config:dumpCreate dump of application
php bin/magento app:config:importImport data from shared configuration files to appropriate data storage
cachephp bin/magento cache:cleanphp bin/magento c:cCleans cache type(s)
php bin/magento cache:disablephp bin/magento c:dDisables cache type(s)
php bin/magento cache:enablephp bin/magento c:eEnables cache type(s)
php bin/magento cache:flushphp bin/magento c:fFlushes cache storage used by cache type(s)
php bin/magento cache:statusphp bin/magento c:sChecks cache status
catalogphp bin/magento catalog:images:resizephp bin/magento c:i:rCreates resized product images
php bin/magento catalog:product:attributes:cleanupphp bin/magento c:p:a:cRemoves unused product attributes.
configphp bin/magento config:sensitive:setSet sensitive configuration values
php bin/magento config:setChange system configuration
php bin/magento config:showShows configuration value for given path. If path is not specified, all saved values will be shown
cronphp bin/magento cron:installGenerates and installs crontab for current user
php bin/magento cron:removeRemoves tasks from crontab
php bin/magento cron:runphp bin/magento c:rRuns jobs by schedule
customerphp bin/magento customer:hash:upgradephp bin/magento c:h:uUpgrade customer’s hash according to the latest algorithm
deployphp bin/magento deploy:mode:setphp bin/magento d:m:setSet application mode.
php bin/magento deploy:mode:showphp bin/magento d:m:shoDisplays current application mode.
devphp bin/magento dev:di:infoProvides information on Dependency Injection configuration for the Command.
php bin/magento dev:query-log:disableDisable DB query logging
php bin/magento dev:query-log:enableEnable DB query logging
php bin/magento dev:source-theme:deployphp bin/magento d:s:dCollects and publishes source files for theme.
php bin/magento dev:template-hints:disableDisable frontend template hints. A cache flush might be required.
php bin/magento dev:template-hints:enableEnable frontend template hints. A cache flush might be required.
php bin/magento dev:tests:runphp bin/magento d:t:rRuns tests
php bin/magento dev:urn-catalog:generatephp bin/magento d:u:gGenerates the catalog of URNs to *.xsd mappings for the IDE to highlight xml.
php bin/magento dev:xml:convertphp bin/magento d:x:cConverts XML file using XSL style sheets
i18nphp bin/magento i18n:collect-phrasesphp bin/magento i1:cDiscovers phrases in the codebase
php bin/magento i18n:packphp bin/magento i:pSaves language package
php bin/magento i18n:uninstallphp bin/magento i:uUninstalls language packages
indexerphp bin/magento indexer:infophp bin/magento i:iShows allowed Indexers
php bin/magento indexer:reindexphp bin/magento i:reiReindexes Data
php bin/magento indexer:resetphp bin/magento i:resResets indexer status to invalid
php bin/magento indexer:set-modephp bin/magento i:setSets index mode type
php bin/magento indexer:show-modephp bin/magento i:shoShows Index Mode
php bin/magento indexer:statusphp bin/magento i:staShows status of Indexer
infophp bin/magento info:adminuriphp bin/magento i:aDisplays the Magento Admin URI
php bin/magento info:backups:listphp bin/magento i:b:lPrints list of available backup files
php bin/magento info:currency:listphp bin/magento i:c:lDisplays the list of available currencies
php bin/magento info:dependencies:show-frameworkphp bin/magento i:d:show-fShows number of dependencies on Magento framework
php bin/magento info:dependencies:show-modulesShows number of dependencies between modules
php bin/magento info:dependencies:show-modules-circularShows number of circular dependencies between modules
php bin/magento info:language:listphp bin/magento i:l:lDisplays the list of available language locales
php bin/magento info:timezone:listphp bin/magento i:t:lDisplays the list of available timezones
maintenancephp bin/magento maintenance:allow-ipsphp bin/magento m:aSets maintenance mode exempt IPs
php bin/magento maintenance:disablephp bin/magento ma:dDisables maintenance mode
php bin/magento maintenance:enablephp bin/magento ma:eEnables maintenance mode
php bin/magento maintenance:statusphp bin/magento ma:sDisplays maintenance mode status
modulephp bin/magento module:disablephp bin/magento mo:dDisables specified modules
php bin/magento module:enablephp bin/magento mo:eEnables specified modules
php bin/magento module:statusphp bin/magento mo:sDisplays status of modules
php bin/magento module:uninstallphp bin/magento m:uUninstalls modules installed by composer
sampledataphp bin/magento sampledata:deployphp bin/magento sa:dDeploy sample data modules
php bin/magento sampledata:removephp bin/magento sa:remRemove all sample data packages from composer.json
php bin/magento sampledata:resetphp bin/magento sa:resReset all sample data modules for re-installation
setupphp bin/magento setup:backupphp bin/magento s:bTakes backup of Magento Application code base, media and database
php bin/magento setup:config:setphp bin/magento s:c:sCreates or modifies the deployment configuration
php bin/magento setup:cron:runphp bin/magento s:c:rRuns cron job scheduled for setup application
php bin/magento setup:db-data:upgradephp bin/magento s:db-d:uInstalls and upgrades data in the DB
php bin/magento setup:db-schema:upgradephp bin/magento s:db-s:uInstalls and upgrades the DB schema
php bin/magento setup:db:statusphp bin/magento s:d:sChecks if DB schema or data requires upgrade
php bin/magento setup:di:compilephp bin/magento s:d:cGenerates DI configuration and all missing classes that can be auto-generated
php bin/magento setup:installphp bin/magento s:iInstalls the Magento application
php bin/magento setup:performance:generate-fixturesphp bin/magento s:p:gGenerates fixtures
php bin/magento setup:rollbackphp bin/magento se:rRolls back Magento Application codebase, media and database
php bin/magento setup:static-content:deployphp bin/magento s:s:dDeploys static view files
php bin/magento setup:store-config:setphp bin/magento s:s:sInstalls the store configuration. Deprecated since 2.2.0. Use config:set instead
php bin/magento setup:uninstallphp bin/magento s:unUninstalls the Magento application
php bin/magento setup:upgradephp bin/magento s:upUpgrades the Magento application, DB data, and schema
storephp bin/magento store:listDisplays the list of stores
php bin/magento store:website:listDisplays the list of websites
themephp bin/magento theme:uninstallphp bin/magento t:uUninstalls theme
varnishphp bin/magento varnish:vcl:ge

For official information, check here.

Examples of Using Magento 2 CLI Commands

Magento 2 SSH/CLI commands help you perform actions right from the command line. Here are some common examples of using CLI commands in Magento 2.

Create/Unlock Admin User

You can use the Magento 2 admin commands to create or unlock the admin users.

  • Command to create an admin: bin/magento admin:user:create or bin/magento a:u:c

You’ll be prompted to enter the admin details, such as username, password, first name, and last name.

  • Command to unlock an admin: bin/magento admin:user:unlock {username} or php bin/magento a:u:u {username}

Increase Admin Session Lifetime 

The admin session lifetime in Magento 2 can be changed from Stores > Config > Admin > Advanced > Security.

You can set the session value in seconds.

Alternatively, this can also be done using the following CLI command:

php bin/magento config:set admin/security/session_lifetime {value in seconds}

Change/Disable Admin Password Expiry

By default, Magento 2 offers a password expiration feature that recommends or forces the admin to change password at regular intervals.

You can also change the password expiration settings using the following Magento 2 CLI commands:

  • Disable password expiration: php bin/magento config:set admin/security/password_lifetime 0
  • Disable forced password change: php bin/magento config:set admin/security/password_is_forced 0

Enable/Disable 2FA in Magento 2 Admin

The two factor authentication in Magento 2 can also be enabled/disabled by switching the module on or off using the CLI commands.

  • To enable 2FA: php bin/magento module:enable Magento_TwoFactorAuth or php bin/magento config:set twofactorauth/general/enable 1
  • To disable 2FA: php bin/magento module:disable Magento_TwoFactorAuth or php bin/magento config:set twofactorauth/general/enable 0

Enable Developer Mode

You can change the deploy mode using the CLI command and switch to developer mode. Here’s how you can do this:

  • Switch to developer mode: php bin/magento deploy:mode:set developer

Enable/Disable Database Query Log

By default, Adobe Commerce logs all the database queries in the /var/debug/db.log file.

You can enable/disable the logging by using the dev:query-log command.

  • To enable database logging: bin/magento dev:query-log:enable
  • To disable database logging: bin/magento dev:query-log:disable

Enable/Disable Template Path & Block Class Hints

Template path class hints help in definition block classes that correspond to other specific areas of the page. You can enable or disable this functionality in Magento 2 by using the dev:template-hints command.

  • To enable template path hints: php bin/magento dev:template-hints:enable
  • To disable template path hints: php bin/magento dev:template-hints:disable

Hopefully, the above compilation makes your task easy each time you require an SSH/CLI command!

I’ll surely update the post if I find any handy Magento 2 CLI command useful to the developer!

Happy Coding

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.