How to restart the Network Manager in 16.04 whenever Wi-fi is enabled?












0















Is there a way to restart the Network manager every time I check the "Enable Wi-fi" from the applet's dropdown menu?










share|improve this question


















  • 1





    Well , technically there is a command, but requires sudo. Why exactly do you need to restart it ? What's the underlying issue ?

    – Sergiy Kolodyazhnyy
    Oct 6 '16 at 1:07











  • I've noticed that if I disable and then re-enable wifi from the dropdown menu the applet will display the wrong type of connection (usually ethernet, or sometimes nothing at all), thus preventing me from seeing what hotspots are available; restarting the network manager solves the issue though.

    – user525303
    Oct 6 '16 at 1:58
















0















Is there a way to restart the Network manager every time I check the "Enable Wi-fi" from the applet's dropdown menu?










share|improve this question


















  • 1





    Well , technically there is a command, but requires sudo. Why exactly do you need to restart it ? What's the underlying issue ?

    – Sergiy Kolodyazhnyy
    Oct 6 '16 at 1:07











  • I've noticed that if I disable and then re-enable wifi from the dropdown menu the applet will display the wrong type of connection (usually ethernet, or sometimes nothing at all), thus preventing me from seeing what hotspots are available; restarting the network manager solves the issue though.

    – user525303
    Oct 6 '16 at 1:58














0












0








0








Is there a way to restart the Network manager every time I check the "Enable Wi-fi" from the applet's dropdown menu?










share|improve this question














Is there a way to restart the Network manager every time I check the "Enable Wi-fi" from the applet's dropdown menu?







network-manager






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 6 '16 at 0:34







user525303















  • 1





    Well , technically there is a command, but requires sudo. Why exactly do you need to restart it ? What's the underlying issue ?

    – Sergiy Kolodyazhnyy
    Oct 6 '16 at 1:07











  • I've noticed that if I disable and then re-enable wifi from the dropdown menu the applet will display the wrong type of connection (usually ethernet, or sometimes nothing at all), thus preventing me from seeing what hotspots are available; restarting the network manager solves the issue though.

    – user525303
    Oct 6 '16 at 1:58














  • 1





    Well , technically there is a command, but requires sudo. Why exactly do you need to restart it ? What's the underlying issue ?

    – Sergiy Kolodyazhnyy
    Oct 6 '16 at 1:07











  • I've noticed that if I disable and then re-enable wifi from the dropdown menu the applet will display the wrong type of connection (usually ethernet, or sometimes nothing at all), thus preventing me from seeing what hotspots are available; restarting the network manager solves the issue though.

    – user525303
    Oct 6 '16 at 1:58








1




1





Well , technically there is a command, but requires sudo. Why exactly do you need to restart it ? What's the underlying issue ?

– Sergiy Kolodyazhnyy
Oct 6 '16 at 1:07





Well , technically there is a command, but requires sudo. Why exactly do you need to restart it ? What's the underlying issue ?

– Sergiy Kolodyazhnyy
Oct 6 '16 at 1:07













I've noticed that if I disable and then re-enable wifi from the dropdown menu the applet will display the wrong type of connection (usually ethernet, or sometimes nothing at all), thus preventing me from seeing what hotspots are available; restarting the network manager solves the issue though.

– user525303
Oct 6 '16 at 1:58





I've noticed that if I disable and then re-enable wifi from the dropdown menu the applet will display the wrong type of connection (usually ethernet, or sometimes nothing at all), thus preventing me from seeing what hotspots are available; restarting the network manager solves the issue though.

– user525303
Oct 6 '16 at 1:58










3 Answers
3






active

oldest

votes


















2














I know this is an old thread, but on my older laptop I had a pretty crappy WiFi card which had a tendency to disconnect from the WiFi if there was a lot of load (e.g., downloading large files, etc.).



I ended up creating a simple script to check if my internet was still connected, and if it wasn't, then restart the network manager.



#!/bin/bash

ping -c 1 8.8.8.8
received=$?
echo $received
if [[ $received -ne 0 ]] ; then
service network-manager restart
fi


I created a root cronjob with sudo crontab -e, and set it such that every minute (you can do it more less frequently, but the script is a simple ping so it isn't resource intensive) it would run the script.



So, if my WiFi did go out for some reason, it would only ever be out for about a minute at a time, tops. If you're unfamiliar with cron, I recommend reading this






share|improve this answer





















  • 1





    Welcome to Ask Ubuntu and although it's an old thread, it's better than the other answers, so +1 for that. OTOH, if you want to point people to cron help, better send them on this site, so I've edited that.

    – Fabby
    Jun 12 '18 at 17:43











  • I had to write /usr/sbin/service instead of service. Also, the crontab expression you're looking for is */1 * * * * /home/your_user/restart_network_if_needed.sh assuming that's where you copy-pasted the above script

    – ihadanny
    Dec 17 '18 at 6:05



















2














press alt+f2 to get a run dialog



in the run dialog type:



systemctl network-manager restart 


You should then provide your password when prompted.






share|improve this answer


























  • Thank you for your answer. Is there a way, however, to automate the process, for example through a script?

    – user525303
    Oct 8 '16 at 4:01



















1














in a terminal (Ctrl-Alt-t), sudo systemctl restart NetworkManager should do the trick.



However, you can split it into stop and start command



sudo systemctl stop NetworkManager
sudo systemctl start NetworkManager





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f833604%2fhow-to-restart-the-network-manager-in-16-04-whenever-wi-fi-is-enabled%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown
























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I know this is an old thread, but on my older laptop I had a pretty crappy WiFi card which had a tendency to disconnect from the WiFi if there was a lot of load (e.g., downloading large files, etc.).



    I ended up creating a simple script to check if my internet was still connected, and if it wasn't, then restart the network manager.



    #!/bin/bash

    ping -c 1 8.8.8.8
    received=$?
    echo $received
    if [[ $received -ne 0 ]] ; then
    service network-manager restart
    fi


    I created a root cronjob with sudo crontab -e, and set it such that every minute (you can do it more less frequently, but the script is a simple ping so it isn't resource intensive) it would run the script.



    So, if my WiFi did go out for some reason, it would only ever be out for about a minute at a time, tops. If you're unfamiliar with cron, I recommend reading this






    share|improve this answer





















    • 1





      Welcome to Ask Ubuntu and although it's an old thread, it's better than the other answers, so +1 for that. OTOH, if you want to point people to cron help, better send them on this site, so I've edited that.

      – Fabby
      Jun 12 '18 at 17:43











    • I had to write /usr/sbin/service instead of service. Also, the crontab expression you're looking for is */1 * * * * /home/your_user/restart_network_if_needed.sh assuming that's where you copy-pasted the above script

      – ihadanny
      Dec 17 '18 at 6:05
















    2














    I know this is an old thread, but on my older laptop I had a pretty crappy WiFi card which had a tendency to disconnect from the WiFi if there was a lot of load (e.g., downloading large files, etc.).



    I ended up creating a simple script to check if my internet was still connected, and if it wasn't, then restart the network manager.



    #!/bin/bash

    ping -c 1 8.8.8.8
    received=$?
    echo $received
    if [[ $received -ne 0 ]] ; then
    service network-manager restart
    fi


    I created a root cronjob with sudo crontab -e, and set it such that every minute (you can do it more less frequently, but the script is a simple ping so it isn't resource intensive) it would run the script.



    So, if my WiFi did go out for some reason, it would only ever be out for about a minute at a time, tops. If you're unfamiliar with cron, I recommend reading this






    share|improve this answer





















    • 1





      Welcome to Ask Ubuntu and although it's an old thread, it's better than the other answers, so +1 for that. OTOH, if you want to point people to cron help, better send them on this site, so I've edited that.

      – Fabby
      Jun 12 '18 at 17:43











    • I had to write /usr/sbin/service instead of service. Also, the crontab expression you're looking for is */1 * * * * /home/your_user/restart_network_if_needed.sh assuming that's where you copy-pasted the above script

      – ihadanny
      Dec 17 '18 at 6:05














    2












    2








    2







    I know this is an old thread, but on my older laptop I had a pretty crappy WiFi card which had a tendency to disconnect from the WiFi if there was a lot of load (e.g., downloading large files, etc.).



    I ended up creating a simple script to check if my internet was still connected, and if it wasn't, then restart the network manager.



    #!/bin/bash

    ping -c 1 8.8.8.8
    received=$?
    echo $received
    if [[ $received -ne 0 ]] ; then
    service network-manager restart
    fi


    I created a root cronjob with sudo crontab -e, and set it such that every minute (you can do it more less frequently, but the script is a simple ping so it isn't resource intensive) it would run the script.



    So, if my WiFi did go out for some reason, it would only ever be out for about a minute at a time, tops. If you're unfamiliar with cron, I recommend reading this






    share|improve this answer















    I know this is an old thread, but on my older laptop I had a pretty crappy WiFi card which had a tendency to disconnect from the WiFi if there was a lot of load (e.g., downloading large files, etc.).



    I ended up creating a simple script to check if my internet was still connected, and if it wasn't, then restart the network manager.



    #!/bin/bash

    ping -c 1 8.8.8.8
    received=$?
    echo $received
    if [[ $received -ne 0 ]] ; then
    service network-manager restart
    fi


    I created a root cronjob with sudo crontab -e, and set it such that every minute (you can do it more less frequently, but the script is a simple ping so it isn't resource intensive) it would run the script.



    So, if my WiFi did go out for some reason, it would only ever be out for about a minute at a time, tops. If you're unfamiliar with cron, I recommend reading this







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 12 '18 at 17:44









    Fabby

    27k1360161




    27k1360161










    answered Jun 12 '18 at 17:17









    garzaigarzai

    563




    563








    • 1





      Welcome to Ask Ubuntu and although it's an old thread, it's better than the other answers, so +1 for that. OTOH, if you want to point people to cron help, better send them on this site, so I've edited that.

      – Fabby
      Jun 12 '18 at 17:43











    • I had to write /usr/sbin/service instead of service. Also, the crontab expression you're looking for is */1 * * * * /home/your_user/restart_network_if_needed.sh assuming that's where you copy-pasted the above script

      – ihadanny
      Dec 17 '18 at 6:05














    • 1





      Welcome to Ask Ubuntu and although it's an old thread, it's better than the other answers, so +1 for that. OTOH, if you want to point people to cron help, better send them on this site, so I've edited that.

      – Fabby
      Jun 12 '18 at 17:43











    • I had to write /usr/sbin/service instead of service. Also, the crontab expression you're looking for is */1 * * * * /home/your_user/restart_network_if_needed.sh assuming that's where you copy-pasted the above script

      – ihadanny
      Dec 17 '18 at 6:05








    1




    1





    Welcome to Ask Ubuntu and although it's an old thread, it's better than the other answers, so +1 for that. OTOH, if you want to point people to cron help, better send them on this site, so I've edited that.

    – Fabby
    Jun 12 '18 at 17:43





    Welcome to Ask Ubuntu and although it's an old thread, it's better than the other answers, so +1 for that. OTOH, if you want to point people to cron help, better send them on this site, so I've edited that.

    – Fabby
    Jun 12 '18 at 17:43













    I had to write /usr/sbin/service instead of service. Also, the crontab expression you're looking for is */1 * * * * /home/your_user/restart_network_if_needed.sh assuming that's where you copy-pasted the above script

    – ihadanny
    Dec 17 '18 at 6:05





    I had to write /usr/sbin/service instead of service. Also, the crontab expression you're looking for is */1 * * * * /home/your_user/restart_network_if_needed.sh assuming that's where you copy-pasted the above script

    – ihadanny
    Dec 17 '18 at 6:05













    2














    press alt+f2 to get a run dialog



    in the run dialog type:



    systemctl network-manager restart 


    You should then provide your password when prompted.






    share|improve this answer


























    • Thank you for your answer. Is there a way, however, to automate the process, for example through a script?

      – user525303
      Oct 8 '16 at 4:01
















    2














    press alt+f2 to get a run dialog



    in the run dialog type:



    systemctl network-manager restart 


    You should then provide your password when prompted.






    share|improve this answer


























    • Thank you for your answer. Is there a way, however, to automate the process, for example through a script?

      – user525303
      Oct 8 '16 at 4:01














    2












    2








    2







    press alt+f2 to get a run dialog



    in the run dialog type:



    systemctl network-manager restart 


    You should then provide your password when prompted.






    share|improve this answer















    press alt+f2 to get a run dialog



    in the run dialog type:



    systemctl network-manager restart 


    You should then provide your password when prompted.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Oct 7 '16 at 12:16









    Amias

    4,2841329




    4,2841329










    answered Oct 7 '16 at 10:52









    JessieJessie

    211




    211













    • Thank you for your answer. Is there a way, however, to automate the process, for example through a script?

      – user525303
      Oct 8 '16 at 4:01



















    • Thank you for your answer. Is there a way, however, to automate the process, for example through a script?

      – user525303
      Oct 8 '16 at 4:01

















    Thank you for your answer. Is there a way, however, to automate the process, for example through a script?

    – user525303
    Oct 8 '16 at 4:01





    Thank you for your answer. Is there a way, however, to automate the process, for example through a script?

    – user525303
    Oct 8 '16 at 4:01











    1














    in a terminal (Ctrl-Alt-t), sudo systemctl restart NetworkManager should do the trick.



    However, you can split it into stop and start command



    sudo systemctl stop NetworkManager
    sudo systemctl start NetworkManager





    share|improve this answer




























      1














      in a terminal (Ctrl-Alt-t), sudo systemctl restart NetworkManager should do the trick.



      However, you can split it into stop and start command



      sudo systemctl stop NetworkManager
      sudo systemctl start NetworkManager





      share|improve this answer


























        1












        1








        1







        in a terminal (Ctrl-Alt-t), sudo systemctl restart NetworkManager should do the trick.



        However, you can split it into stop and start command



        sudo systemctl stop NetworkManager
        sudo systemctl start NetworkManager





        share|improve this answer













        in a terminal (Ctrl-Alt-t), sudo systemctl restart NetworkManager should do the trick.



        However, you can split it into stop and start command



        sudo systemctl stop NetworkManager
        sudo systemctl start NetworkManager






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 7 '16 at 10:57









        solsTiCesolsTiCe

        6,25332050




        6,25332050






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f833604%2fhow-to-restart-the-network-manager-in-16-04-whenever-wi-fi-is-enabled%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            GameSpot

            日野市

            Tu-95轟炸機