How to toggle mobile data from cli

When librem5 loses mobile data I have to reset the modem and disable/enable mobile data.
For the modem reset in command line it’s ok but I can’t find for mobile data.
Who can help me?

1 Like

Have you looked into nmcli, similar to the Hotspot toggle commands described here?

Yes, I did it but my problem is not with the hotspot, which is working well and keep the connection up.
Sometimes, as reported many times in this forum, the mobile data connection stop working, the modem is connected to the mobile network but without data.
The solution is to reset the modem but just doing this is not enought, I havev to switch on/off the mobile data (currently in Gui Mobile Connection).
When I’m connected from my laptop far from the L5, I would like to do via ssh (hotspot still up) and I didn’t found the correct mmcli syntaxe.

1 Like

The point I wanted to make is that it should be a nmcli invocation either way, regardless of Hotspot or mobile connection.

Run nmcli connection and look through the list until you find an entry whose type is gsm. (For me it’s Prepaid Contracts but yours may vary.) That’s the connection you want to bring down or up via nmcli.

Edit: Confirmed.

For me, it’s

sudo nmcli connection up 'Prepaid Contracts'

to bring the connection up, and

sudo nmcli connection down 'Prepaid Contracts'

to bring it down again.


Thanks a lot @Lliure I was looking at mmcli commands not nmcli.
So I just successfully tested it.


I have a bunch of such connections, which would be the correct one:

purism@pureos:~$ nmcli connection | grep gsm
Internet                          2ea6512e-7b60-428e-86b3-6516e763162c  gsm       cdc-wdm0
Default                           ae31686b-061a-4137-9de0-852b73f201ba  gsm       --
fonic                             2e48491c-6c46-4ba7-8161-dff86b41337c  gsm       --
FONIC                             da8ff50a-734e-4e3c-ba0c-c7e7d1e311c0  gsm       --
Internet                          1d8c4ac9-ed41-413f-a76a-d15dbe1f8666  gsm       --
Internet                          3e7c17a5-7957-41b1-9f6e-485ed6b450e6  gsm       --
Internet                          d4d8135a-3a88-42cc-b7bd-0070b198fb34  gsm       --
Internet                          f1e9473b-1de4-4bc0-ba2d-e703502bc07e  gsm       --
Internet Cubacel                  206a96d5-3179-4313-9eb7-bbefc7595c17  gsm       --
NAUTA                             c68ad5c8-0896-4a0c-a19f-9e01b432574c  gsm       --
o2 Internet                       c887561b-3d59-4fc9-9ddf-fbd5d1cdf7c8  gsm       --

The one where it says cdc-wdm0 at the end should be the correct one.

If the names are not unique, e.g. Internet, I think that nmcli allows you to pass the UUID instead.

Using the Librem SIMple plan, I’m able to toggle data on/off via the terminal using:

$ nmcli connection <up|down>

It does. I normally do that.

Probably time to clean some of those up …

1 Like

When librem5 loses mobile data I have to reset the modem

Hello. I appreciate the solution and receiving the command. However, I have a bigger question: why does the mobile modem drop data so much? Is this problem being looked-at? Is this a fixable issue in Crimson? This is a rather large issue (as many others have noted in other posts).

Is Purism aware of this rather large issue and are they working on it?

It is more frequent when suspend mode is activated, but not only.

I agree with this the suspend issue. However, it happens with and without suspend activated.