We turn complex data into clear information, giving you confidence in every decision.

Switch Network Manager profiles from the CLI in Ubuntu

With laptops there’s often a need to have multiple network profiles, especially when traveling. With development laptops there’s a need to do this fast, usually from the terminal

On servers with no GUI this can be easily accomplished by netplan

However, if you’re running a Linux GUI desktop then you’re likely using the popular GUI Network Manager when configuring network connections.

Network Manager also has a CLI component: nmcli.

To get started, install nmcli:

$ apt-get install network-manager

To list the configured network profiles:

$ nmcli c show

Output:

NAME               UUID                                  TYPE      DEVICE          
MYWIFI             304ae38f-8ca5-447a-8be9-20608a29e6b0  wifi      wlp2s0          
br-86167549b1e0    61ae9392-88bb-435b-ae1b-4525dd811665  bridge    br-86167549b1e0 
lo                 d53449aa-a96b-44c4-a46a-48949c7abc90  loopback  lo              
br-5f172a54d046    f3a4add6-bcc2-4b37-bbd4-4790656bb0f3  bridge    br-5f172a54d046 
docker0            13bae0b1-a4a0-465a-909c-9e370122ee7f  bridge    docker0         
MYWIFI (Static)    31cca8a6-1675-44f7-bb53-d88a919fbb45  wifi      --              
netplan-enp0s31f6  d4735e4b-9bfa-3052-b1c4-ef3302803c9a  ethernet  --

Using the UUID you can turn the profiles on and off:

# Turn a profile ON
$ nmcli c up
# Turn a profile OFF
$ nmcli c down

nmcli provides many more options for configuring your network connections via the CLI:

nmcli --help
LinkedIn