Ubuntu – Script to Restart Network Manager after Resume from Sleep

hibernatenetworkingsuspend

When my laptop resumes from sleep, the wifi connection doesn't resume and I have to manually restart network manager every time with sudo service network-manager restart from terminal.

I had a script that did that, but it prevented the PC from properly resuming from sleep so I had to remove it.

Best Answer

You should be able to create a script in the /etc/pm/sleep.d/ directory (or supposedly the /lib/systemd/system-sleep/ directory if you are running 15.10+) which executes that restart command on system resume. Make sure to make that script executable.

  1. Create a network_restart file in said directory with these contents:

    case "${1}" in
      resume|thaw)
        sudo service network-manager restart
    ;;
    esac
    
  2. Make the file executable: sudo chmod +x network_restart
Related Question