Log in to the Magento server as, or switch to, a user with permissions to write to the Magento file system. See switch to the Magento file system owner.
If you use the bash shell, you can use the following syntax to switch to the Magento file system owner and enter the command at the same time:
su <Magento file system owner> -s /bin/bash -c <command>
If the Magento file system owner does not allow logins, you can do the following:
sudo -u <Magento file system owner> <command>
To run Magento commands from any directory, add
<magento_root>/binto your system
Because shells have differing syntax, consult a reference like unix.stackexchange.com.
Sample bash shell for CentOS:
Optionally, you can run the commands in the following ways:
cd <magento_root>/binand run them as
./magento <command name>
<magento_root>/bin/magento <command name>
<magento_root>is a subdirectory of your web server docroot.
In addition to the command arguments discussed here, see Common arguments.
Before you use these commands, you must install the Magento software.
Update the Magento software
To update the Magento software:
- If you installed the software from an archive or if you used ‘composer-create-project’, see the Upgrade Guide.
- If you are a contributing developer (that is, you used
git clone), see Update the Magento application.
Reinstall the Magento software
The way you reinstall the Magento application from the command line depends on your role:
- If you installed the software from an archive or if you used ‘composer-create-project’, see Reinstall Magento Software.
- If you’re a contributing developer (that is, you started using
git clone), see Reinstall Magento Software.
Uninstall the Magento software
Uninstalling the Magento software drops and restores the database, removes the deployment configuration, and clears directories under
To uninstall the Magento software, enter the following command:
1 bin/magento setup:uninstall
The following message displays to confirm a successful uninstallation:
1 [SUCCESS]: Magento uninstallation complete.
Optionally keeping generated files
bin/magento setup:upgrade clears compiled code and the cache. Typically, you use
bin/magento setup:upgrade to update components and each component can require different compiled classes.
However, in some situations (particularly, deploying Magento to production), you might wish to avoid clearing compiled code because it can take some time. (The cache is still cleared.) To update the Magento database schema and data without clearing compiled code, enter:
1 bin/magento setup:upgrade --keep-generated
--keep-generated option should be used only in limited circumstances by experienced system integrators. This option should never be used in a development environment. Improper use of this optional parameter can cause errors during code execution.