I use a USB LTE modem to connect to the internet. The problem is, every time I connect it to my PC, it first gets recognised as a mass storage device. I need to manually run this command every time I plug it in: sudo usb_modeswitch -J -v 12d1 -p 14fe to change its mode to Modem/Networkcard. It's not a great problem, but it becomes very tiring to those steps every time.
How do I automate this process such that every time I plug in the device it gets recognised as a Modem in the first place?

1 Answer 1


The easiest way is to create an udev rule in /etc/udev/rules.d/70-usb-modeswitch.rules .

For example with a USB LTE stick from another vendor:

# own udev rule USB LTE 
# switch from mass storage mode to modem modem
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9bfe", RUN+="/usr/sbin/usb_modeswitch -v 1c9e -p 9bfe -M '55534243123456780000000000000606f50402527000000000000000000000'"
# load driver for modem mode
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9b01", RUN+="/bin/bash -c 'modprobe option && echo 1c9e 9b01 > /sys/bus/usb-serial/drivers/option1/new_id'"
# rule for modemmanager (example /lib/udev/rules.d/77-mm-longcheer-port-types.rules)
ACTION!="add|change", GOTO="mm_longcheer_port_types_end"
SUBSYSTEM!="tty", GOTO="mm_longcheer_port_types_end"

SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c9e", GOTO="mm_longcheer_vendorcheck"

SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{bInterfaceNumber}"

ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9b01", ENV{.MM_USBIFNUM}=="03", ENV{ID_MM_LONGCHEER_PORT_TYPE_MODEM}="1"
ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9b01", ENV{.MM_USBIFNUM}=="00", ENV{ID_MM_LONGCHEER_PORT_TYPE_AUX}="1"
ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9b01", ENV{.MM_USBIFNUM}=="01", ENV{ID_MM_LONGCHEER_PORT_TYPE_AUX}="1"
ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9b01", ENV{.MM_USBIFNUM}=="02", ENV{ID_MM_LONGCHEER_PORT_TYPE_AUX}="1"
ATTRS{idVendor}=="1c9e", ATTRS{idProduct}=="9b01", ENV{ID_MM_LONGCHEER_TAGGED}="1"


After saving your rule do udevadm control --reload-rules.

see also this longer blog post https://bytefish.de/blog/huawei_e352s5/

  • You should point out where your idVendor and idProduct is specific to your machine and OP needs to replace with their own values. Also how OP can obtain idVendor and idProduct using lsusb or whichever command you used to get your values. Many new users will be unaware of lsusb output and correlation to udev rules. Commented Jun 6, 2020 at 16:47

You must log in to answer this question.

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