How to Use the Command 'mmcli' (with Examples)
- Linux
- December 17, 2024
The mmcli
command is an invaluable utility designed to control and monitor the functionality of ModemManager, a service that enables easy management of network connections through various USB and built-in modems in Linux-based systems. This tool allows users to execute a range of operations on connected modems, from querying status and sending messages to enabling or disabling modem hardware. Below, we explore several practical use cases of the mmcli
command.
Use case 1: List Available Modems
Code:
mmcli --list-modems
Motivation:
Listing all available modems connected to your system is a crucial first step when managing or configuring these devices. This is especially important for users who work with multiple modems and need to understand their current status and connectivity. By identifying all modems, you can make informed decisions about which device to interact with for specific tasks.
Explanation:
--list-modems
: This argument instructsmmcli
to display a list of all modems currently recognized by the ModemManager service. It doesn’t require any additional parameters and serves as a straightforward query to quickly assess the active modems.
Example Output:
Found 2 modems:
/org/freedesktop/ModemManager1/Modem/0 [Sierra Wireless, Incorporated] EM7345
/org/freedesktop/ModemManager1/Modem/1 [Qualcomm] Gobi 2000
Use case 2: Print Information About a Modem
Code:
mmcli --modem=0
Motivation:
Understanding the detailed state and configuration of a specific modem is essential for troubleshooting, configuration, and management tasks. This command allows users to access comprehensive information about a specified modem, such as model, carrier information, signal quality, and registration state, which can be crucial for network diagnostics.
Explanation:
--modem=0
: The--modem
option is used to specify which modem to query for information. The number ‘0’ represents the unique identifier assigned to a particular modem, as provided in the listing output from the previous use case.
Example Output:
/org/freedesktop/ModemManager1/Modem/0
-------------------------
Modem | Sierra Wireless, Incorporated EM7345
-------------------------
Status | active
IP | 192.168.1.2
Signal Quality | 80%
-------------------------
Use case 3: Enable a Modem
Code:
mmcli --modem=0 --enable
Motivation:
Enabling a modem is a fundamental operation for users looking to activate a data connection on a disabled device. This operation prepares the modem for operation by initializing its network interface and registering it on the appropriate mobile network. This is a necessary action after a modem is installed or if it has been disabled for any reason.
Explanation:
--modem=0
: Indicates which modem should be enabled, using its unique identifier.--enable
: This parameter is used to enable the specified modem, allowing it to establish a data connection when conditions permit.
Example Output:
Successfully enabled modem: /org/freedesktop/ModemManager1/Modem/0
Use case 4: List SMS Messages Available on the Modem
Code:
sudo mmcli --modem=0 --messaging-list-sms
Motivation:
Listing SMS messages stored on a modem is particularly useful for users who need to manage text communications directly through the modem, especially in embedded systems or remote network management scenarios. It lets you review messages sent or received without using a traditional mobile interface.
Explanation:
sudo
: Grants the necessary administrative privileges required to access messaging functions on many systems.--modem=0
: Specifies the modem from which to list SMS messages.--messaging-list-sms
: Requests a listing of all SMS messages currently stored in the specified modem’s memory.
Example Output:
Found 2 SMS messages:
/org/freedesktop/ModemManager1/Sms/0 (received)
/org/freedesktop/ModemManager1/Sms/1 (sent)
Use case 5: Delete a Message from the Modem
Code:
sudo mmcli --modem=0 --messaging-delete-sms=/org/freedesktop/ModemManager1/Sms/0
Motivation:
Deleting SMS messages from a modem is often necessary to maintain memory availability and ensure personal data stays secure. This is especially critical on devices with limited storage capacity or when automated systems require regular cleanup to function optimally.
Explanation:
sudo
: Ensures the user has the necessary permissions to delete messages.--modem=0
: Selects the modem associated with the SMS to be deleted.--messaging-delete-sms=/org/freedesktop/ModemManager1/Sms/0
: Specifies the exact SMS message, by its path, that should be removed from the modem’s storage.
Example Output:
Successfully deleted SMS: /org/freedesktop/ModemManager1/Sms/0
Conclusion
The mmcli
command proves to be an efficient and robust tool for managing modem connectivity in Linux environments, providing essential functions to list, control, and monitor modem operations. Whether you are enabling a connection, managing SMS, or retrieving modem details, mmcli
simplifies these tasks by offering a command-line method to manage modems seamlessly.