Comprehensive Guide to the 'nmcli radio' Command (with examples)

Comprehensive Guide to the 'nmcli radio' Command (with examples)

The nmcli radio command is part of the nmcli suite, which is provided by NetworkManager to manage and control network interfaces in Linux systems. This subcommand focuses specifically on radio technology interfaces, mainly Wi-Fi and WWAN (mobile broadband). The command allows users to query the status of these radios and toggle them on or off as needed. It’s particularly useful in scenarios where a graphical user interface is unavailable or users need quick control over network radios through the command line.

Use case: Show status of Wi-Fi

Code:

nmcli radio wifi

Motivation:

In a scenario where you’re troubleshooting connectivity issues related to a Wi-Fi network, knowing whether the Wi-Fi radio is turned on or off is crucial. This command allows you to verify the current state of the Wi-Fi interface without needing to navigate through any graphical interfaces, streamlining the debugging process.

Explanation:

  • nmcli: Refers to the NetworkManager command-line interface, a powerful tool to manage network settings.
  • radio: Specifies the subcommand to handle radio technologies/interfaces.
  • wifi: Targets the Wi-Fi radio switch for querying its status.

Example output:

disabled

The output indicates that the Wi-Fi radio is currently turned off.

Use case: Turn Wi-Fi on or off

Code:

nmcli radio wifi on

or

nmcli radio wifi off

Motivation:

Controlling the Wi-Fi radio directly from the command line is often essential in automated scripts or remote sessions where you need to manage network interfaces without physical interaction. For example, a remote server with no access to its desktop environment may require this to enable Wi-Fi connectivity.

Explanation:

  • nmcli radio wifi: Engages the Wi-Fi radio control.
  • on|off: The argument ‘on’ will enable the Wi-Fi radio, whereas ‘off’ will disable it, providing direct control over its status.

Example output:

For nmcli radio wifi on:

Wi-Fi is enabled

For nmcli radio wifi off:

Wi-Fi is disabled

Use case: Show status of WWAN

Code:

nmcli radio wwan

Motivation:

In mobile broadband scenarios, especially with devices like laptops using cellular networks, knowing whether the WWAN radio is enabled is critical. This command helps in identifying the current operational state of the WWAN interface.

Explanation:

  • nmcli: Calls the NetworkManager Command-Line Interface.
  • radio: Indicates the attention to radio interfaces.
  • wwan: Pertains to the mobile broadband radio switch, which is queried for its current status.

Example output:

enabled

Indicating that the mobile broadband (WWAN) radio is active.

Use case: Turn WWAN on or off

Code:

nmcli radio wwan on

or

nmcli radio wwan off

Motivation:

In environments where bandwidth usage needs to be regulated, like during travel where data costs are high, being able to switch the WWAN interface off and on through command scripts can help efficiently manage these resources.

Explanation:

  • nmcli radio wwan: Utilizes NetworkManager’s ability to control the WWAN interface.
  • on|off: The argument ‘on’ will activate WWAN connectivity, ‘off’ will deactivate it, providing full control.

Example output:

For nmcli radio wwan on:

WWAN is enabled

For nmcli radio wwan off:

WWAN is disabled

Use case: Show status of both switches

Code:

nmcli radio all

Motivation:

This command is useful when a global overview of the status of all radio interfaces on a system is required. It provides a quick and comprehensive overview of both Wi-Fi and WWAN interfaces to ensure all necessary components are operational or to identify any radio that wasn’t intended to be on or off.

Explanation:

  • nmcli: The command-line tool facilitating these operations.
  • radio: Specifies operations on radio interfaces.
  • all: Aggregates the status query for both Wi-Fi and WWAN, returning the state of each.

Example output:

WIFI-HW  WIFI    WWAN-HW  WWAN
enabled  disabled  enabled  enabled

Use case: Turn both switches on or off

Code:

nmcli radio all on

or

nmcli radio all off

Motivation:

In preparing a device for air travel or troubleshooting connectivity, there might be a need to turn all radios on or off quickly. Doing this manually through a GUI might take extra time, but with this command, an immediate blanket action is possible, ensuring no device is inadvertently left active.

Explanation:

  • nmcli radio all: Acts on all recognized radio interfaces.
  • on|off: The use of ‘on’ will activate all radios, while ‘off’ will deactivate them, allowing for rapid system-wide adjustments.

Example output:

For nmcli radio all on:

WIFI and WWAN are enabled

For nmcli radio all off:

WIFI and WWAN are disabled

Conclusion:

The nmcli radio command is a powerful utility for controlling network radio devices directly from the command line, enabling quick access and management of Wi-Fi and WWAN states across devices and scenarios where GUI-based management isn’t possible or practical. Its simplicity and effectiveness make it a crucial tool for system administrators and tech-savvy users managing network interfaces.

Related Posts

How to Use the Command 'tectonic' (with Examples)

How to Use the Command 'tectonic' (with Examples)

Tectonic is a modern, self-contained TeX/LaTeX engine designed to seamlessly compile TeX documents into ready-to-view PDFs with minimal fuss.

Read More
How to Use the Command 'nc' (with Examples)

How to Use the Command 'nc' (with Examples)

The ’nc’ command, often referred to as Netcat, is a powerful network utility used in Unix-like systems.

Read More
How to use the command 'ostree' (with examples)

How to use the command 'ostree' (with examples)

OSTree is a version control system designed for managing and deploying binary files and is optimized for operating system root filesystems.

Read More