I have a system without X display and I want to use nmcli to configure my cell modem to connect to a certain apn. I can get it going with this modem just fine on Ubuntu (with X) and I would like to achieve the same now on the command line. How can I setup the connection?

so far I get this:

# nmcli dev status

** (process:2379): WARNING **: Could not initialize NMClient /org/freedesktop/NetworkManager: Permissions request failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.PolicyKit1 was not provided by any .service files
DEVICE     TYPE              STATE        
ttyUSB1    gsm               disconnected 
eth0       802-3-ethernet    connected 

3 Answers 3


A bit late to the party, but I was stuck at the same hurdle. Since I have worked it out I thought I'd share my findings as every other post on the topic is about as clear as mud.

Although NetworkManager can see the device, it doesn't know of any connections that are supported by the device. Unlike WiFi, we can't just do a scan to make a list of available connections. We need to add one ourselves.

Before creating the connection, ensure NetworkManager does not prevent the device from being managed. This is by default happening on Ubuntu Server to prevent NetworkManager from taking over an existing legitimate legacy connection (see explanation from Ubuntu developer here).

You can verify that the device is unmanaged whennmcli device shows unmanaged status for your device, the opposite being disconnected. In this case, skip to the next paragraph.

To make NetworkManager on Ubuntu Server handle the connection, copy the file /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf to /etc/NetworkManager/conf.d/10-globally-managed-devices.conf, then edit it: modify the line beginning with unmanaged-device by adding gsm type to the list of exceptions:


Don't forget to check updates to the original /usr/lib file when upgrading NetworkManager.

Creating a connection

To start off with, we create a new connection named as you wish with the (appropriately named /s) edit command e.g.:

sudo nmcli connection edit type gsm con-name "My GPRS Connection"

Use sudo if you don't want to be disappointed when you try to save the connection.

Of course, if you aren't using GSM, you can change the type parameter to a different protocol supported by NetworkManager.

Now you will enter edit mode. Most of the settings you need are automatically filled in for you. You can see all the current settings with the print command:

nmcli> print
                Connection profile details (My GPRS Connection)
connection.id:                          My GPRS Connection
connection.uuid:                        27b012ca-453f-482f-bc0e-c81bbab07310
connection.interface-name:              --
connection.type:                        gsm
connection.autoconnect:                 yes
connection.timestamp:                   0
connection.read-only:                   no
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.gateway-ping-timeout:        0
ipv4.method:                            auto
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv6.method:                            auto
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       -1 (unknown)
ipv6.dhcp-hostname:                     --
gsm.number:                             *99#
gsm.username:                           --
gsm.password:                           --
gsm.password-flags:                     0 (none)
gsm.apn:                                --
gsm.network-id:                         --
gsm.network-type:                       -1
gsm.allowed-bands:                      1 (any)
gsm.pin:                                --
gsm.pin-flags:                          0 (none)
gsm.home-only:                          no

Type help to see a full list of commands.

The only thing you are likely to need to edit is the APN of your network. This can be set with set gsm.apn <APN> where APN would be something like epc.t-mobile.com, wholesale or vzwinternet for verizon.

You can also restrict the connection to a particular interface. This is not recommended especially for serial-based connections where the device name can change readily. If you wanted to though, you could do set connection.interface-name ttyS4 for example.

Provided you're running as root, you'll now be able to save your connection

nmcli> save

That's it. If you need to go back to edit the connection, use nmcli c edit "My GPRS Connection", or directly edit the config file. On Debian-based systems you'll find it in /etc/NetworkManager/system-connections/, on Redhat it'll be in /etc/sysconfig/network-scripts/. These files seem to be transferable from system to system - the UUID is basically random.

Connecting to our new connection

Now you should be able to connect with

sudo nmcli device connect <interface name>

If all goes well, NetworkManager will select "My GPRS Connection" automatically. If not,

sudo nmcli connection up "My GPRS Connection" ifname <interface name>

This is where it falls down for me right now. It times out during the connection but I think I'm out of signal range. Hopefully it works better for you.

Please comment if you need any more information.

  • i was able to create the connection, but still: Error: Connection activation failed: Connection 'eBroadband' is not available on the device ttyACM0 at this time. // ScSht #debian #stretch #thinkpad #N5321
    – eapo
    Jun 9, 2019 at 23:29
  • The name of the interface is the one that you see when you execute nmcli d you will see some like in my case cdc-wdm0 gsm something something you need to use that cdc-wdm0 in the set connection.interface-name
    – Nassiel
    Jan 23, 2022 at 10:12

It's a year later now and a lot of packages are updated. Using the ModemManager service and mmcli I was able to initialise my ublox SARA-U201. ModemManager already made the connection called "mymodem". The only thing that was not set right was the connection.interface-name, so this one I had to clear. +1 for the accepted answer because it helped me in the right way to achieve this. To summarise, these are the commands that I had to run to get it up and running:

sudo mmcli -i 0 --pin=<pin_number>
sudo mmcli -m 0 --simple-connect="apn=my.carrier.apn"
sudo nmcli connection edit mymodem
    nmcli>set connection.interface-name
    Enter 'interface-name' value: (leave blank, press enter)
sudo nmcli connection up mymode ifname ttyACM0

Note that these settings are saved except for the PIN of the SIM. If you require a PIN you have to using this command at every boot.

  • 1
    This is wrong I'm afraid, you should not run --simple-connect or --pin with mmcli and then attempt to bring the iface up with nmcli. There is no need to touch mmcli commands, you just need proper NM "gsm" settings with the APN and PIN set. There's not even strict need for the ifname actually.
    – Aleksander
    Sep 17, 2020 at 7:37
  • Maybe that's why the connection only worked at boot for a short while and then wouldn't connect any more. For some reason I didn't have the gsm.pin and gsm.apn settings on my device. I replaced the modem with a dongle for that project, maybe I'll check again later if I can add those settings by changing the connection type.
    – Pete
    Sep 18, 2020 at 9:06

Assuming you have a more recent version than 0.9.6:

$ nmcli --version
nmcli tool, version

You can create devices like so via the command line using the dev commands within nmcli:

excerpt from nmcli man page

   nmcli dev wifi con "Cafe Hotspot 1" password caffeine name "My cafe"

          creates a new connection named "My cafe" and then connects it to 
          "Cafe Hotspot 1" SSID using "caffeine" password. This is mainly 
          useful when connecting to "Cafe Hotspot 1" for the first time. 
          Next time, it is better to use 'nmcli con up id "My cafe"' so that 
          the existing connection profile can be used and no additional is 

However creating connections is still a very new feature for nmcli, and isn't even listed in my F19's version of NetworkManager ( Looking into F20 and RHEL7 Beta I noticed these examples which would seem to indicate that the option might be coming soon, 2.4. Using the NetworkManager Command Line Tool, nmcli.

$ nmcli connection modify id 'MyCafe' 802-11-wireless.mtu 1350

So perhaps if your distro has a newer version of NetworkManager you could add it like that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .