How to Use the Command 'nmcli general' (with Examples)

How to Use the Command 'nmcli general' (with Examples)

The nmcli general command is a versatile utility for managing general settings of NetworkManager, a system network service that manages network devices and connections, attempting to enable users to connect to a network as seamlessly as possible. It is a command-line client for NetworkManager which simplifies network management tasks in Linux-based systems.

Use Case 1: Show the General Status of NetworkManager

Code:

nmcli general

Motivation:

Using nmcli general without any arguments provides a quick overview of the general status of NetworkManager on your system. This is particularly useful for administrators or users who need a summary status update of the network environment without diving into intricate details. It gives an essential glimpse into whether NetworkManager is running and operational, which can be critical for troubleshooting or confirming system setup.

Explanation:

  • nmcli: Calls the NetworkManager command-line interface.
  • general: Specifies that general information about NetworkManager should be retrieved.

Example Output:

state: connected
connectivity: full
wifi-hotspot: none

In this example output, it shows that the system’s connectivity status is active (‘connected’) and provides additional information about connectivity type and Wi-Fi hotspot status. This summary can immediately reassure that the network services are functioning as expected.

Use Case 2: Show the Hostname of the Current Device

Code:

nmcli general hostname

Motivation:

Gathering the hostname of the system is fundamental for network configuration, identification, and management. When managing multiple servers or troubleshooting network-related issues, knowing the hostname allows you to easily identify systems and apply the necessary configurations or technical queries.

Explanation:

  • nmcli: Invokes the NetworkManager command-line tool.
  • general: Targets the general settings domain.
  • hostname: Command option that specifies the retrieval of the current system’s hostname.

Example Output:

current_host_name

This output provides the current hostname configured on your machine, which is useful for ensuring correct network identification and configuration.

Use Case 3: Change the Hostname of the Current Device

Code:

sudo nmcli general hostname new_hostname

Motivation:

Changing a system’s hostname can be necessary when roles or responsibilities of a server have changed or during initial system setup for clear organizational identification. This affecting how the system is recognized over the network can align with naming conventions or meet specific protocol criteria.

Explanation:

  • sudo: Runs the command with superuser privileges necessary for changing system configurations.
  • nmcli: Engages the NetworkManager command-line interface.
  • general: Accesses general settings to be modified.
  • hostname: Specifies the operation of changing the current device’s hostname.
  • new_hostname: Placeholder for the desired new hostname, which must not include spaces and should conform to network naming conventions.

Example Output:

There is no direct output to this command, but if executed successfully, running nmcli general hostname afterward will return:

new_hostname

Indicating that the hostname change has been successfully applied.

Use Case 4: Show the Permissions of NetworkManager

Code:

nmcli general permissions

Motivation:

Understanding permissions allocated to NetworkManager can be crucial for security audits and ensuring that necessary privileges are correctly assigned. This is particularly key in environments with strict access controls and detailed network policies, where inappropriate permissions could lead to inadvertent policy violations.

Explanation:

  • nmcli: Accesses NetworkManager’s command-line interface.
  • general: Focuses on general settings and information.
  • permissions: Requests a list of permissions that NetworkManager currently has.

Example Output:

org.freedesktop.NetworkManager.network-control: yes
org.freedesktop.NetworkManager.settings.modify.global-dns: no
org.freedesktop.NetworkManager.settings.modify.hostname: yes

This example output details varying permission statuses, indicating which controls NetworkManager is permitted to access or alter.

Use Case 5: Show the Current Logging Level and Domains

Code:

nmcli general logging

Motivation:

Network troubleshooting often involves assessing logging information. Determining the current logging level and domains across NetworkManager is essential for diagnosing connectivity issues, monitoring network performance, or auditing system activity. This command is beneficial for IT professionals looking to optimize logging configurations or verify diagnostic readiness.

Explanation:

  • nmcli: Calls the NetworkManager command-line tool.
  • general: Focuses on general state and configuration information.
  • logging: Fetches the current logging level and the domains being logged.

Example Output:

level: INFO
domains: PLATFORM,RFKILL,VPN

The example indicates the current logging activity level (INFO), along with active logging domains, facilitating targeted log analysis by the user.

Use Case 6: Set the Logging Level and/or Domains

Code:

nmcli general logging level DEBUG domain PLATFORM,VPN

Motivation:

Adjusting the logging level and domains allows for detailed monitoring and troubleshooting. This is particularly useful for developers or network engineers diagnosing specific issues or testing new network setups. By switching to a more detailed logging level or focusing on specific domains, precise diagnoses and insights into system behavior are facilitated.

Explanation:

  • nmcli: Contacts NetworkManager’s command-line interface.
  • general: Instructs commands to deal with general configurations and settings.
  • logging: Specifies a change in logging priorities.
  • level DEBUG: Sets the logging level to DEBUG, providing detailed operational outputs for diagnosis and examination purposes.
  • domain PLATFORM,VPN: Targets specific network domains (PLATFORM and VPN) for logging, focusing tool outputs on relevant operational areas.

Example Output:

No direct output will be displayed; however, deeper and domain-specific logging information will become available in the system’s logging outputs.

Conclusion:

The nmcli general command is instrumental for managing various aspects of network settings efficiently from the Linux command line. With capabilities ranging from simple status checks to making deep configuration changes, it supports tasks in system management and administrative network control, contributing significantly to improved workflow in managing Linux-based network environments.

Related Posts

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

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

Tailscale is a private WireGuard network service that simplifies secure networking by allowing users to easily connect devices using a unique mesh VPN.

Read More
Understanding the 'cargo publish' Command in Rust (with Examples)

Understanding the 'cargo publish' Command in Rust (with Examples)

The cargo publish command in Rust serves a critical role in the Rust ecosystem by allowing developers to upload their packages (or crates) to a cargo registry.

Read More
How to Use the Command `pmset` (with Examples)

How to Use the Command `pmset` (with Examples)

The pmset command is a powerful tool available in macOS that allows users to configure power management settings directly from the command line.

Read More