    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>Linux.com :: execute a script on start up</title>
        <link>http://www.linux.com/archive/forums/topic/1541</link>
        <description>Everything Linux and Open Source</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Linux.com Admin</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.linux.com" /> 
        <admin:errorReportsTo rdf:resource="mailto:noreply@linux.com" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>



<div class="xarbb-noteswrapper">
</div>

   <div class="xarbb-noteswrapper">
       <div class="xar-sub rightnote">
           <div>
                    <a href="http://www.linux.com/archive/forums/topic/1556">
Previous Topic</a>
|
                    <a href="http://www.linux.com/archive/forums/topic/1317">
Next Topic</a>
</div>

           <div>
                    <a href="http://www.linux.com/archive/forums/printtopic/1541?theme=print">
Print this topic</a> |
You are not subscribed            </div>
        </div>
        <div style="clear: both;"></div>
    </div>

    <h1>
        <a class="xar-title" href="http://www.linux.com/archive/forums/topic/1541">execute a script on start up</a>
   </h1>


   <div class="xarbb-topiccontrols">
<form action="http://www.linux.com/archive/forums?func=jump" method="post">
   <label for="xarbb_jump_menu">Forum Jump</label>
    <select name="f" id="xarbb_jump_menu" onchange="this.form.submit();">
        <optgroup label="Options">
            <option value="1" selected="selected">
Please select forum            </option>
            <option value="1">--------------------</option>
        </optgroup>
        <optgroup label="Forums">
                <option value="1">New to Linux</option>
                <option value="2">Hardware</option>
                <option value="3">Linux Distributions</option>
                <option value="4">Applications</option>
                <option value="5">Programming and Development</option>
                <option value="6">Miscellaneous Discussion</option>
                <option value="7">Linux.com Writers Forum</option>
                <option value="8">Jobs</option>
        </optgroup>
    </select>
    <input type="submit" class="button" value="Jump" />
</form>
<div style="clear: both;"></div>
   </div>

   <div class="xarbb-topiccontrols">

<span class="xar-sub">
    <a href="http://www.linux.com/archive/forums">
Forum Index    </a>
    <span style="font-size: larger;">&#187;</span>
    <a href="http://www.linux.com/archive/forums/category/4181">
        Forums 
    </a>
    <span style="font-size: larger;">&#187;</span>
    <a href="http://www.linux.com/archive/forums/forum/1">
        New to Linux   </a>
</span>
<div style="clear: both;"></div>
   </div>

<div class="xarbb-tablewrapper">



   <table>
       <tr>
           <th scope="col">
Author</th>
           <th scope="col">
Message</th>
       </tr>



            <tr>
                <td class="xar-norm author">
                    <div>
                        <a href="http://www.linux.com/archive/roles/401784">r2b2</a>
                   </div>
                   <div class="xar-sub">
Joined: Apr 18, 2008<br/>Posts: 13                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401784&amp;func=searchtopics">
Other Topics</a>
                   </div>
               </td>

               <td class="xar-norm message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted Apr 18, 2008 at 3:57:33 PM</span>
                       </div>



<div style="float: left;">
                           <strong class="xar-sub">
Subject: execute a script on start up                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div>
                        im using kubuntu 7.10 and i would want to run a command when my computer starts. how can i do that with linux ?
furthermore, what if that command i wanted to run needs &quot;sudo&quot;?

for example i have this:

just for example : open xorg.conf 

[quote]

sudo kate /etc/X11/xorg.conf

[/quote]

the command uses &quot;sudo&quot; because the file is owned by root. 

thanks!</div>

                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>
               <td class="xar-alt">

                        <a href="http://www.linux.com/archive/roles/401784">
                            <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                        </a>
                        <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401784">
                            <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                       </a>
                            <a href="http://">
                                <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                           </a>
</td>
           </tr>





           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/401295">
                                tophandcwby                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Apr 10, 2008<br/>Posts: 81<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401295&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-accent message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Apr 18, 2008 5:22:04 PM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1187951" href="http://www.linux.com/archive/forums/topic/1541#1187951">
                                    execute a script on start up                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        Are you trying to edit your /etc/X11/xorg.conf every time your computer boots? Or, are you just trying to edit the /etc/X11.xorg.conf until you get it running correctly?                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/401295">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401295">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
                                <a href="http://">
                                    <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                               </a>
</td>
           </tr>

           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/401755">
                                Synthead                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Apr 17, 2008<br/>Posts: 12<br />
Location:Seattle<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401755&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-norm message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Apr 18, 2008 10:49:00 PM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1187972" href="http://www.linux.com/archive/forums/topic/1541#1187972">
                                    execute a script on start up                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        It sounds like you're trying to get around a problem that would require you to edit a config ... what is the issue?

You could put it in /etc/rc.conf on some distros
You could put it in ~/.xinitrc at X startup time
There are others ...<p class="hiddensignature">
www.archlinux.org</p>
                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/401755">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401755">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
                                <a href="http://">
                                    <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                               </a>
                                <a href="http://www.linux.com/archive/roles/401755">
                                    <img src="modules/xarbb/xarimages/new/icon_msnm.gif" alt="MSN" />
                               </a>
                                <a href="http://edit.yahoo.com/config/send_webmesg?.target=bikejumpouch&amp;.src=pg">
                                    <img src="modules/xarbb/xarimages/new/icon_yim.gif" alt="Yahoo!" />
                               </a>
                                <a href="aim:goim?screenname=sawtoothdentist&amp;message=Hello+Are+you+there?">
                                    <img src="modules/xarbb/xarimages/new/icon_aim.gif" alt="AOL Instant Messenger" />
                               </a>
</td>
           </tr>

           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/401784">
                                r2b2                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Apr 18, 2008<br/>Posts: 13<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401784&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-accent message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Apr 19, 2008 12:40:37 AM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1187984" href="http://www.linux.com/archive/forums/topic/1541#1187984">
                                    Re:  execute a script on start up                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        sorry, the xorg editing thing is just an example where i wanted to run a command during startup. 

wait, i found it! here's what im trying to execute during startup :

[quote]
sudo smbmount //192.168.1.2/Music /home/dbott/music -o username=dbott,password=mysecretpassword,uid=1000,mask=000
[/quote]

i would like the samba share to mount automatically so that users wont execute this script anymore, and it requires sudo , which is not applicable to non admin users...



[Modified by: r2b2 on April 19, 2008 12:41 AM]
                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/401784">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401784">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
                                <a href="http://">
                                    <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                               </a>
</td>
           </tr>

           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/401295">
                                tophandcwby                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Apr 10, 2008<br/>Posts: 81<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401295&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-norm message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Apr 19, 2008 1:14:57 AM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1187987" href="http://www.linux.com/archive/forums/topic/1541#1187987">
                                    execute a script on start up                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        Rather than using a startup script, you need to create an entry in your /etc/fstab. A quick google showed the following link
http://www.cyberciti.biz/faq/configure-a-system-to-automount-a-samba-share-with-etcfstab/                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/401295">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401295">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
                                <a href="http://">
                                    <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                               </a>
</td>
           </tr>

           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/401784">
                                r2b2                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Apr 18, 2008<br/>Posts: 13<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401784&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-accent message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Apr 19, 2008 3:07:40 AM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1187993" href="http://www.linux.com/archive/forums/topic/1541#1187993">
                                    execute a script on start up                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        yeah thats another thing,., but what about commands like ,for example start an application that requires sudo?                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/401784">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401784">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
                                <a href="http://">
                                    <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                               </a>
</td>
           </tr>

           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/401295">
                                tophandcwby                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Apr 10, 2008<br/>Posts: 81<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401295&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-norm message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Apr 19, 2008 12:03:59 PM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1188017" href="http://www.linux.com/archive/forums/topic/1541#1188017">
                                    execute a script on start up                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        When using debian and maybe ubuntu since it is derived from debian, to run a script at boot time, write the script and locate it at /etc/rc.local 

During the boot up process the script in /etc/init.d/rc.local checks for /etc/rc.local and if it's executable, runs it. This script will be run with root privilege so sudo is not needed. If you wanted to run a command in the script with another users privilege it would look something like
sudo -u tom /path/to/command

To learn more about start up scripts, run the command
man boot-scripts                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/401295">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401295">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
                                <a href="http://">
                                    <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                               </a>
</td>
           </tr>

           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/401784">
                                r2b2                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Apr 18, 2008<br/>Posts: 13<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401784&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-accent message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Apr 21, 2008 7:06:01 AM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1188078" href="http://www.linux.com/archive/forums/topic/1541#1188078">
                                    Re:  execute a script on start up                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        [quote=tophandcwby]When using debian and maybe ubuntu since it is derived from debian, to run a script at boot time, write the script and locate it at /etc/rc.local 

During the boot up process the script in /etc/init.d/rc.local checks for /etc/rc.local and if it's executable, runs it. This script will be run with root privilege so sudo is not needed. If you wanted to run a command in the script with another users privilege it would look something like
sudo -u tom /path/to/command

To learn more about start up scripts, run the command
man boot-scripts[/quote]

Here's what i did based on what i understand on the above post: I think i got it wrong because it is not working.

1. create a file called mountSamba and located it in /home/rvk

    Contents of /home/rvk/mountSamba (this will mount the samba share to my desktop)
[quote]
   smbmount //samba/common /home/rvb/Desktop/samba/ -o username=rvb,uid=1000,mask=000
[/quote]

2. Make the file executable :

[quote]
   sudo chmod +x /home/rvk/mountSamba
[/quote]   

3. Locate it in /etc/rc.local (as suggested above)

    Contents of /etc/rc.local :

[quote]
  #!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will &quot;exit 0&quot; on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# the file that contains the command for mounting samba
/home/rvk/mountSamba
exit 0

[/quote]

Then i rebooted the system. I was expecting that the samba will be automatically mounted on my desktop folder when the system starts, but to no avail.
Please tell me if i did something in the above steps. Thanks!                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/401784">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401784">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
                                <a href="http://">
                                    <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                               </a>
</td>
           </tr>

           <tr>
               <td class="xar-norm author">
                   <strong>

                            <a href="http://www.linux.com/archive/roles/401295">
                                tophandcwby                           </a>
</strong>

                   <span class="xar-sub">
<br />
Joined Apr 10, 2008<br/>Posts: 81<br />
                        <br />
                        <a href="http://www.linux.com/archive/forums?by=401295&amp;func=searchtopics">
Other Topics                        </a>
                    </span>
                </td>

                <td class="xar-norm message">
                   <div class="xarbb-messagecontrols">
                       <div class="leftnote">
                           <span class="xar-sub">
Posted:
                                Apr 21, 2008 1:48:33 PM                           </span>
                       </div>
                       <div class="rightnote">
</div>
                       <div style="float:left;">
                           <strong class="xar-sub">
Subject:
                                <a name="1188091" href="http://www.linux.com/archive/forums/topic/1541#1188091">
                                    execute a script on start up                                </a>
                            </strong>
                        </div>
                        <div style="clear: both;"></div>
                    </div>

                    <div style="clear: left;">
                        Did you make /etc/rc.local executable?
Did you make //samba/common  a shared file on the windows machine?

                    </div>
                </td>
            </tr>

            <tr>
                <td class="xar-norm author">
                    <a href="http://www.linux.com/archive/forums/topic/1541#top">
Back to top</a>
</td>

               <td class="xar-alt">

                            <a href="http://www.linux.com/archive/roles/401295">
                                <img src="modules/xarbb/xarimages/new/icon_profile.gif" alt="Profile" />
                            </a>
                            <a href="http://www.linux.com/archive/?module=roles&amp;func=email&amp;uid=401295">
                                <img src="modules/xarbb/xarimages/new/icon_email.gif" alt="Email" />
                           </a>
                                <a href="http://">
                                    <img src="modules/xarbb/xarimages/new/icon_www.gif" alt="Website" />
                               </a>
</td>
           </tr>
</table>
</div>

<div class="xarbb-topiccontrols">

<span class="xar-sub">
    <a href="http://www.linux.com/archive/forums">
Forum Index    </a>
    <span style="font-size: larger;">&#187;</span>
    <a href="http://www.linux.com/archive/forums/category/4181">
        Forums 
    </a>
    <span style="font-size: larger;">&#187;</span>
    <a href="http://www.linux.com/archive/forums/forum/1">
        New to Linux   </a>
</span>

</div>



            </channel>
</rss>
