close
close

How to Use Terminal to Fix Wi-Fi Problems in Linux

How to Use Terminal to Fix Wi-Fi Problems in Linux

  • Linux users can fix most Wi-Fi problems using terminal commands without needing to download software.

  • Resetting your IP address or network interface with terminal commands can fix common Wi-Fi problems.

  • If the problem persists, contact your internet service provider for assistance.

If you’re having trouble with your Wi-Fi, this is probably an easy fix. If you’re using a Linux machine, this is even easier as you can fix most common Wi-Fi problems with some quick terminal commands, no need to download software.

If you’re new to the terminal or even Linux as a whole, don’t worry, because you won’t be able to do any permanent damage to your systems. Actually, you shouldn’t be afraid of the terminal because that’s where the power of Linux lies, as you’ll soon see.

Releasing and Renewing Your IP Address

Usually when you experience Wi-Fi issues it is because there are issues with your device. IP addressa set of numbers that identify your online location. There may be dozens of reasons for this, but fortunately the solution is always the same, namely resetting your IP address.

To do this, you first need to know your current IP address. You can do this using the following command:

ip address

Alternatively, some Linux distributions allow you to do this in the desktop environment; Check out our article: How to find your IP address in Ubuntu.

Although it is not necessary, you may want to make a note of this IP address as we will need to check if it has been changed after we are done.

Next we need to request a new IP address through your DHCP server. We have a complete explainer What is DHCPbut the short version is that it is a protocol that manages IP assignments. It usually does this on a daily basis, so your network gets a new IP every 24 hours. What we’re going to do is ask if we can renew now.

To do this, you need a program called dhclient, which is installed by default on Linux systems. To make sure you get some output, run the “verbose” command (-v) to find out what your system is currently running:

sudo dhclient -v

Detailed output from Dhclient.

This lets you know which IP was requested (DHCPREQUEST) and when it will expire (in my case 40157 seconds from now, so about 11 hours).

Now we need to release the IP address, which means we ask dhclient to trash the IP address. This is done with the -r command, and I recommend adding another “verbose” command to see what happens:

sudo dhclient -v -r

We release your IP in dhclient.

After doing this, request a new IP address with the same command as before:

sudo dhclient

Now all you have to do is enjoy your new IP address.

Resetting Network Settings

Sometimes renewing the IP address may not be enough. The next thing you can try is to completely reset your network interface in the hope that the setting causing the problem will be returned to its default state.

To do this we will use a program called ip. This is a very powerful tool that allows you to control the network on your device. We have a full guide on using the ip commandbut for now we only need three commands.

The first is to show the interfaces available on your device. To do this, type:

ip link show

Exited from ip command.

You will get a list of interfaces. For most people it’s the latter (enp0s3 in my case), so let’s try resetting it first. To do this, you need to close the interface:

sudo ip link set <interface_name> down

This will close it, you can check it with the “link show” command before.

The interface is closed with the IP command.

Now you can open the interface again:

sudo ip link set <interface_name> up

ip interface restored.

Still Can’t Solve Your Wi-Fi Problems?

In most cases, these two fixes will mean the end of any problems you may be experiencing with your Wi-Fi connection. But if this is not the case The problem may be at your internet service provider’s (ISP) end. We recommend that you contact them and check if there are any problems with the internet in your location.