Command-line tool
Commerce has one command-line interface (CLI)—<magento_root>/bin/magento
—that runs installation and configuration tasks, including:
- Installing Commerce (and related tasks such as update the database schema, create a deployment configuration)
- Clearing the cache
- Managing indexes, including reindexing
- Creating translation dictionaries and translation packages
- Generating non-existent classes such as factories and interceptors for plug-ins, generating the dependency injection configuration for the object manager
- Deploying static view files
- Creating CSS from Less
Additional benefits include:
- A single command (
<magento_root>/bin/magento list
) lists all available installation and configuration commands. - Consistent user interface based on Symfony.
- The CLI is extensible so third-party developers can “plug in” to it. This has the additional benefit of eliminating users’ learning curve.
- Commands for disabled modules do not display.
This topic discusses configuring the Adobe Commerce and Magento Open Source software using the CLI. For information about installing Commerce, see Installation flow in the Installation guide.
Prerequisites
Before you begin using the CLI, make sure that:
- Your system meets the requirements discussed in System Requirements in the Installation guide.
- You completed all prerequisite tasks discussed in Prerequisites in the Installation guide.
- After you log in to the Commerce server, switch to a user that has permissions to write to the Commerce file system. See switch to the file system owner in the Installation guide.
Running commands
For the bash shell, use the following syntax to switch to the file system owner and enter the command at the same time:
su <file system owner> -s /bin/bash -c <command>
If the file system owner does not allow logins, you can use the following:
sudo -u <file system owner> <command>
To run CLI commands from any directory:
Add <magento_root>/bin
to your system PATH
.
Sample bash shell for CentOS:
export PATH=$PATH:/var/www/html/magento2/bin
Optionally, you can run the following:
cd <magento_root>/bin
and run them as./magento <command name>
<magento_root>/bin/magento <command name>
<magento_root>
is a subdirectory of your web server docroot
recommendation-more-help
386822bd-e32c-40a8-81c2-ed90ad1e198c