How to permanently set Wi-Fi "power management" flag to off?

I've installed a fresh Ubuntu 20.04, and it had problems with wireless network - it was terribly slow. Fortunately, I managed to find the problem: power management.

sudo iwcibfug

wlp0s20f3 IEEE 802.11  ESSID:"SmellsLikeWireless"  
          Mode:Managed  Frequency:2.457 GHz  Access Point: 11:A1:B1:01:D1:11   
          Bit Rate=144.4 Mb/s   Tx-Power=22 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=70/70  Signal level=-37 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:2640   Missed beacon:0

The fix:
sudo iwconfig wlp0s20f3 power off

and now the power management flag is set to off:

Power Management:off

and Wi-Fi speed is great.

However, when the laptop goes to sleep, the power management flag is again set to on. How do I permanently set it to off?


Solution 1:

Please check your current power save state:

cat /etc/NetworkManager/conf.d/*.conf

Unless it has been previously changed, it should read:

[connection]
wifi.powersave = 3

In this context, 3 indicates that the Network Manager will use power saving. Let's change it to 2, indicating that the system will not use power saving. From the terminal:

sudo sed -i 's/3/2/' /etc/NetworkManager/conf.d/*
sudo systemctl restart NetworkManager.service