Key Takeaways

  • Tethering allows you to share your mobile internet with a Linux computer, either through USB or wireless connection.
  • Using a suitable USB cable is important for successful tethering, as it will provide a reliable network connection and prevent wireless interference.
  • Tethering is a convenient option when you don't have Wi-Fi or Ethernet network access, and it can be easily set up with Android and iPhone devices on Linux computers.

Laptops are invariably limited to Wi-Fi only connections; desktop computers never have built-in mobile internet. But what if you need to get your Linux computer online but have no wireless or Ethernet network?

The answer is tethering. With a smartphone you can share your mobile internet with your computer.

As long as your carrier doesn't limit how you use your data, internet connection sharing (also known as netshare) with a Linux computer is a good option. Wi-Fi tethering is one option, but what if this isn't practical? Happily, there is an alternative. Here's how to use Linux USB tethering with Android and iPhone.

What Is Tethering?

Tethering is the name given to connecting a mobile device to a computer in order to share mobile internet.

While some carriers might restrict this activity, these days that is rare. Most smartphones have a data plan which allows tethering, making tethering an attractive way to get online.

Strictly speaking, tethering refers to using a USB cable to share mobile internet. This means that you will need to carry your phone's USB data cable around if you plan to use tethering.

Wireless tethering is also possible, using Wi-Fi or Bluetooth, although Bluetooth is slower and less reliable.

Using Wi-Fi is known as setting up a "wireless hotspot" with your mobile. In most cases wireless tethering is easier, but there are good reasons to use USB tethering:

  • For a reliable network connection
  • To keep your phone charged
  • Avoid wireless interference
  • Prevent wireless sniffers intercepting data

If you don't have a suitable USB cable, here's how to use your phone as a wireless hotspot. Simply connect your Linux computer to your phone's hotspot to get online.

Use the Right USB Cable for Tethering

Before proceeding, you need to be sure that you're using a USB cable that is suitable for tethering. Not all cables will work for this, as some are designed purely for power. Here’s the best way to check that your USB cable is suitable for tethering:

  1. Connect the cable to your computer
  2. Connect your phone to the cable
  3. Wait for either device to detect the other
  4. If data transfer or file browsing is available, it is suitable for tethering
  5. An unsuitable cable will merely charge the phone

If there is a problem with the cable, you should be able to buy a suitable data-ready alternative online.

The methods described here require you to connect the mobile device to your PC with a working USB cable before activating tethering. All the steps and screenshots have been recorded using USB tethering on Ubuntu 22.04.3 lTS.

How to Tether Android Phones to Linux

If you have an Android device, tethering is straightforward, thanks in part to both phone and PC being Linux-based.

If you want to share your mobile internet to a Linux PC over USB :

  1. Connect the USB cable to your phone and Linux PC.
  2. Android will detect the connection---when prompted to Allow access, select Allow.
  3. In the Notifications find the USB message, and tap it.
  4. Under Use USB for, select USB tethering.

In most cases, the connection will be automatically established. You should be able to see the connection details in the system tray/panel.

If not, use the terminal. Check the IP address for your device to confirm it has worked:

        ip address
    

Look for a new entry (you can disconnect and retry) with a valid IP address for your network.

Check USB connection status in the terminal.

If you find the ip address results confusing, use ifconfig, which can be accessed with the net-tools package.

        sudo apt install net-tools
    

To display network connections, enter

        ifconfig
    

Look for an option labeled

        usb0
    

...or again, anything new with a valid IP address.

Linux to Android USB tethering isn’t always that simple. With some distros, you may need to select the USB connection.

  1. Find the network tray icon
  2. Click to find the network option with a name like "auto usb0".
  3. Select this to connect Linux to your phone via the USB cable.

Don't have a data plan which allows tethering? Installing a custom Android ROM can help circumvent restrictions.

How to Tether iPhones to Linux

If you have an iPhone with a data plan which allows tethering, you can set up Linux tethering over USB.

Unlike Android, however, this doesn't connect automatically. Instead, you will need libimobiledevice, described as a "cross-platform software protocol library and tools to communicate with iOS devices natively." Head to www.libimobiledevice.org to confirm current compatibility.

If you're using Ubuntu, libimobiledevice should already be installed. If not, before hooking up your iPhone to Linux, open a terminal and enter:

        sudo apt install libimobiledevice6
    

Next, you need to establish trust between the phone and computer. When hooking up the devices with the USB cable, you will be prompted with messages on both devices. On the iPhone, tap Trust to proceed; the message should vanish on the computer (if nothing happens, click Try again.)

iPhone connection trust connection notice

To connect to the internet through your iPhone:

  1. Open Settings > Personal Hotspot.
  2. Enable Allow Others to Join.

All you need to do now is select the connection to enable Linux tethering. Unlike Android, iPhone devices display as a new Ethernet device, rather than USB. You should see them listed in the usual Settings > Network view.

Can You Enable USB Tethering in the Linux Terminal?

In some scenarios you may need to use the command line to tether Linux to your phone. For example, your computer may not have a desktop environment.

It is unsurprisingly simple so enable this. With the phone connected over USB and sharing activated, open sudo nano /etc/netplan/01-network-manager-all.yaml.

Next, add the following:

        ethernets:
    

Should you need to enable IPv6, change the condition to on the dhcp6 option to yes. (Note that true and false also work.)

Hit CTRL+X to save and exit, then Y to confirm.

Enter the following commands:

        sudo netplan try
sudo netplan apply

Your USB tethered connection should now begin. You can review the netplan at any time from the terminal with

        sudo netplan get
    

Remember not to save any changes to the file unless they are required.

Tethering Linux Phones to Linux

Several Linux mobile operating systems are available. These include a mobile version of Pure OS on the Librem 5, PostmarketOS on the PinePhone, and UBPorts, the continuation of Ubuntu Touch (perhaps the easiest Linux mobile operating system to install).

Perhaps surprisingly, not all of these have reliable options for USB or wireless tethering. For specifics, check the documentation of whichever Linux mobile project you're using.

Tethering Your Phone to Linux: Success!

While smartphones can be used as wireless hotspots for laptops and computers, USB tethering remains useful. Your computer may have a damaged network card, for example, or you may have equipment susceptible to wireless interference.

Ultimately, sharing your phone's mobile internet is a great way to get your Linux PC or any other device online. And if you're concerned about the phone losing charge, the USB cable will ensure it draws power from your PC. It's win-win!