Share your love
How To Configure Networking on AlmaLinux

In this guide, we want to teach you How To Configure Networking on AlmaLinux with the nmcli command.
nmcli is a command-line tool that is used for controlling NetworkManager. nmcli command can also be used to display network device status, create, edit, activate/deactivate, and delete network connections.
Typical Uses:
- Scripts: Instead of manually managing the network connections it utilizes NetworkManager via nmcli.
- Servers, headless machines, and terminals: Can be used to control NetworkManager with no GUI and control system-wide connections.
Configure Networking on AlmaLinux with nmcli command
In this tutorial, we will show you how to use the nmcli command to control network connections and restart your network on AlmaLinux.
How To Check Network Status on AlmaLinux
NetworkManager is a system network service that manages your network devices and connections and attempts to keep network connectivity active when available.
One of the most popular usages of the nmcli command is to check whether the Network Manager is running or not on your server. To do this, you can run the following command:
nmcli -t -f RUNNING general
In your output you will see:
Output
running
Also, you can get a general status by running the command below:
nmcli general
Output STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN connected full enabled enabled enabled enabled
How To List Available Devices on AlmaLinux
At this point, you can use the nmcli command to display your all available devices on AlmaLinux:
nmcli dev status
In my case, I get the following output:
Output
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected System eth0
lo loopback unmanaged --
How To List Active Connections on AlmaLinux
Another usage of the nmcli command is to list your active connections. To do this, run the following command:
nmcli con show
In my case, I get the following output:
Output
NAME UUID TYPE DEVICE
System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0
ens3 0e50b731-0de2-4c9f-906c-6c2f3d8129d1 ethernet --
Also, you can list the brief information about the ethernet connection by running the command below:
nmcli con show "System eth0"
In your output, you will see something similar to this:
Output
connection.id: System eth0
connection.uuid: 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
connection.stable-id: --
connection.type: 802-3-ethernet
connection.interface-name: eth0
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.autoconnect-retries: -1 (default)
connection.multi-connect: 0 (default)
connection.auth-retries: -1
....
How To Change Hostname on AlmaLinux
You can easily use the nmcli command to find your current hostname and change it.
nmcli general hostname
Output
AlmaLinux
To change the hostname from AlmaLinux to Linux for example, run the command below:
nmcli general hostname linux
How To Restart Ethernet Connection on AlmaLinux
You can restart or reload your ethernet connection with the following command:
nmcli con reload
How To Restart Network on AlmaLinux
To turn networking completely off and back on in AlmaLinux, we can use the following nmcli command, which effectively restarts the network for the operating system.
# nmcli networking off # nmcli networking on
How To Reset a Network Interface on AlmaLinux
To activate an ethernet connection, run the following command:
nmcli con up ens3
You should see the following output:
Output
Connection successfully activated
You can now verify the active connection with the following command:
nmcli con show --active
To deactivate the connection, run the following command:
nmcli con down ens3
Also, there is another way to reset a network interface in AlmaLinux is with the ip link
commands, which work through networkd.
#ip link set ens3 down #ip link set ens3 up
How To Delete an Ethernet Connection on AlmaLinux
You can also delete a specific ethernet connection with nmcli.
For example, to delete a connection ens3, run the following command:
nmcli con del ens3
You should see the following output:
Output
Connection 'ens3' (cefb3f7d-424c-42f8-b4e8-ed54e7dcb880) successfully deleted.
To get more information about the nmcli command, you can run the following command:
nmcli --help
Output
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }
OPTIONS
-a, --ask ask for missing parameters
-c, --colors auto|yes|no whether to use colors in output
-e, --escape yes|no escape columns separators in values
-f, --fields <field,...>|all|common specify fields to output
-g, --get-values <field,...>|all|common shortcut for -m tabular -t -f
-h, --help print this help
-m, --mode tabular|multiline output mode
-o, --overview overview mode
-p, --pretty pretty output
-s, --show-secrets allow displaying passwords
-t, --terse terse output
-v, --version show program version
-w, --wait set timeout waiting for finishing operations
OBJECT
g[eneral] NetworkManager's general status and operations
n[etworking] overall networking control
r[adio] NetworkManager radio switches
c[onnection] NetworkManager's connections
d[evice] devices managed by NetworkManager
a[gent] NetworkManager secret agent or polkit agent
m[onitor] monitor NetworkManager changes
Conclusion
At this point, you learn how to use the nmcli command to control your networking on AlmaLinux.
Hope you enjoy it.
You may be interested in these articles:
Install and Configure Zabbix 6.0 on AlmaLinux 8