{"id":13808,"date":"2026-11-23T12:05:31","date_gmt":"2026-11-23T06:35:31","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=13808"},"modified":"2026-11-23T12:05:31","modified_gmt":"2026-11-23T06:35:31","slug":"magento-2-cli-commands","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/magento-2-cli-commands\/","title":{"rendered":"15 Magento 2 CLI Commands Every Developer Should Know"},"content":{"rendered":"\n<h2 id=\"introduction\" class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Magento 2 CLI commands<\/strong> are the fastest way to manage a Magento store. With one line in the terminal, you can clear the cache, reindex products, deploy a new theme, enable maintenance mode, or create an admin user. Many tasks, like compiling code or switching to production mode, can only be done from the command line.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The Magento command line tool is called <strong>bin\/magento<\/strong>, and it ships with more than a hundred commands. You do not need to learn all of them. In this guide, we cover the 15 Magento 2 commands that developers and store administrators use almost every day, with examples and simple explanations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is <strong>Day 3<\/strong> of our Magento and eCommerce series. In <a href=\"https:\/\/pheonixsolutions.com\/blog\/magento-2-setup-guide\/\">Day 1<\/a>, we installed Magento 2.4.9, and in <a href=\"https:\/\/pheonixsolutions.com\/blog\/magento-2-admin-panel-guide\/\">Day 2<\/a>, we explored the admin panel. Today, we move to the terminal.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Key takeaways:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run all Magento 2 CLI commands from the <strong>Magento root folder<\/strong> as the <strong>file system owner<\/strong>, never as root.<\/li>\n\n\n\n<li>After installing or updating code, run <strong>setup:upgrade<\/strong>, <strong>setup:di:compile<\/strong>, <strong>setup:static-content:deploy<\/strong>, and <strong>cache:flush<\/strong>.<\/li>\n\n\n\n<li>Use <strong>indexer:reindex<\/strong> and <strong>cache:clean<\/strong> to fix most &#8220;my change is not showing&#8221; problems.<\/li>\n\n\n\n<li>Put the store in <strong>maintenance mode<\/strong> before any deployment on a live site.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>On This Page<\/h2><nav><ul><li class=\"\"><a href=\"#introduction\">Introduction<\/a><\/li><li class=\"\"><a href=\"#why-magento-2-cli-commands-matter\">Why Magento 2 CLI Commands Matter<\/a><\/li><li class=\"\"><a href=\"#prerequisites-for-using-magento-2-cli-commands\">Prerequisites for Using Magento 2 CLI Commands<\/a><\/li><li class=\"\"><a href=\"#15-magento-2-cli-commands-with-examples\">15 Magento 2 CLI Commands with Examples<\/a><\/li><li class=\"\"><a href=\"#magento-2-deployment-command-sequence\">Magento 2 Deployment Command Sequence<\/a><\/li><li class=\"\"><a href=\"#common-magento-2-cli-mistakes-to-avoid\">Common Magento 2 CLI Mistakes to Avoid<\/a><\/li><li class=\"\"><a href=\"#conclusion\">Conclusion<\/a><\/li><li class=\"\"><a href=\"#faqs\">FAQs<\/a><\/li><li class=\"\"><a href=\"#related-articles\">Related Articles<\/a><\/li><li class=\"\"><a href=\"#official-documentation\">Official Documentation<\/a><\/li><li class=\"\"><a href=\"#talk-to-magento-experts\">Talk to Magento Experts<\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 id=\"why-magento-2-cli-commands-matter\" class=\"wp-block-heading\">Why Magento 2 CLI Commands Matter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The admin panel is great for store settings, but developers need the command line. Magento 2 CLI commands are faster, can be scripted, and work even when the admin panel is down. They are also the only way to run some tasks, such as code compilation, static content deployment, and database schema upgrades.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Knowing the right Magento command line tools also makes deployments safer. A clear, repeatable set of commands means every release follows the same steps, with fewer mistakes and less downtime.<\/p>\n\n\n\n<h2 id=\"prerequisites-for-using-magento-2-cli-commands\" class=\"wp-block-heading\">Prerequisites for Using Magento 2 CLI Commands<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you start, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>A working Magento 2 store:<\/strong> See our <a href=\"https:\/\/pheonixsolutions.com\/blog\/magento-2-setup-guide\/\">Magento 2 setup guide<\/a> to install one.<\/li>\n\n\n\n<li><strong>SSH access<\/strong> to the server where Magento is installed.<\/li>\n\n\n\n<li><strong>The file system owner account:<\/strong> In our series, this is the <strong>magento<\/strong> user.<\/li>\n\n\n\n<li><strong>Basic Linux knowledge:<\/strong> Moving between folders and running commands.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Switch to the file system owner and go to the Magento root folder before running any command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo su - magento\ncd \/var\/www\/magento2<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Running Magento 2 CLI commands as the root user creates files that the web server cannot write to. This causes permission errors on the storefront. Always use the file system owner.<\/p>\n\n\n\n<h2 id=\"15-magento-2-cli-commands-with-examples\" class=\"wp-block-heading\">15 Magento 2 CLI Commands with Examples<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a quick cheat sheet of the 15 Magento 2 commands covered in this guide.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>No.<\/th><th>Command<\/th><th>What it does<\/th><\/tr><\/thead><tbody><tr><td>1<\/td><td>list \/ help<\/td><td>Shows all commands and their options<\/td><\/tr><tr><td>2<\/td><td>setup:upgrade<\/td><td>Updates the database schema and data after code changes<\/td><\/tr><tr><td>3<\/td><td>setup:di:compile<\/td><td>Compiles dependency injection code<\/td><\/tr><tr><td>4<\/td><td>setup:static-content:deploy<\/td><td>Deploys CSS, JS, and images<\/td><\/tr><tr><td>5<\/td><td>cache:clean \/ cache:flush<\/td><td>Clears the Magento cache<\/td><\/tr><tr><td>6<\/td><td>indexer:reindex<\/td><td>Rebuilds the store indexes<\/td><\/tr><tr><td>7<\/td><td>deploy:mode:set<\/td><td>Switches between developer and production mode<\/td><\/tr><tr><td>8<\/td><td>maintenance:enable<\/td><td>Turns maintenance mode on or off<\/td><\/tr><tr><td>9<\/td><td>module:status<\/td><td>Lists, enables, or disables modules<\/td><\/tr><tr><td>10<\/td><td>cron:install \/ cron:run<\/td><td>Sets up and runs Magento cron jobs<\/td><\/tr><tr><td>11<\/td><td>config:set \/ config:show<\/td><td>Changes or reads store settings<\/td><\/tr><tr><td>12<\/td><td>admin:user:create<\/td><td>Creates or unlocks admin users<\/td><\/tr><tr><td>13<\/td><td>setup:db:status<\/td><td>Checks whether the database needs an upgrade<\/td><\/tr><tr><td>14<\/td><td>catalog:images:resize<\/td><td>Generates product image sizes<\/td><\/tr><tr><td>15<\/td><td>queue:consumers:start<\/td><td>Runs message queue consumers<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-cli-commands-cheat-sheet-1024x576.png\" alt=\"Magento 2 CLI commands cheat sheet listing 15 bin\/magento commands for cache, indexer, deploy mode, maintenance, modules and cron\" class=\"wp-image-13806\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-cli-commands-cheat-sheet-1024x576.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-cli-commands-cheat-sheet-300x169.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-cli-commands-cheat-sheet-768x432.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-cli-commands-cheat-sheet-1536x864.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-cli-commands-cheat-sheet.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">1. List All Commands: bin\/magento list<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Start here when you forget a command name. The list command shows every available command, grouped by namespace.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento list\nbin\/magento list cache\nbin\/magento help indexer:reindex<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use <strong>help<\/strong> with any command to see its arguments and options.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Upgrade the Database: bin\/magento setup:upgrade<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run this command after you install, update, or enable a module or extension. It updates the database schema and data to match your code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento setup:upgrade<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> setup:upgrade clears generated code. On production, add <code>--keep-generated<\/code> only if you have already compiled the code in your deployment process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Compile the Code: bin\/magento setup:di:compile<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This command generates factories, proxies, and interceptors that Magento needs to run. It is required in production mode after any code change.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento setup:di:compile<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Deploy Static Content: bin\/magento setup:static-content:deploy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This command copies and builds CSS, JavaScript, fonts, and images into the pub\/static folder for each theme and language.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento setup:static-content:deploy -f en_US en_IN<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>-f<\/strong> (force) option is needed when the store is in developer or default mode. Add every language your store views use, for example <strong>en_US<\/strong> and <strong>en_IN<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Clean and Flush the Cache: bin\/magento cache<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The cache commands are the ones you will use most often.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento cache:status\nbin\/magento cache:clean\nbin\/magento cache:flush\nbin\/magento cache:clean config full_page<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>cache:clean<\/strong> deletes items from enabled Magento cache types only. Try this first.<\/li>\n\n\n\n<li><strong>cache:flush<\/strong> purges the whole cache storage, which can affect other apps that share the same storage, such as Valkey.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">6. Reindex Data: bin\/magento indexer<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Indexers turn your product, category, price, and stock data into fast lookup tables. If prices or products do not show correctly on the storefront, reindex.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento indexer:status\nbin\/magento indexer:reindex\nbin\/magento indexer:reindex catalogsearch_fulltext\nbin\/magento indexer:set-mode schedule<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> For live stores, use <strong>schedule<\/strong> mode (Update by Schedule) so cron updates indexes in the background instead of slowing down every save in the admin.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7. Switch Deploy Modes: bin\/magento deploy:mode<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Magento has developer, default, and production modes. Use developer mode while building, and production mode for live stores.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento deploy:mode:show\nbin\/magento deploy:mode:set developer\nbin\/magento deploy:mode:set production<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Switching to production mode automatically compiles the code and deploys static content.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">8. Enable Maintenance Mode: bin\/magento maintenance<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Maintenance mode shows a &#8220;Service Unavailable&#8221; page to visitors while you work on the store. You can allow your own IP address so you can still test the site.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento maintenance:enable --ip=203.0.113.10\nbin\/magento maintenance:status\nbin\/magento maintenance:disable<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Want a branded maintenance page? Read our guide on <a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-enable-maintenance-mode-in-magento-2\/\">how to enable maintenance mode in Magento and customize the maintenance page<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">9. Manage Modules: bin\/magento module<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use these commands to check, enable, or disable modules and extensions.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento module:status\nbin\/magento module:disable Vendor_Module\nbin\/magento module:enable Vendor_Module\nbin\/magento setup:upgrade<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <strong>Vendor_Module<\/strong> with the real module name, such as Magento_Newsletter. Always run setup:upgrade after you enable or disable a module.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">10. Set Up Cron Jobs: bin\/magento cron<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Cron runs indexers, sends emails, and processes scheduled tasks. Install it once, then check that it is running.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento cron:install\ncrontab -l\nbin\/magento cron:run<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">11. Change Settings: bin\/magento config:set and config:show<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can read and change most store settings without opening the admin panel. This is very useful in deployment scripts.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento config:show web\/unsecure\/base_url\nbin\/magento config:set web\/secure\/use_in_frontend 1\nbin\/magento config:set web\/secure\/use_in_adminhtml 1<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> After you change base URLs or secure settings, run <code>bin\/magento cache:clean config<\/code> so Magento loads the new values.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">12. Manage Admin Users: bin\/magento admin:user<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new admin account or unlock one that was locked after too many failed logins.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento admin:user:create --admin-user=devuser --admin-password='Dev@Pass2026' --admin-email=dev@example.com --admin-firstname=Dev --admin-lastname=User\nbin\/magento admin:user:unlock devuser\nbin\/magento info:adminuri<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For password resets, see our guide on how to <a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-reset-the-admin-password-in-magento2-using-the-command-line-interface-tool\/\">reset the Magento 2 admin password using the CLI<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">13. Check the Database Status: bin\/magento setup:db:status<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This command tells you whether your database is up to date with your code. It is a quick check before and after deployments.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento setup:db:status<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">All modules are up to date.<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If it reports that modules need an upgrade, run bin\/magento setup:upgrade.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">14. Resize Product Images: bin\/magento catalog:images:resize<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This command creates all product image sizes defined in your theme. Run it after you import many products or change a theme, so the storefront does not resize images on the first visit.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento catalog:images:resize<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">15. Run Message Queue Consumers: bin\/magento queue:consumers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Magento uses message queues for tasks such as bulk actions, exports, and inventory updates. You can list and start consumers from the command line.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento queue:consumers:list\nbin\/magento queue:consumers:start exportProcessor<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">By default, cron starts the consumers for you. Start them manually only when you need to debug a stuck task.<\/p>\n\n\n\n<h2 id=\"magento-2-deployment-command-sequence\" class=\"wp-block-heading\">Magento 2 Deployment Command Sequence<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When you deploy new code or extensions to a live store, run the Magento 2 CLI commands in this order:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">bin\/magento maintenance:enable\ncomposer install --no-dev\nbin\/magento setup:upgrade\nbin\/magento setup:di:compile\nbin\/magento setup:static-content:deploy -f en_US en_IN\nbin\/magento cache:flush\nbin\/magento maintenance:disable<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-deployment-command-sequence-1024x576.png\" alt=\"Magento 2 commands deployment sequence from maintenance:enable, setup:upgrade, setup:di:compile and static content deploy to cache:flush\" class=\"wp-image-13807\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-deployment-command-sequence-1024x576.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-deployment-command-sequence-300x169.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-deployment-command-sequence-768x432.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-deployment-command-sequence-1536x864.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-deployment-command-sequence.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Always take a database and file backup before you deploy to a live store, and test the same commands on a staging server first.<\/p>\n\n\n\n<h2 id=\"common-magento-2-cli-mistakes-to-avoid\" class=\"wp-block-heading\">Common Magento 2 CLI Mistakes to Avoid<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Running commands as root:<\/strong> This causes permission errors. Use the file system owner.<\/li>\n\n\n\n<li><strong>Skipping setup:upgrade after installing a module:<\/strong> The storefront may show errors because the database is out of date.<\/li>\n\n\n\n<li><strong>Forgetting -f in developer mode:<\/strong> Static content deploy will not run without it.<\/li>\n\n\n\n<li><strong>Using cache:flush on shared storage without care:<\/strong> It can clear data that other applications use.<\/li>\n\n\n\n<li><strong>Deploying without maintenance mode:<\/strong> Customers may see broken pages during the deployment.<\/li>\n<\/ul>\n\n\n\n<h2 id=\"conclusion\" class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 CLI commands give you full control of your store from the terminal. Once you learn these 15 commands, daily tasks like clearing the cache, reindexing, and deploying updates become quick and predictable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Quick recap:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use <strong>list<\/strong> and <strong>help<\/strong> to discover any Magento command.<\/li>\n\n\n\n<li>After code changes, run <strong>setup:upgrade<\/strong>, <strong>setup:di:compile<\/strong>, <strong>static content deploy<\/strong>, and <strong>cache:flush<\/strong>.<\/li>\n\n\n\n<li>Fix display issues with <strong>cache:clean<\/strong> and <strong>indexer:reindex<\/strong>.<\/li>\n\n\n\n<li>Use <strong>maintenance mode<\/strong> and a <strong>fixed deployment order<\/strong> for live stores.<\/li>\n\n\n\n<li>Always run commands as the <strong>file system owner<\/strong>.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Bookmark this list of Magento 2 CLI commands for your team. In the next article of this series, we will set up the store configuration: websites, stores, and store views.<\/p>\n\n\n\n<h2 id=\"faqs\" class=\"wp-block-heading\">FAQs<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Where do I run Magento 2 CLI commands?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run them from the Magento root folder (for example, \/var\/www\/magento2) using bin\/magento, logged in as the file system owner.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. What is the difference between cache:clean and cache:flush?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">cache:clean deletes items only from enabled Magento cache types. cache:flush purges the whole cache storage, which can also remove data used by other applications that share it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Which command should I run after installing an extension?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run setup:upgrade, then setup:di:compile and setup:static-content:deploy in production mode, and finally cache:flush.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. How do I fix &#8220;One or more indexers are invalid&#8221; in Magento 2?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run bin\/magento indexer:reindex, and make sure cron is installed so indexes stay up to date in schedule mode.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. How do I see all available Magento 2 commands?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run bin\/magento list. To see the options for one command, run bin\/magento help followed by the command name.<\/p>\n\n\n\n<h2 id=\"related-articles\" class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/magento-2-setup-guide\/\">Magento 2 Setup Guide: Install Magento 2.4.9 on Ubuntu in 9 Steps<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/magento-2-admin-panel-guide\/\">Magento 2 Admin Panel Guide: 10 Key Sections Every Store Owner Should Know<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-enable-maintenance-mode-in-magento-2\/\">How to Enable Maintenance Mode in Magento and Customize the Maintenance Page<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-reset-the-admin-password-in-magento2-using-the-command-line-interface-tool\/\">How to Reset the Admin Password in Magento 2 Using the Command Line Interface Tool<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-resolve-the-autoload-error-while-installing-magento2-in-ubuntu-18-04-20-04\/\">How to Resolve the Autoload Error While Installing Magento 2 in Ubuntu<\/a><\/li>\n<\/ul>\n\n\n\n<h2 id=\"official-documentation\" class=\"wp-block-heading\">Official Documentation<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-operations\/configuration-guide\/cli\/config-cli\" target=\"_blank\" rel=\"noopener\">Command-Line Tool Overview<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-operations\/configuration-guide\/cli\/manage-cache\" target=\"_blank\" rel=\"noopener\">Manage the Cache<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-operations\/configuration-guide\/cli\/manage-indexers\" target=\"_blank\" rel=\"noopener\">Manage the Indexers<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-operations\/configuration-guide\/cli\/set-mode\" target=\"_blank\" rel=\"noopener\">Set the Application Mode<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-operations\/configuration-guide\/cli\/code-compiler\" target=\"_blank\" rel=\"noopener\">Code Compiler<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-operations\/installation-guide\/tutorials\/maintenance-mode\" target=\"_blank\" rel=\"noopener\">Enable or Disable Maintenance Mode<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-operations\/configuration-guide\/cli\/configure-cron-jobs\" target=\"_blank\" rel=\"noopener\">Configure and Run Cron<\/a><\/li>\n<\/ul>\n\n\n\n<h2 id=\"talk-to-magento-experts\" class=\"wp-block-heading\">Talk to Magento Experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Running Magento deployments by hand on a live store can be risky. At <strong><a href=\"https:\/\/pheonixsolutions.com\/ecommerce\/\">Pheonix Solutions<\/a><\/strong>, our developers build, deploy, and maintain Magento stores with safe, automated release processes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can help you with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pheonixsolutions.com\/ecommerce\/\">eCommerce development<\/a> on Magento 2, including custom modules and extensions.<\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/devops-cloud\/\">DevOps and cloud services<\/a> to automate Magento deployments with CI\/CD pipelines.<\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/software-maintenance-and-support\/\">Software maintenance and support<\/a> for upgrades, reindexing issues, and performance fixes.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Need a reliable deployment process for your Magento store? <a href=\"https:\/\/pheonixsolutions.com\/contact\/\">Talk to our Magento experts<\/a> and ship updates without downtime.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn 15 Magento 2 CLI commands every developer should know, from setup:upgrade and cache:flush to reindex, deploy modes, maintenance mode, and cron jobs.<\/p>\n","protected":false},"author":507,"featured_media":13805,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1092,1022],"tags":[],"class_list":["post-13808","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento-ecommerce","category-web-architecture","psol-cat-magento-ecommerce"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-3AI","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2026\/11\/magento-2-cli-commands.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/13808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/507"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=13808"}],"version-history":[{"count":3,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/13808\/revisions"}],"predecessor-version":[{"id":13811,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/13808\/revisions\/13811"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/13805"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=13808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=13808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=13808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}