Press ESC to close

List of Magento 2 SSH Commands Every Developer Should Know

Managerial tasks of the robust e-commerce platform Magento 2 often benefit from running through the Magento 2 Command-Line Interface (CLI). The terminal commands enable users to execute multiple tasks directly via command line interfaces, thus reducing execution time and labor. The guide includes vital and professional-grade Magento 2 CLI commands to optimize administration procedures.

Getting Started with Magento 2 SSH commands

Magento 2 Command List to obtain SSH server access or command line local access before executing CLI commands. You can begin using CLI commands for store management within Magento 2 after getting inside the system.

Essential Magento 2 CLI Commands

  • Cache Management
    • Clear Cache: php bin/magento cache:clean or php bin/magento c:c
    • Disable Cache: php bin/magento cache:disable or php bin/magento c:d
    • Enable Cache: php bin/magento cache:enable or php bin/magento c:e
    • Flush Cache: php bin/magento cache:flush or php bin/magento c:f
    • Check Cache Status: php bin/magento cache:status or php bin/magento c:s
  • Index Management
    • Reindex Data: php bin/magento indexer:reindex or php bin/magento i:rei
    • Reset Indexer: php bin/magento indexer:reset or php bin/magento i:res
    • Show Indexer Status: php bin/magento indexer:status or php bin/magento i:sta
  • Magento 2 Admin User Management
    • Create Admin User: php bin/magento admin:user:create or php bin/magento a:u:c
    • Unlock Admin User: php bin/magento admin:user:unlock {username} or php bin/magento a:u:u {username}
  • Cron Jobs
    • Run Cron Jobs: php bin/magento cron:run or php bin/magento c:r
    • Install Crontab: php bin/magento cron:install
    • Remove Crontab: php bin/magento cron:remove
  • Developer Tools
    • Enable Developer Mode: php bin/magento deploy:mode:set developer
    • Enable Database Query Log: php bin/magento dev:query-log:enable
    • Disable Database Query Log: php bin/magento dev:query-log:disable
    • Enable Template Path Hints: php bin/magento dev:template-hints:enable
    • Disable Template Path Hints: php bin/magento dev:template-hints:disable

Advanced Magento 2 SSH/CLI Commands

  • Message Queue Management
    • Start Consumer: php bin/magento queue:consumers:start {consumer_name}
    • List Consumers: php bin/magento queue:consumers:list
    • Restart Consumer: php bin/magento queue:consumers:restart {consumer_name}
  • Module Management
    • Enable Module: php bin/magento module:enable {Module_Name}
    • Disable Module: php bin/magento module:disable {Module_Name}
    • Check Module Status: php bin/magento module:status
    • Uninstall Module: php bin/magento module:uninstall {Module_Name}
  • Deployment and Setup
    • Deploy Static Content: php bin/magento setup:static-content:deploy
    • Upgrade Magento: php bin/magento setup:upgrade
    • Compile Dependency Injection: php bin/magento setup:di:compile
    • Backup Magento: php bin/magento setup:backup
  • Maintenance Mode
    • Enable Maintenance Mode: php bin/magento maintenance:enable
    • Disable Maintenance Mode: php bin/magento maintenance:disable
    • Set Maintenance Mode IPs: php bin/magento maintenance:allow-ips {IP_Address}
  • Theme Management
    • Uninstall Theme: php bin/magento theme:uninstall {Vendor}/{theme}
    • Deploy Theme: php bin/magento dev:source-theme:deploy {Vendor}/{theme}
  • Database Management
    • Upgrade Database Schema: php bin/magento setup:db-schema:upgrade
    • Upgrade Database Data: php bin/magento setup:db-data:upgrade
    • Check Database Status: php bin/magento setup:db:status

Practical Examples (Common CLI Commands)

Creating an admin user to create a new admin user using Magento 2 Admin commands :

php bin/magento admin:user:create

You’ll be prompted to enter details like username, password, first name, and last name.

Increasing Admin Session Lifetime To increase the admin session lifetime, use:

php bin/magento config:set admin/security/session_lifetime 86400

This sets the session lifetime to 86400 seconds (24 hours).

Disabling Password Expiry To disable password expiration, use:

php bin/magento config:set admin/security/password_lifetime 0

Enabling Two-Factor Authentication (2FA) To enable 2FA, use:

php bin/magento module:enable Magento_TwoFactorAuth

Starting a Message Queue Consumer To start a specific message queue consumer, use:

php bin/magento queue:consumers:start {consumer_name}

Replace {consumer_name} with the actual consumer name, such as async.operations.all.

Deploying Static Content To deploy static content for all locales, use:

php bin/magento setup:static-content:deploy

You can also specify locales:

php bin/magento setup:static-content:deploy en_US fr_FR

Enabling a Module To enable a specific module, use:

php bin/magento module:enable {Module_Name}

For example, to enable the Magento_TwoFactorAuth module:

php bin/magento module:enable Magento_TwoFactorAuth

Enabling Maintenance Mode To put your store in maintenance mode, use:

php bin/magento maintenance:enable

To allow specific IPs to access the store while in maintenance mode:

php bin/magento maintenance:allow-ips 192.168.1.1

Upgrading Magento To upgrade your Magento installation, use:

php bin/magento setup:upgrade

This command will update the database schema and data.

Conclusion

Your management capabilities of the e-commerce store increase significantly when you learn how to use CLI commands in Magento 2. The listed commands enable users to handle cache and manage modules as well as conduct database upgrades to maintain a smooth, optimized Magento 2 store.

Magento 2 CMS empowers businesses to create and manage dynamic content effortlessly, enhancing customer engagement and driving conversions.

You should continue to explore these commands to discover additional ways to boost your Magento 2 interface capabilities. Happy coding!

FAQ

What is the correct way to execute Magento CLI commands?

Navigate to the Magento root directory via SSH, then execute commands using the syntax:

php bin/magento <command>
What is the CLI command in Magento 2?

The Magento 2 CLI command format is:

php bin/magento [command] [options]

jhjbhjbhjbhjjjhbj

Share Post

Leave a Reply

Your email address will not be published. Required fields are marked *