# nmcli

`nmcli` is a command-line interface for managing **NetworkManager**, a tool used to manage network connections on Linux-based systems. It provides a convenient way to configure network interfaces, Wi-Fi connections, VPNs, and other networking configurations directly from the command line.

### Key Features and Subcommands

Here’s a breakdown of some common `nmcli` commands and their usage:

### 1. **nmcli general**

Used to display general system network settings and manage NetworkManager.

*   **Show general status of NetworkManager:**

    ```bash
    nmcli general status
    ```

    This command shows the overall status of NetworkManager (e.g., whether it's running).
*   **Show the NetworkManager version:**

    ```bash
    nmcli general version
    ```
*   **Enable/Disable NetworkManager:**

    ```bash
    nmcli general enable
    nmcli general disable
    ```

### 2. **nmcli device**

Manages network devices and shows their status.

*   **Show all network devices:**

    ```bash
    nmcli device status
    ```

    Displays the status of all network devices (e.g., Ethernet, Wi-Fi, etc.).
*   **Bring a device up or down:**

    ```bash
    nmcli device connect eth0
    nmcli device disconnect eth0
    ```
*   **Show detailed information about a device:**

    ```bash
    nmcli device show eth0
    ```
*   **Change device connection:**

    ```bash
    nmcli device wifi connect SSID password "yourpassword"
    ```

### 3. **nmcli connection**

Used to manage network connections (Ethernet, Wi-Fi, VPN, etc.).

*   **Show all connections:**

    ```bash
    nmcli connection show
    ```
*   **Show a specific connection:**

    ```bash
    nmcli connection show <connection-name>
    ```
*   **Activate a connection:**

    ```bash
    nmcli connection up <connection-name>
    ```
*   **Deactivate a connection:**

    ```bash
    nmcli connection down <connection-name>
    ```
*   **Add a new Wi-Fi connection:**

    ```bash
    nmcli connection add type wifi ifname wlan0 con-name mywifi autoconnect yes ssid MySSID
    ```
*   **Delete a connection:**

    ```bash
    nmcli connection delete <connection-name>
    ```
*   **Edit a connection:**

    ```bash
    nmcli connection modify <connection-name> ipv4.addresses 192.168.1.100/24
    ```

### 4. **nmcli networking**

Used to control the overall networking status.

*   **Enable or disable networking:**

    ```bash
    nmcli networking off
    nmcli networking on
    ```

### 5. **nmcli radio**

Used to control the wireless radio (Wi-Fi) state.

*   **Enable Wi-Fi radio:**

    ```bash
    nmcli radio wifi on
    ```
*   **Disable Wi-Fi radio:**

    ```bash
    nmcli radio wifi off
    ```
*   **Enable/Disable Bluetooth radio:**

    ```bash
    nmcli radio bluetooth on
    nmcli radio bluetooth off
    ```

### 6. **nmcli vpn**

Manages VPN connections.

*   **Show VPN connections:**

    ```bash
    nmcli vpn show
    ```
*   **Add a VPN connection:**

    ```bash
    nmcli connection add type vpn vpn-type openvpn con-name myvpn ifname -- vpn-service-type org.freedesktop.NetworkManager.openvpn
    ```
*   **Activate a VPN connection:**

    ```bash
    nmcli connection up myvpn
    ```

### 7. **nmcli monitor**

Monitors network status in real-time.

*   **Monitor changes to connections:**

    ```bash
    nmcli monitor
    ```

This command will keep the terminal open and monitor any network changes in real-time.

### 8. **nmcli wifi**

Manages Wi-Fi connections and networks.

*   **List available Wi-Fi networks:**

    ```bash
    nmcli device wifi list
    ```
*   **Connect to a Wi-Fi network:**

    ```bash
    nmcli device wifi connect SSID password "yourpassword"
    ```
*   **Disconnect from the current Wi-Fi network:**

    ```bash
    nmcli device disconnect wlan0
    ```

### Examples of nmcli Usage

1.  **Check the current connection status:**

    ```bash
    nmcli connection show --active
    ```
2.  **Change the IP address of an interface:**

    ```bash
    nmcli connection modify "Wired connection 1" ipv4.addresses 192.168.0.100/24
    ```
3.  **Create a new Ethernet connection:**

    ```bash
    nmcli connection add type ethernet con-name "MyEthernet" ifname eth0 ipv4.addresses 192.168.0.101/24
    ```
4.  **Enable and disable Wi-Fi:**

    ```bash
    nmcli radio wifi off
    nmcli radio wifi on
    ```
5.  **Activate or deactivate a connection:**

    ```bash
    nmcli connection up "MyWifi"
    nmcli connection down "MyWifi"
    ```

### Conclusion

`nmcli` is a powerful and flexible tool for managing network connections on Linux systems. Whether you're configuring an Ethernet connection, connecting to Wi-Fi, managing VPNs, or even controlling network device states, `nmcli` provides a comprehensive set of commands to handle all your network configuration needs from the command line.
