# Using the Magento command-line interface (CLI)

> Use the Magento command-line tool to manage caches, indexes, modules, upgrades and admin users quickly over SSH.

Source: https://helpcenter.ruachost.com/apps/magento/using-the-magento-command-line-interface-cli/

Magento includes a powerful **command-line interface (CLI)** that lets you perform common administrative tasks quickly and efficiently. On **ruachost.com**, the CLI is especially useful for automation, troubleshooting, and performance tuning.

## Why Use the Magento CLI?

- Faster than using the admin panel for repetitive tasks.
- Enables automation with scripts and cron jobs.
- Provides advanced options for developers and administrators.
- Essential for managing large or complex Magento stores.

## Getting Started

1. Log in to your hosting account via **SSH**.
2. Navigate to your Magento installation directory:

   ```bash
   cd ~/public_html
   ```
3. The CLI tool is located in the `bin` directory:

   ```bash
   bin/magento
   ```

   ```
   ```
4. Run the command to see available options:

   ```bash
   php bin/magento list
   ```

## Common Magento CLI Commands

### Cache Management

- Flush all caches:

  ```bash
  php bin/magento cache:flush
  ```
- Clean cache storage:

  ```bash
  php bin/magento cache:clean
  ```

### Index Management

- Reindex all data:

  ```bash
  php bin/magento indexer:reindex
  ```

### Module Management

- Enable a module:

  ```bash
  php bin/magento module:enable Vendor_ModuleName
  ```
- Disable a module:

  ```bash
  php bin/magento module:disable Vendor_ModuleName
  ```

### Setup and Upgrades

- Upgrade database schema and data:

  ```bash
  php bin/magento setup:upgrade
  ```
- Compile dependency injection:

  ```bash
  php bin/magento setup:di:compile
  ```
- Deploy static content:

  ```bash
  php bin/magento setup:static-content:deploy
  ```

### User Management

- Create a new admin user:

  ```bash
  php bin/magento admin:user:create \
    --admin-user="newadmin" \
    --admin-password="StrongPassword123" \
    --admin-email="admin@example.com" \
    --admin-firstname="John" \
    --admin-lastname="Doe"
  ```

## Important Notes

- Always back up your site before running upgrade or deployment commands.
- Use CLI commands in a **staging environment** before applying them to production.
- Some commands may require elevated permissions depending on your hosting plan.
