How to reboot the Wi-Fi on Ubuntu?

This is frustrating for some Wi-Fi cards that wares out until reboot.
Here’s a script that you may copy and paste it. Yes I’ll subject you to save it as “wifi-reboot” on this directory /usr/bin/, if you want to make it easier for you if you want.

#!/bin/sh

sudo echo Wi-Fi is rebooting &&
sudo modprobe -r iwlwifi && sleep 10 &&
sudo modprobe iwlwifi &&
sudo echo Wi-Fi established &&
sleep 1 && clear

This solution is a temporary fix because if it happens again then you have to try again over and over, but it doesn’t means it will happen so often, commonly it will take a while.

Yes, Realtek Wi-Fi cards/chips and AMD/Intel Wi-Fi cards/chips are effected by this solution, some Wi-Fi cards/chips like one from Broadcom are not effected very well because of their drivers are based on additional drivers and not proprietary drivers. It’s like NVIDIA GPU drivers are based on additional drivers and AMD/Intel GPU drivers are based on proprietary drivers.

Proprietary drivers are easily effected while additional drivers are not easily effected.
Also, hopefully a developers of Linux Kernel fixes the bug were allows us to reboot iwlwifi again, because on 6.11 iwlwifi will not boot.
Here’s one topic on Ask Ubuntu which it’s related to.

3 Likes

There are other causes like power management being enabled for wifi, you can check with the iwconfig command you may have to copy the wifi interface name wlo1, wlan1, w followed by mac address for USB and run sudo iwconfig {interface name} power off and sudo sed -i 's/wifi.powersave = 3/wifi.powersave = 2/' /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf to fully disable power managament on wifi

3 Likes

Hello @Jeremy31, what about turning it back on entirely?

My way works a lot on Ubuntu with Linux 6.8 (Not 6.11) because some of my devices when I disable Wi-Fi while it wares out I have wait for few seconds until it starts to be disabled and when I turn it back on, again, few seconds until it starts to be enabled and won’t scan for networks and won’t connect to a current network that has been connected to previously until I have to reboot Ubuntu, every time I made that solution I found, it worked (Until it uses Linux Kernel 6.11).
If Ubuntu uses Linux 6.11 my solution that I find can’t turn on iwlwifi but I can use a
Wi-Fi dongle/adapter to connect.

1 Like

Run this in terminal, enter password when asked and when asked to upload press y
Post URL from terminal here

wget -N -t 5 -T 10 https://github.com/UbuntuForums/wireless-info/raw/master/wireless-info && chmod +x wireless-info && ./wireless-info
4 Likes

You could simply put -y rather than manually press y.

But I appreciate the download, however I’m a little concern about downloading packages from GitHub.

1 Like

The link in Jeremy31’s post is not a package, it’s a shell script. In Ubuntu Forums this script is a standard troubleshooting aid to help diagnose networking issues. More information about it here.

If you like, you can copy only up to just before (not including) the first && of that command to only download the script, then you can inspect the text contents of the wireless-info file before actually running it.

3 Likes

Ok, but because downloading files/scripts and/or package from other people on GitHub can be a bit risky (Depending on the users in GitHub, yes be very careful around GitHub. Yes, having a GitHub account is fine). Luckily, creating a script like copy and paste from the something shouldn’t hurt people unless if it is a fake website.

2 Likes

You are correct, I am the original author of that script and it is hosted on Ubuntu Forums GitHub, Jeremy31 is the person that has been maintaining it for quite awhile now and we are both admin of this GitHub page.

4 Likes

if it really is a power saver problem, I usually look here first.

iw wlp4s0 get power_save off
Power save: on
**strong text**

Then to disable it I’ll just use this

sudo iw wlp4s0 set power_save off
[sudo] password for me: 

Recheck with

iw wlp4s0 get power_save off
Power save: off

Hope that is helpful.

3 Likes

This was definitely helpful for me. I had disabled all kind of other power saving features like PCIe power saving, etc but this specific one got past me. I’ve been having a ton of problems with my wifi disconnecting and not reconnecting and I think this solved it.

2 Likes

Looks like NetworkManager was overwriting the configuration I set via iw. I had to edit /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf and set wifi.powersave = 2 then restart NetworkManager. Using iw confirmed that powersave stayed off.

1 Like

I sure would like to know how different hardware handles that, I’ve only had to issue as root

  • sudo iw wlp0s20f3 set power_save off

And across reboots I still have this:

  • inxi -N | grep wifi && iw wlp0s20f3 get power_save off
    Device-1: Intel Comet Lake PCH-LP CNVi WiFi driver: iwlwifi
    Power save: off
2 Likes

Hey @1fallen,

That solution disables the power saver for the Wi-Fi which would help certain Wi-Fi cards/chips on going iffy for the bit or further, disconnects frequently.

:ok_hand:

Hi

I have used that script (wireless-info) on occasions, in opensuse and debian and linuxmint as well as Ubuntu, and it is an excellent piece of “coding”.

I keep a copy in text form on my windows partition, just in case my latest Linux install stalls at the wifi stage.

2 Likes

Cool @johndough, always keep that solution I made for a backup.

Also, welcome to Ubuntu Discourse.

1 Like