YouTip LogoYouTip

Linux Comm Nmcli

Linux nmcli Command | Rookie Tutorial [![Image 1: Linux Command Manual](#) Linux Command Manual](#) * * * ## What is nmcli nmcli is the command-line tool for NetworkManager, used to configure and manage network connections in Linux systems. It is the official client for NetworkManager, providing more powerful and flexible network management capabilities than the graphical interface. ### Main Features of nmcli * **Full Feature Support**: Covers almost all NetworkManager functionalities * **Script-Friendly**: Suitable for automation scripts and remote management * **No Dependencies**: Does not require a graphical interface, operates purely via command line * **Real-time Feedback**: Immediately displays command execution results * * * ## nmcli Basic Syntax The basic command format for nmcli is as follows: nmcli OBJECT { COMMAND | help } ### Common OBJECT Types * `general`: NetworkManager general status and operations * `networking`: Overall network control * `radio`: Wireless network switches * `connection`: Network connection configuration * `device`: Network device management ### Common OPTIONS | Option | Description | | --- | --- | | `-t` | Terse output (suitable for script processing) | | `-p` | Pretty output (more readable) | | `-h` | Show help information | | `-v` | Show version information | * * * ## Detailed Explanation of Common nmcli Commands ### 1. Check Network Status Check NetworkManager overall status: ## Example nmcli general status Output example: STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN connected full enabled enabled enabled enabled ### 2. Manage Network Connections List all network connections: ## Example nmcli connection show Activate/Deactivate a connection: ## Example nmcli connection up "Connection Name" nmcli connection down "Connection Name" ### 3. Manage Network Devices List all network devices: ## Example nmcli device status Output example: DEVICE TYPE STATE CONNECTION eth0 ethernet connected Wired Connection 1 wlan0 wifi disconnected -- lo loopback unmanaged -- View detailed device information: ## Example nmcli device show eth0 * * * ## Wireless Network Management ### Scan for Available WiFi Networks ## Example nmcli device wifi list ### Connect to a WiFi Network ## Example nmcli device wifi connect "SSID Name" password "Password" ### Create a New WiFi Connection Profile ## Example nmcli connection add type wifi ifname wlan0 con-name "MyWiFi" ssid "SSID Name" nmcli connection modify "MyWiFi" wifi-sec.key-mgmt wpa-psk nmcli connection modify "MyWiFi" wifi-sec.psk "Password" * * * ## Wired Network Configuration ### Create a Static IP Connection ## Example nmcli connection add type ethernet ifname eth0 con-name "Static Connection" ip4 192.168.1.100/24 gw4 192.168.1.1 nmcli connection modify "Static Connection" ipv4.dns "8.8.8.8,8.8.4.4" ### Modify an Existing Connection to DHCP ## Example nmcli connection modify "Connection Name" ipv4.method auto * * * ## Advanced Usage ### Create a VPN Connection ## Example nmcli connection add type vpn vpn-type openvpn con-name "MyVPN" ifname tun0 vpn.data "remote=vpn.example.com, username=user, password=pass" ### Create a Bridge ## Example nmcli connection add type bridge ifname br0 con-name "My Bridge" nmcli connection add type bridge-slave ifname eth0 master br0 ### Create a VLAN ## Example nmcli connection add type vlan ifname eth0.100 con-name "VLAN100" dev eth0 id 100 ip4 192.168.100.100/24 * * * ## Common Issue Resolution ### 1. Network Device Shows as "Unmanaged" ## Example # Check NetworkManager.conf cat/etc/NetworkManager/NetworkManager.conf # If you see unmanaged-devices configuration, you can comment out the relevant lines # Then restart NetworkManager systemctl restart NetworkManager ### 2. Forgot Connection Password ## Example nmcli connection show "Connection Name"|grep psk ### 3. Reset Network Configuration ## Example nmcli connection reload * * * ## Practice Exercises 1. Use nmcli to connect to your WiFi network 2. Create a wired connection with a static IP 3. Scan and list all available WiFi networks 4. View detailed information of the currently active connection * * * ## Summary nmcli is a powerful tool for network management in Linux systems. After studying this article, you should be able to: * Understand the basic concepts and syntax structure of nmcli * Use nmcli to manage wired and wireless network connections * Configure static IP and DHCP connections * Handle common network connection issues Mastering nmcli allows you to efficiently manage networks in server environments without a graphical interface and is an important skill for Linux system administrators. [![Image 2: Linux Command Manual](#) Linux Command Manual](#)
← Linux Comm ServiceLinux Comm Sar β†’