View Full Version : Howto: avoid having to reboot!
Heliode
May 15th, 2005, 05:16 PM
I'm starting this howto because a lot of people seem to be under the impression that you have to reboot Ubuntu to get certain changes applied. However, when working with Ubuntu, or Linux in general, it is important to remember that rebooting is a Windows CrazyThing (TM). The only thing you should really have to reboot a Linux machine for is for changes to the kernel. All other things you can reload/restart/whatever at run-time. This is due to the modular nature of the Linux system. Why do you think Unix systems have the highest uptime?
Well anyway, lets get this started. I propose we make this kind of a collaborative effort since i'm by no means an expert (yet) and there's some stuff I don't know. So i'll just add what I do know and we can just add to each others knowledge, ok? Alright then.
The graphical user interface
As most of you know, you can refresh the gnome panel with the command:
killall gnome-panel
However, when screwing around with your Xorg.conf, you have to restart X in order to apply your changes. You can do this with the key combination:
Ctrl+Alt+Backspace
WARNING: This is a very powerful command! It won't ask you if you are sure, or if you would like to save anything you have running; it just shuts off everything in brute force. A more 'civilized' way might be to do '/etc/init.d/gdm restart', but i'm going to need confirmation on that.
Services
A default Ubuntu system has lots of services running. You can get a list of them with:
ls /etc/init.d
For example, lets say you have a samba server running, and you made a change to the samba config file. You can restart samba like this:
sudo /etc/init.d/samba restart
Or if a change has occurred in your network environment (new cable plugged in, interface removed, etc), you could do:
sudo /etc/init.d/networking restart
And so on..
This is all I can think of right now. I'm sure there's lots of other stuff, but in general just remember: rebooting in order to apply stuff is a Windows CrazyThing, and if you feel like you have to do it there is probably a better way.
I encourage anyone to add to this Howto!
Have fun!
Firetech
May 15th, 2005, 05:23 PM
Some quick notes:
1. A lot of the init.d scripts also have a 'reload' action (e.g. "sudo /etc/init.d/samba reload") which just reloads the conf file. All of them doesn't work without restarting the program, but most do.
2. "/etc/init.d/gdm restart" is correct (if you run kubuntu, exchange gdm with kdm). Although, a good thing to do is to press ctrl+alt+backspace after you've logged out. "/etc/init.d/gdm restart" is mostly used for reloading gdm's config.
Anyway, it's a great howto. I would probably had written something like this if you hadn't ;)
Sam
May 15th, 2005, 05:32 PM
Nice howto !
_Pete_
May 17th, 2005, 01:54 AM
Also good trick to really get everything restarted without rebooting is going
to the single user mode (init 1) and then back to the normal runlevel (init 2).
Rodrigo
May 18th, 2005, 12:08 PM
Also good trick to really get everything restarted without rebooting is going
to the single user mode (init 1) and then back to the normal runlevel (init 2).
Why Oh why I didnt think of THAT before ?!?! ](*,)
cool tip
Heliode
May 18th, 2005, 12:24 PM
Also good trick to really get everything restarted without rebooting is going
to the single user mode (init 1) and then back to the normal runlevel (init 2).
That's also a good one! Not recommended if you are running a server people depend upon, but great for workstation users who don't like to wait for their system to reboot!
mr_ed
May 20th, 2005, 12:00 PM
There's one thing that I can't do without rebooting, so far: If I'm connected to the 'net at work, and I pack up my laptop and go home without turning it off, I can't get access to the 'net until I reboot. I've blown away my resolv.conf, did an /etc/init.d/____ restart on every system I could see that looked relevant, and I still can't. Oh well.
Heliode
May 20th, 2005, 12:07 PM
did you try;
sudo /etc/init.d/networking restart
sudo ifdown eth0
sudo ifup eth0
sudo dhclient eth0 (if you're using DHCP)
testingubuntu
May 20th, 2005, 12:11 PM
There's one thing that I can't do without rebooting, so far: If I'm connected to the 'net at work, and I pack up my laptop and go home without turning it off, I can't get access to the 'net until I reboot. I've blown away my resolv.conf, did an /etc/init.d/____ restart on every system I could see that looked relevant, and I still can't. Oh well.
sudo /sbin/service network restart <-- Does that do it?
epb613
June 7th, 2005, 03:03 PM
Same things happens to me on my laptop.
sudo modprobe -r ipw2200
sudo modprobe ipw2200
sudo dhclient eth1 (or whatever your interface is called)
fixes it though.
pdk001
June 7th, 2005, 03:34 PM
thanks a lot. i will try it right away
jerome bettis
June 8th, 2005, 01:37 AM
Also good trick to really get everything restarted without rebooting is going
to the single user mode (init 1) and then back to the normal runlevel (init 2).
what are the commands for #2?
i can get to single user mode with sudo /etc/init.d/single start but i can't figure out how to get back to normal mode ...
jerome bettis
June 8th, 2005, 01:44 AM
also the ipw2200 card does have to be reloaded sometimes (this is a nasty bug that they've been trying to fix for a long time now .. sooner or later it will be gone).
to do this i wrote a simple shell script
sudo rmmod ipw2200
sudo modprobe ipw2200
sudo ifdown eth0
sudo rm /etc/network/interfaces
sudo ln -s /etc/network/interfaces.home /etc/network/interfaces
sudo ifup eth0
that just reloads the module, takes down the interface, and i use different /etc/network/interfaces.* files for the different network enviorments i'm in (have one for home, one for work etc etc) and the third and fourth command remove the symbolic link and link whatever interface file i need at the time. then it brings the interface back up of course.
writing different etc/network/interface files and having different versions of a script like that is the easiest way i've found to manage wireless networks. i can just type home or work or class and the network works great.
sickdude
June 8th, 2005, 04:20 AM
did you try;
sudo /etc/init.d/networking restart
sudo ifdown eth0
sudo ifup eth0
sudo dhclient eth0 (if you're using DHCP)
k thnx dude
i was getting worried because the networking restart doesnt do anything, wel it doesnt refresh the dhcp lease but now i know how :D thnx
used to working with fedora core and red hat so i was typing "service network restart" more often because of frustration ](*,)
Heliode
June 8th, 2005, 09:44 AM
Whoops... can a mod please change
Reload this Page Hotwo: avoid having to reboot!
into
Reload this Page Howto: avoid having to reboot!
?
](*,)
Tobi Vollebregt
June 8th, 2005, 10:07 AM
what are the commands for #2?
i can get to single user mode with sudo /etc/init.d/single start but i can't figure out how to get back to normal mode ...
sudo init 1
sudo init 2
to switch to runlevel 1 and 2 respectively
Ptero-4
July 9th, 2005, 12:15 PM
sudo init 1
sudo init 2
to switch to runlevel 1 and 2 respectively
Actually you don't need to use sudo when going back to runlevel 2 'cause in singleuser you're actually in the root account.
PeteJ
August 23rd, 2005, 04:47 PM
Hi All,
I'm working on a ubuntu hoary 5.04, installed as server only, via ssh command line, with no gui available, on a remote machine, that I don't want to bug the locals to reboot.
3 Questions, if I may:
1) does one _permanently_ set the default route by adding a gateway line to the /etc/networking/interfaces file? ("sudo ip route add default via" wasn't permanent after reboot, ugh, and so my ssh access from the outside external network no longer worked...)
2) /etc/init.d/networking restart drops my remote connection and doesn't bring the interfaces back up (so I have to ask the locals to reboot because I could no longer diagnose the problem). What would cause the connection to permanently drop? Could it be not having a gateway line in the interfaces file? Is there something else wrong with "network restart" in hoary? I'm I missing something else?
3) Is there a lighter way to simply "reload" the interfaces file besides "networking restart"? Would something like "if-down && if-up" be lighter and do the job (remember, I'm working through a remote ssh terminal).
Thanks!
Pete
xinel
August 26th, 2005, 05:10 AM
Also good trick to really get everything restarted without rebooting is going
to the single user mode (init 1) and then back to the normal runlevel (init 2).
How do you do that?
sorry didn't read above, please ignore
joshuapurcell
September 19th, 2005, 10:27 PM
Hi All,
I'm working on a ubuntu hoary 5.04, installed as server only, via ssh command line, with no gui available, on a remote machine, that I don't want to bug the locals to reboot.
3 Questions, if I may:
1) does one _permanently_ set the default route by adding a gateway line to the /etc/networking/interfaces file? ("sudo ip route add default via" wasn't permanent after reboot, ugh, and so my ssh access from the outside external network no longer worked...)
2) /etc/init.d/networking restart drops my remote connection and doesn't bring the interfaces back up (so I have to ask the locals to reboot because I could no longer diagnose the problem). What would cause the connection to permanently drop? Could it be not having a gateway line in the interfaces file? Is there something else wrong with "network restart" in hoary? I'm I missing something else?
3) Is there a lighter way to simply "reload" the interfaces file besides "networking restart"? Would something like "if-down && if-up" be lighter and do the job (remember, I'm working through a remote ssh terminal).
Thanks!
Pete
I've never quite figured this one out, but I don't get disconnected from a server when issuing the network restart command (while connected through telnet or ssh). You would think you'd get disconnected... ifdown eth0 && ifup eth0 should do the trick as well.
Also, I find myself using the networking gui front-end every day a couple of times (when coming and going from work/home). You get to it through this command:
network-admin
You are able to bring your network devices up/down, and change their configuration easily (almost as easily as editing the needed /etc/network/interfaces config file).
EDIT: Speaking of the init comman mentioned above, I've always used that to change the runlevel, but recently I've read about the telinit command. I've heard that it's better to use telinit, but I can't seem to find a difference between the two commands. Anyone have a clue?
doclivingston
September 20th, 2005, 08:03 AM
EDIT: Speaking of the init comman mentioned above, I've always used that to change the runlevel, but recently I've read about the telinit command. I've heard that it's better to use telinit, but I can't seem to find a difference between the two commands. Anyone have a clue?
"telinit N", where N is the runlevel to change to, is the canonical way - however "init N" works fine too (although there may be Unixes where it doesn't work).
zigford
September 27th, 2005, 05:07 PM
Hi All,
I'm working on a ubuntu hoary 5.04, installed as server only, via ssh command line, with no gui available, on a remote machine, that I don't want to bug the locals to reboot.
3 Questions, if I may:
1) does one _permanently_ set the default route by adding a gateway line to the /etc/networking/interfaces file? ("sudo ip route add default via" wasn't permanent after reboot, ugh, and so my ssh access from the outside external network no longer worked...)
2) /etc/init.d/networking restart drops my remote connection and doesn't bring the interfaces back up (so I have to ask the locals to reboot because I could no longer diagnose the problem). What would cause the connection to permanently drop? Could it be not having a gateway line in the interfaces file? Is there something else wrong with "network restart" in hoary? I'm I missing something else?
3) Is there a lighter way to simply "reload" the interfaces file besides "networking restart"? Would something like "if-down && if-up" be lighter and do the job (remember, I'm working through a remote ssh terminal).
Thanks!
Pete
Pete,
1. On my ubuntu setup I have a bridged network which the graphical utility cannot understand, so I am forced to use the /etc/network/interfaces file. To add a default gateway in this is easy.
iface eth0 inet static
address 192.168.1.2
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
2. When restarting network from remote I have also had the problem you describe. I believe it is because when you loose connectivity, linux no longer can process the command because it looses its output.
There is a handy program called "screen" It acts like a buffer between your shell and the output display. Think of it like VNC for ssh/telnet. (You can disconnect from it and your application stays running.
This is how it works for me:
ssh -l user somewhere.com
# screen
# /etc/init.d/network restart
----Disconnected----
ssh -l user somewhere.com
# screen -r (This re-attaches me to a running screen)
_Pete_
September 28th, 2005, 01:06 AM
That's also a good one! Not recommended if you are running a server people depend upon, but great for workstation users who don't like to wait for their system to reboot!
That's the reason for wall command:
# echo "**** off" | wall && init 1
:)
encompass
January 2nd, 2006, 11:17 AM
The tweak firefox link is down. But there is another thread that does what you say... search for 'diggity' and find the firefox link. Just trust me... that is how I remembered to find it.
jonrkc
May 24th, 2006, 05:47 AM
If you make changes to /etc/fstab you can test or implement them right away without rebooting by simply doing:
sudo mount
Giga
June 27th, 2006, 09:56 PM
First of all, thanks for the tips (the "HOWTO backup" is awesome).
Why both of the lines does not do the same job?
I mean.. both of the lines should do the same thing, isnt it?
oem@ubuntu:/etc/init.d$ sudo networking restart
sudo: networking: command not found
and this dont:
oem@ubuntu:/etc/init.d$ sudo /etc/init.d/networking restart
I know its a tipic roockie question, but you know...:confused:
networking is a service running.. and Bash interprets like as a command, this is why i got command not found. Right?
But why bash does not interpret when i put all the path along with?
Thx
jonrkc
June 28th, 2006, 02:23 AM
Networking isn't a command, but a service run at boot time. The script for it is located in /etc/init.d, and the way to restart is it
sudo /etc/init.d/networking restart
This kind of "command" will work for any service, by the way...as far as I know. It's handy to restart, or to stop, or start, a service sometimes as a way of troubleshooting--for example, when there's no sound. (But this evening the main trouble was that I had my headphones plugged into the wrong outlet, and it took me an hour to find out.) :?
The "restart" isn't a command recognized by bash but a special function associated with the scripts in init.d. With "sudo networking restart" bash interprets the word immediately after "sudo" as referring to a command--but that command doesn't exist. When a PATH follows "sudo," bash knows something special's going on: Either a command is coming up that is executed out of the directory being stated, or a special function. So there's no error message as long as either a command or a special function follows the path statement.
ethoslite
March 22nd, 2007, 11:05 PM
I have read through this thread and found the howto and follow up posts informative. I do have a question regarding performance, relating to memory.
I've noticed when I have multiple applications open, performance of course decreases somewhat because the available hardware memory is being minimized. Ok, well if I close many of these and leave a few open, will the memory being used from those programs be cleanly released back into availability?
As well, is it a good practice to periodically Ctrl-Alt-Backspace, just because, or is it only necessary after applied config or update changes?
Thanks ;)
amd-64
June 7th, 2007, 10:49 PM
These do the job for me
sudo modprobe --force ndiswrapper
sudo ifup --force eth1
no need to unload and reload.
Greedo
June 17th, 2008, 08:14 PM
After reading this thread, somebody might have a solution for one of the reasons I reboot my hardy workstation almost once a day.
It seems like if I ever watch a video which is flash encoded then all my sound drivers are messed up except those for real player until I reboot. Totem will no longer play any sounds, nor will VLC until I restart my system. Does some body have a command line that could fix my sound issue(s) without rebooting?
dragoonx
July 23rd, 2008, 01:10 PM
After reading this thread, somebody might have a solution for one of the reasons I reboot my hardy workstation almost once a day.
It seems like if I ever watch a video which is flash encoded then all my sound drivers are messed up except those for real player until I reboot. Totem will no longer play any sounds, nor will VLC until I restart my system. Does some body have a command line that could fix my sound issue(s) without rebooting?
I don't know if it is the same case but what I do when this happens, I just type in terminal:
killall pulseaudio
Somehow, pulseaudio interferes with my Rhythmbox, Totem, and all the other multimedia stuff I run that needs sounds.
Again, I'm not sure if we have the same case.
panickedthumb
July 23rd, 2008, 02:46 PM
Whoops... can a mod please change
Reload this Page Hotwo: avoid having to reboot!
into
Reload this Page Howto: avoid having to reboot!
?
](*,)
Yep! Although this is over a year late.
Unanimated
November 4th, 2008, 06:42 PM
Pretty nice guide - I'll probably have to use it every once in a while.
halovivek
December 19th, 2008, 06:16 AM
Thanks for posting
H4F
March 29th, 2009, 06:29 PM
Thanks nice posts.
How do I avoid rebooting because of changes to the config files of kernel modules ?
Ex. after changind /etc/modprobe/alsa* I have to restart .
trying to reload snd_hda_intel
modprobe -r snd_hda_intel
FATAL: Module snd_hda_intel is in use.
??
Skip Da Shu
May 22nd, 2009, 12:12 AM
Yep! Although this is over a year late.
Yea but it got thousands of hit from folks looking for Hotwomen... LOL
learning_
May 15th, 2010, 02:00 AM
Also good trick to really get everything restarted without rebooting is going
to the single user mode (init 1) and then back to the normal runlevel (init 2).
how do you do this? im just starting out, learning as i go along. that seems very very usefull, but i dont know how to do it.
also didnt read above. just ignore this please
Nicholas Buckner
May 17th, 2010, 03:34 PM
meh, my ubuntu boots up so fast that this doesn't really bother me :) beats windows 7 booting up in 1 min:mad:
srnissen
August 29th, 2010, 09:23 AM
There is a thing I have to reboot for, actually: Every so often, my keyboard stops responding. ... yeah.
d3v1150m471c
March 29th, 2011, 01:28 AM
lol i'd never reboot this machine if it wasn't for kernel updates. I've been wanting to see if i could leave it running for over a month total time but those horrible developers keep making my system better. :)
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.