Get a list of network manager network connections with Bash?
I want to get a list of Ethernet and wireless connections from the terminal. Those connections are listed in NetworkManager's GUI and include info like the connection's SSID.
The next step is to delete unwanted connections.
Solution 1:
All NetworkManager connections are located in: /etc/NetworkManager/system-connections/
So you can easily use ls
to get a list of them:
ls /etc/NetworkManager/system-connections/
then remove the one you want:
sudo rm /etc/NetworkManager/system-connections/some-connection
You can also use nmcli
tool, which is a better idea:
To get a list of connections:
nmcli connection
To get informations about a connection:
nmcli connection show connection-name
You can pip it to grep
to look for specific info:
nmcli connection show connection-name | grep ipv4.dns
To modify a connection:
nmcli connection modify connection-name config-name new-alue
Example:
nmcli connection modify HomeNetwork ipv4.dns 8.8.8.8
To delete a connection
nmcli connection delete connection-name