Skip to content
Resources

Magento 2 command list: all CLI commands cheat sheet (2.4.8)

If you work with Magento 2 every day, you probably type the same bin/magento commands again and again: flush the cache, reindex, deploy static content, enable maintenance mode… And every now and then you need a command you only use once a year and can’t remember the exact syntax.

In this post, I put together a complete Magento 2 command list: the CLI commands you really use, grouped by area, with the exact syntax and the most useful options. Bookmark this page and use it as your Magento 2 CLI cheat sheet. All commands are valid for Magento Open Source and Adobe Commerce 2.4.7, 2.4.8 and 2.4.9.

Run every command from the Magento root folder (for example /var/www/magento2) as the file system owner, not as root, to avoid permission problems.

magento-2-cli-command-groups

How to list all Magento 2 commands

Magento 2.4.9 ships with more than 140 commands, and extensions add their own. To see every command available on your installation, run:

bin/magento list

To see the full syntax and options of a single command, use help:

bin/magento help setup:static-content:deploy

magento-2-bin-magento-list

Tip: Magento accepts shortened command names as long as they are unique, so bin/magento c:f works the same as bin/magento cache:flush.

Cache commands

bin/magento cache:status                  # show enabled/disabled cache types
bin/magento cache:clean                   # clean all enabled cache types
bin/magento cache:clean config layout     # clean only some types
bin/magento cache:flush                   # flush the whole cache storage
bin/magento cache:enable full_page        # enable a cache type
bin/magento cache:disable full_page       # disable a cache type

cache:clean removes only Magento’s own cache entries, while cache:flush empties the entire storage (for example the whole Redis database). Use clean first; use flush when clean is not enough.

Indexer commands

bin/magento indexer:status                # status of every indexer
bin/magento indexer:info                  # list indexer codes
bin/magento indexer:reindex               # reindex everything
bin/magento indexer:reindex catalogsearch_fulltext
bin/magento indexer:show-mode
bin/magento indexer:set-mode schedule     # "Update by Schedule" (recommended)
bin/magento indexer:set-mode realtime catalog_product_price
bin/magento indexer:reset catalogsearch_fulltext

I wrote a separate, detailed guide to the Magento 2 reindex command that explains every indexer and when to use each mode.

Setup and upgrade commands

bin/magento setup:upgrade                 # apply DB schema/data changes after installing modules
bin/magento setup:upgrade --keep-generated
bin/magento setup:di:compile              # generate DI configuration and interceptors
bin/magento setup:db:status               # check if setup:upgrade is needed
bin/magento setup:install --help          # all installation options

Static content deploy

bin/magento setup:static-content:deploy -f
bin/magento setup:static-content:deploy -f en_US vi_VN
bin/magento setup:static-content:deploy -f --area frontend --theme Magento/luma
bin/magento setup:static-content:deploy -f -j 4          # 4 parallel jobs
bin/magento setup:static-content:deploy -f -s compact    # quick | standard | compact

The -f (force) flag is required when the store is not in production mode. -j sets the number of parallel jobs (the default 0 means no parallel processing).

Deploy mode commands

bin/magento deploy:mode:show
bin/magento deploy:mode:set developer
bin/magento deploy:mode:set production
bin/magento deploy:mode:set production --skip-compilation

A typical production deployment

Here is the sequence I use after updating code or installing an extension on a live store:

bin/magento maintenance:enable
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f -j 4 en_US
bin/magento cache:flush
bin/magento maintenance:disable

magento-2-production-deploy-commands

Maintenance mode commands

bin/magento maintenance:enable
bin/magento maintenance:enable --ip=203.0.113.10   # your IP still sees the store
bin/magento maintenance:allow-ips 203.0.113.10
bin/magento maintenance:allow-ips --none
bin/magento maintenance:status
bin/magento maintenance:disable

Cron commands

bin/magento cron:install          # add Magento cron to the crontab
bin/magento cron:install --force
bin/magento cron:run              # run all cron groups once
bin/magento cron:run --group index
bin/magento cron:remove

Module commands

bin/magento module:status
bin/magento module:status --disabled
bin/magento module:enable Vendor_Module
bin/magento module:disable Vendor_Module --clear-static-content
bin/magento module:uninstall Vendor_Module --remove-data   # Composer-installed modules only

If you are adding a new extension, see how to install and enable a new Magento 2 extension.

Admin user commands

bin/magento admin:user:create --admin-user=john --admin-password='Str0ngPass!' \
  --admin-email=john@example.com --admin-firstname=John --admin-lastname=Doe
bin/magento admin:user:unlock john
bin/magento info:adminuri            # show the admin URL

More options and troubleshooting are in my tutorial on how to create an admin user in Magento 2 via command line.

Configuration commands

bin/magento config:show web/secure/base_url
bin/magento config:set web/secure/use_in_frontend 1
bin/magento config:set --scope=websites --scope-code=base general/locale/code en_GB
bin/magento config:set --lock-env catalog/search/engine opensearch   # write to env.php
bin/magento config:set --lock-config dev/js/minify_files 1           # write to config.php
bin/magento app:config:dump
bin/magento app:config:import
bin/magento app:config:status

Queue, catalog and other useful commands

bin/magento queue:consumers:list
bin/magento queue:consumers:start product_action_attribute.update --max-messages=1000
bin/magento catalog:images:resize
bin/magento catalog:images:resize --async
bin/magento sampledata:deploy
bin/magento sampledata:remove
bin/magento info:currency:list
bin/magento info:backups:list
bin/magento customer:hash:upgrade
bin/magento encryption:payment-data:update
bin/magento --version

Developer commands

bin/magento dev:template-hints:enable
bin/magento dev:template-hints:disable
bin/magento dev:query-log:enable
bin/magento dev:query-log:disable
bin/magento dev:di:info "Magento\Catalog\Api\ProductRepositoryInterface"
bin/magento dev:urn-catalog:generate --ide=phpstorm .idea/misc.xml

Common errors

“There are no commands defined in the … namespace”

The command belongs to a disabled module or you mistyped it. Run bin/magento list to check the exact name, and bin/magento module:status to see if the module is enabled.

“Permission denied” after running a command

You ran the command as root, so new files in generated/, var/ and pub/static/ belong to root. Fix the ownership with chown -R to the web server user and always run commands as that user.

Commands are slow or run out of memory

Run them with a higher PHP memory limit, for example php -d memory_limit=-1 bin/magento setup:di:compile.

The official list of every command and option is in the Adobe Commerce CLI reference.

FAQ about Magento 2 CLI commands

What is the difference between setup:upgrade and setup:di:compile?

setup:upgrade updates the database schema and data after you install or update modules. setup:di:compile generates the dependency injection code (factories, proxies, interceptors) in the generated folder. In production mode you usually need both, in that order.

Do I need to flush the cache after every command?

No. Commands like setup:upgrade already clean the cache. But after changing configuration with config:set, or after editing templates and layout files, run bin/magento cache:clean so the change is visible.

How can I run a command for a single store view?

Most configuration commands accept a scope: --scope=stores --scope-code=default. Static content can be limited with --theme, --area and a list of locales.

Can I run bin/magento commands on shared hosting?

Yes, if your host gives you SSH access. Use the full PHP path when the default PHP version is wrong, for example /usr/bin/php8.3 bin/magento cache:flush. Without SSH, ask your host to run the commands or use a control panel that supports them.

Where can I see what a command did?

Most commands print their result in the terminal. For errors, check var/log/system.log and var/log/exception.log, and add -vvv to a command to get a full stack trace.

Wrapping up

That’s the Magento 2 command list I use the most. Keep this cheat sheet bookmarked, and remember the two commands that save the most time: bin/magento list to find a command and bin/magento help <command> to see all of its options.

Is there a command you use a lot that is missing here? Leave a comment below and I will add it to the list.

Written by

Hung Tran

Hung Tran is the main editor of magentip.com, he loves to write about everything related to Magento 2