<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>gHacks Technology News &#124; Latest Tech News, Software And Tutorials &#187; rc.local</title> <atom:link href="http://www.ghacks.net/tag/rclocal/feed/" rel="self" type="application/rss+xml" /><link>http://www.ghacks.net</link> <description>A technology news blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description> <lastBuildDate>Sat, 11 Feb 2012 09:52:46 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>Starting services at boot in Linux</title><link>http://www.ghacks.net/2009/11/04/starting-services-at-boot-in-linux/</link> <comments>http://www.ghacks.net/2009/11/04/starting-services-at-boot-in-linux/#comments</comments> <pubDate>Wed, 04 Nov 2009 17:25:40 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[boot services]]></category> <category><![CDATA[init]]></category> <category><![CDATA[linux boot]]></category> <category><![CDATA[rc.local]]></category> <category><![CDATA[runlevels]]></category> <category><![CDATA[sysV]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=18116</guid> <description><![CDATA[There are plenty of times when you may want to add a new service to start when your Linux machine boots. Or you may want to stop a service from starting upon boot. And, like nearly every aspect of Linux, there are many ways to deal with this scenario. And different distributions handle this in [...]]]></description> <content:encoded><![CDATA[<p>There are plenty of times when you may want to add a new service to start when your Linux machine boots. Or you may want to stop a service from starting upon boot. And, like nearly every aspect of Linux, there are many ways to deal with this scenario. And different distributions handle this in different ways. So what is the best way for you to manage this task?</p><p>Because different distributions handle this task differently, we will examine how Fedora (and friends) handle the task and how Ubuntu (and friends) handle the task. As well we will also examine a neutral method that can always work in a pinch. All three methods will be command line, so stretch out those fingers and get ready to type.</p><p><span
id="more-18116"></span><strong>Fedora (and friends)</strong></p><p>The Fedora distribution uses the <em>chkconfig</em> command to update and query system run-level information for system services. The usage of this command is:</p><p><em>chkconfig OPTIONS SERVICE ON/OF</em></p><p>Where:</p><ul><li><span
style="background-color: #ffffff">OPTIONS are the various options the command offers.</span></li><li><span
style="background-color: #ffffff">SERVICE is the service you want to add at startup.</span></li><li><span
style="background-color: #ffffff">ON/OFF is either on or off &#8211; depending on if you want the s<span
style="background-color: #ffffff">ervice to start or not.</span></span></li></ul><p><span
style="background-color: #ffffff">The confusion with the <em>chkconfig </em>command generally boils down to runlevel. The typical Linux runlevels are:</span></p><ul><li><span
style="background-color: #ffffff">0 &#8211; Halt</span></li><li><span
style="background-color: #ffffff">1 &#8211; Single user mode</span></li><li><span
style="background-color: #ffffff">2 &#8211; Multi user mode</span></li><li><span
style="background-color: #ffffff">3 &#8211; Multi user mode with networking</span></li><li><span
style="background-color: #ffffff">4 &#8211; Not used</span></li><li><span
style="background-color: #ffffff">5 &#8211; X11</span></li><li><span
style="background-color: #ffffff">6 &#8211; Reboot</span></li></ul><p><span
style="background-color: #ffffff">So with <em>chkconfig </em>you can also define at which point the service starts. So let&#8217;s say you want Apache to start at boot and you want it to start for levels 3, 4, and 5. For this you would issue the command (as the root user):</span></p><p><span
style="background-color: #ffffff"><em>chkconfig &#8211;level 345 httpd on</em></span></p><p><span
style="background-color: #ffffff">Now, if you don&#8217;t want Apache to run at boot you could issue the command:</span></p><p><span
style="background-color: #ffffff"><em>chkconfig httpd off</em></span></p><p><span
style="background-color: #ffffff">If you want to know what services are running at boot you can issue the command:</span></p><p><span
style="background-color: #ffffff"><em>chkconfig &#8211;list</em></span></p><p><span
style="background-color: #ffffff">The above command will list out all services that are starting at boot time.</span></p><p><span
style="background-color: #ffffff"><strong>Ubuntu (and friends)</strong></span></p><p><span
style="background-color: #ffffff">Ubuntu (and friends) takes a totally different route to the same destination. Instead of using <em>chkconfig </em>Ubuntu uses the <em>update-rc.d</em> command. This command makes things pretty simple. The command structure is:</span></p><p><em>update-rc.d SERVICE OPTIONS</em></p><p>Where OPTIONS are available options and SERVICE is the service you want to start.</p><p>With <em>update-rc.d</em> there is an option that makes it simple: <em>defaults.</em> So to add sshd to the start up process, you would issue the command:</p><p><em>sudo update-rc.d sshd defaults</em></p><p>To remove the same service from start up you would issue the following command:</p><p><em>sudo update-rc.d sshd remove</em></p><p>Now let&#8217;s take a look at a fail safe, nearly-universal method</p><p><strong>rc.local</strong></p><p>There is another means of getting a service to start. I recommend using either of the two above before you try this means. The <strong>rc.local</strong> file is a file that is executed at the end of the multiuser runlevel. By default, this script does nothing, but you can add to it so that it does.</p><p>Say you want Apache to start at boot up, and you want to do so from <strong>rc.local</strong>. You can do this by adding one of the following lines at the end of your <strong>/etc/rc.local</strong> file.</p><p>Fedora:</p><p><em>/etc/init.d/rc.d/httpd star</em>t</p><p>Ubuntu:</p><p><em>/etc/init.d/apache2 start</em></p><p>Save that file and you should be good to go. If you change your mind and do not want that service to start at boot, just remove the line you added.</p><p><strong>Final thoughts</strong></p><p>The above should allow you get that service that needs to start at boot working correctly. Make sure, however, you use the distribution-prescribed method before you use the <strong>rc.local</strong> method.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/11/04/starting-services-at-boot-in-linux/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Get To Know Linux: The /etc/init.d Directory</title><link>http://www.ghacks.net/2009/04/04/get-to-know-linux-the-etcinitd-directory/</link> <comments>http://www.ghacks.net/2009/04/04/get-to-know-linux-the-etcinitd-directory/#comments</comments> <pubDate>Sat, 04 Apr 2009 19:54:02 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[init]]></category> <category><![CDATA[init.d]]></category> <category><![CDATA[rc.local]]></category> <category><![CDATA[system startup]]></category> <guid
isPermaLink="false">http://www.ghacks.net/?p=11663</guid> <description><![CDATA[If you use Linux you most likely have heard of the init.d directory. But what exactly does this directory do? It ultimately does one thing but it does that one thing for your entire system, so init.d is very important. The init.d directory contains a number of start/stop scripts for various services on your system. [...]]]></description> <content:encoded><![CDATA[<p>If you use Linux you most likely have heard of the <strong>init.d</strong> directory. But what exactly does this directory do? It ultimately does one thing but it does that one thing for your entire system, so <strong>init.d </strong>is very important. The <strong>init.d</strong> directory contains a number of start/stop scripts for various services on your system. Everything from <em>acpid</em> to <em>x11-common</em> is controlled from this directory. Of course it&#8217;s not exactly that simple.</p><p>If you look at the <strong>/etc</strong> directory you will find directories that are in the form <strong>rc#.d</strong> (Where # is a number reflects a specific initialization level &#8211; from 0 to 6). Within each of these directories is a number of other scripts that control processes. These scripts will either begin with a &#8220;K&#8221; or an &#8220;S&#8221;. All &#8220;K&#8221; scripts are run before &#8220;S&#8221; scripts. And depending upon where the scripts are located will determine when the scripts initiate. Between the directories the system services work together like a well-oiled machine. But there are times when you need to start or stop a process cleanly and without using the kill or killall commands. That is where the <strong>/etc/init.d </strong>directory comes in handy.</p><p>Now if you are using a distribution like Fedora you might find this directory in <strong>/etc/rc.d/init.d</strong>. Regardless of location, it serves the same purpose.</p><p><span
id="more-11663"></span></p><p>In order to control any of the scripts in <strong>init.d </strong>manually you have to have root (or sudo) access. Each script will be run as a command and the structure of the command will look like:</p><p><em>/etc/init.d/command OPTION</em></p><p>Where <em>command </em>is the actual command to run and <em>OPTION </em>can be one of the following:</p><ul><li>start</li><li>stop</li><li>reload</li><li>restart</li><li>force-reload</li></ul><p>Most often you will use either <em>start, stop, </em>or <em>restart. </em>So if you want to stop your network you can issue the command:</p><p><em>/etc/init.d/networking stop</em></p><p>Or if you make a change to your network and need to restart it, you could do so with the following command:</p><p><em>/etc/init.d/networking restart</em></p><p>Some of the more common init scripts in this directory are:</p><ul><li>networking</li><li>samba</li><li>apache2</li><li>ftpd</li><li>sshd</li><li>dovecot</li><li>mysql</li></ul><p>Of course there may be more often-used scripts in your directory &#8211; it depends upon what you have installed. The above list was taken from a Ubuntu Server 8.10 installation so a standard desktop installation would have a few less networking-type scripts.</p><p><strong>But what about /etc/rc.local</strong></p><p>There is a third option that I used to use quite a bit. This option is the <strong>/etc/rc.local</strong> script. This file runs after all other init level scripts have run, so it&#8217;s safe to put various commands that you want to have issued upon startup. Many times I will place mounting instructions for things like nfs in this script. This is also a good place to place &#8220;troubleshooting&#8221; scripts in. For instance, once I had a machine that, for some reason, samba seemed to not want to start. Even afer checking to make sure the Samba daemon was setup to initialize at boot up. So instead of spending all of my time up front with this I simply placed the line:</p><p><em>/etc/init.d/samba start</em></p><p>in the <strong>/etc/rc.local</strong> script and Samba worked like a charm. Eventually I would come back and trouble shoot this issue.</p><p><strong>Final Thoughts</strong></p><p>Linux is flexible. Linux is so flexible there is almost, inevitably, numerous ways to solve a single problem. Starting a system service is one such issue. With the help of the <strong>/etc/init.d</strong> system (as well as <strong>/etc/rc.local</strong>) you can pretty much rest assured your service will start.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/04/04/get-to-know-linux-the-etcinitd-directory/feed/</wfw:commentRss> <slash:comments>24</slash:comments> </item> </channel> </rss>
