LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-21-2016, 02:49 PM   #1
d_K
Member
 
Registered: Aug 2016
Posts: 32

Rep: Reputation: Disabled
Question Ubuntu 16.04: can I "delay" starting the network manager service?


I have unresolved wifi issues on 16.04. However, on every boot,
Code:
sudo systemctl restart network-manager.service
usually solves my issue. I'm wondering if simply delaying the service might work...if delaying is not possible, then I'll just use a script like this to restart it and put it in my "startup applications" list:

Code:
#!/bin/bash 
sleep 20 && systemctl restart network-manager.service
...the problem there however: restarting a service needs root privileges...maybe just put in cron with "@reboot", I'd rather not have to type out my pw on every reboot.
 
Old 12-22-2016, 08:42 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Quote:
Originally Posted by d_K View Post
...the problem there however: restarting a service needs root privileges...maybe just put in cron with "@reboot", I'd rather not have to type out my pw on every reboot.
You can add a line to /etc/sudoers to allow you to restart the service without needing a password. Obviously some caution is needed when editing the sudoers file. Use visudo to add the following to the tail end of sudoers for the user "dk" as a line by itself:

Code:
dk    ALL=(root:root) NOPASSWD: /bin/systemctl restart network-manager.service
Read the manual page for sudoers to see the meaning and, again, be sure to use visudo to ensure that at least the syntax is correct.

Then the code in your script could be the following:

Code:
#!/bin/sh 
sleep 20
sudo /bin/systemctl restart network-manager.service


About changing the boot order, changing the boot order in systemd seems (to me) to be a tangled mess. You'll have to get an overview by generating a graph using systemd-analyze plot > startup.svg and then examining the resulting file startup.svg to see where network-manager.service might possibly be moved. Then fiddle with the value for "After=" in the network-manager.service file.
 
1 members found this post helpful.
Old 12-22-2016, 06:54 PM   #3
d_K
Member
 
Registered: Aug 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by Turbocapitalist View Post
You can add a line to /etc/sudoers to allow you to restart the service without needing a password. Obviously some caution is needed when editing the sudoers file. Use visudo to add the following to the tail end of sudoers for the user "dk" as a line by itself:

Code:
dk    ALL=(root:root) NOPASSWD: /bin/systemctl restart network-manager.service
Read the manual page for sudoers to see the meaning and, again, be sure to use visudo to ensure that at least the syntax is correct.

Then the code in your script could be the following:

Code:
#!/bin/sh 
sleep 20
sudo /bin/systemctl restart network-manager.service
Thanks, this worked. The sudoers file did mention this:
Code:
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
...but I'm assuming "local content" isn't applicable here.

I also forgot about that pasting in nano works the same way in terminal (ctrl+shift+v), and that text buffering pasting also works here too (middle mouse button or shift+insert). And now I know why Neo did a ctrl+x to get rid of "wake up Neo, follow the white rabbit."
 
Old 12-23-2016, 12:51 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,295
Blog Entries: 3

Rep: Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719Reputation: 3719
Quote:
Originally Posted by d_K View Post
Thanks, this worked. The sudoers file did mention this:
Code:
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
...but I'm assuming "local content" isn't applicable here.
It could go in either place. The advantage of having your additions in a separate file is that automated updates to the main file can be done more easily. So I can see why they've started to suggest that approach. But either way works. I just suggested using the main file out of inertia.

If you want a quick overview of what your account is allowed via sudo, try it with the -l option.

Code:
sudo -l
sudo -ll
That will parse the configuration file and show a summary of what you can do.
 
  


Reply

Tags
network-manager, systemd, ubuntu, wifi



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting "SIOCADDRT: No such process" when running "service network restart" cmlorentz Linux - Networking 1 11-26-2010 01:06 PM
"ping" shows different delay from two computer on the same network ufmale Linux - Networking 2 07-21-2010 09:19 AM
"not starting internet supersaver no service enabled" john83reuben Linux - Newbie 0 10-13-2007 06:03 AM
Logs filling up with "smbd/service.c:make_connection" - "couldn't find service" DumbTerminal Linux - Networking 14 07-16-2007 06:33 AM
Problem starting, needed service "Netmount" not started The_fuzzy_cow Linux - Hardware 1 07-26-2004 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration