LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 07-25-2005, 05:24 PM   #1
linux-rulz
Member
 
Registered: Dec 2004
Distribution: Windows XP Home, Ubuntu Hoary
Posts: 584

Rep: Reputation: 30
Run commands on each boot


Hey all. On Red Hat systems (I use Centos and Ubuntu) you can add a line to /etc/rc.local and that command will run on every single boot. What is the equivalent file in Ubuntu? Thx!
 
Old 07-25-2005, 05:39 PM   #2
username17
Member
 
Registered: Aug 2004
Location: Norfolk VA
Distribution: Slackware 11
Posts: 230

Rep: Reputation: 30
Have you looked, it should be the same.
I've never used ubuntu, but it should use rc.d scripts to call itself linux (IMO).

If not, sorry but GL.
 
Old 07-25-2005, 05:43 PM   #3
linux-rulz
Member
 
Registered: Dec 2004
Distribution: Windows XP Home, Ubuntu Hoary
Posts: 584

Original Poster
Rep: Reputation: 30
You are mistaken. Red Hat systems (and SUSE, etc.) use /etc/rc.local. Debian systems do not use this file. To call yourself a Red Hat derived Linux system, you may have to use these files, but not to call yourself Linux.
 
Old 07-27-2005, 11:38 AM   #4
cjnodell
Member
 
Registered: Jun 2005
Location: Remchingen, Deutschland
Distribution: Undecided
Posts: 50

Rep: Reputation: 15
i dont think its redhat specific. Arch linux has it, and so dose puppy linux. I think that slackware has it, but am not sure.

Anyways, I would love to hear the answer to this one too. I have set linux-wlan-ng pre 26, but cant finish it up because the documentation says to edit rc.local, and there is none... I would love to hear about an equivilant.
 
Old 07-27-2005, 11:28 PM   #5
Rick485
Member
 
Registered: Sep 2003
Location: Arizona
Distribution: Kubuntu 8.04
Posts: 202

Rep: Reputation: 30
I am new to using Ubuntu and could not find the rc.local file so my I created my own rc.local file. My previous experience was with Red Hat and Slackware, so I am not sure if I did things the Debian/Ubuntu way or not. Red Hat uses the typical System 5 style initialization and Slackware is slightly different from most other Linux distros in that is uses more of a BSD style initialization. Both distros have an rc.local file which can be used to add commands which must be run after system initialization. My knowledge about how Linux boots up is actually somewhat limited but, I could see that some things were different than with either Red Hat or Slackware, so I hope what I did was not too unreasonable. At least the rc.local file that I created seems to work.

When I looked Inside the /etc/inittab I see that it says that my computer should boot up in run level 2. When I enter the “runlevel” command it confirmed that my computer had started up in run level 2. I needed to create an rc.local file somewhere. If I wanted my rc.local script to run, I would need to place a symbolic link to my rc.local script from within the /etc/rc2.d directory. The scripts used to start things in run level 2 are in the /etc/rc2.d directory. My rc.local file itself could be placed somewhere else (anywhere).

In CentOS the rc.local is in the /etc/rc.d directory. In CentOS a symbolic link to that file is placed in each of the other directories for each run level such as /etc/rc2.d, /etc/rc3.d, /etc/rc4.d, and /etc/rc5.d. Ubuntu does not have an /etc/rc.d directory so I decided to place my rc.local script in the /etc/init.d directory instead. At the top of the file I placed this this line which tells it to use the “sh” shell to interpret the commands in the file:

#!/bin/sh

After that line in my rc.local file I added whatever commands I wanted it to execute each time the computer starts up. After I finished creating the file, I then used “sudo chmod 751 /etc/init.d/rc.local” to make the script executable with the same permissions as the other scripts in the /etc/init.d directory. Afterwards, I used “ls -l” to check that the permissions were the same as most of the other scripts.

Next, I needed to create the symbolic link in the /etc/rc2.d directory. Assuming this has at least some resemblance to Red Hat Linux, then every script in the /etc/rc2.d directory that starts with an S should be executed in alphabetical order when the computer starts up. I wanted my rc.local file to be the last startup script to run so I called my symbolic link S99zlocal. I used this command to create my symbolic link to my rc.local file:

sudo ln -s /etc/init.d/rc.local /etc/rc2.d/S99zlocal

Afterwards, I used the “ls -l” command and could see the arrow and the lower case “l” that told me that I had a link. I then rebooted my computer and found that the commands I had placed in my rc.local file had been executed. It seemed to work! Perhaps someone who knows more about Ubuntu can tell me if what I did is reasonable or not or if it departs too far from the Debian/Ubuntu way of doing things. Was there already a file somewhere that I could have just edited instead? I have only been using Ubuntu for about a week, so I may or may not know what I am doing.

Last edited by Rick485; 07-27-2005 at 11:49 PM.
 
Old 07-28-2005, 01:48 AM   #6
Rick485
Member
 
Registered: Sep 2003
Location: Arizona
Distribution: Kubuntu 8.04
Posts: 202

Rep: Reputation: 30
Oops, I noticed what might possibly be a slight flaw in the rc.local file that I created. I am not really sure if it would be a problem or not in Ubuntu because I am not really that familiar with Ubuntu. In Red Hat or CentOS for each run level there there are seperate scripts in seperate files used to start and stop programs. In Red Hat the scripts that start with the letter "S" are run on startup the scripts that start with the letter "K" are run on shutdown. They are all in the same directory. In Ubuntu everything in the /etc/rc2.d directory starts with an S so I am wondering if my script could somehow be run when shutting down. I have not yet checked to see if that is happening so you might possibly want to ignore my suggestion for now until someone more familiar with Ubuntu comments. What I did might or might not be ok, there clearly seems to be something very different about how Ubuntu starts and stops services.
 
Old 08-02-2005, 06:23 PM   #7
errr
LQ Newbie
 
Registered: Aug 2005
Location: Windows sucks, and Linux/*BSD rules :)
Distribution: them all
Posts: 1

Rep: Reputation: 0
I know this is a bit old but I found this thread while doing a google search for this exact same question. I kept on doing a google search because I knew there had to be some file that was already out there for this... I was right, but I didnt have any luck with google though. I asked one of the guys in my LUG Dave Ponder and as it turns out you can use
Quote:
/etc/init.d/bootmisc.sh
I hope this will help out someone else down the road.
errr-online.com
 
Old 08-17-2005, 06:18 AM   #8
Tomy
LQ Newbie
 
Registered: Jul 2004
Posts: 5

Rep: Reputation: 0
Quote:
Originally posted by errr
I know this is a bit old but I found this thread while doing a google search for this exact same question. I kept on doing a google search because I knew there had to be some file that was already out there for this... I was right, but I didnt have any luck with google though. I asked one of the guys in my LUG Dave Ponder and as it turns out you can use I hope this will help out someone else down the road.
errr-online.com
Thanks for posting the answer. I found this thread with a google search and was happy that the answer was here

Tomy
 
Old 12-27-2011, 04:28 PM   #9
eventvwr
LQ Newbie
 
Registered: Dec 2011
Location: UK
Distribution: Ubuntu 11.04 (Natty Narwhal)
Posts: 4

Rep: Reputation: Disabled
Situation seems to have changed now

(Yes I realise that this thread is very old, however it turned up in my web search so there may be other people who stumble across it)

It appears that Ubuntu from Karmic to Natty, and probably versions onward until they change it again, uses /etc/rc.local instead of bootmisc.sh
http://linuxdrops.blogspot.com/2009/...in-karmic.html

I have added the startup commands I wanted to rc.local and it worked

HTH
E
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
no commands run astroboiii Linux - General 2 01-08-2005 07:40 PM
run 2 commands in a script ddpicard Linux - General 10 06-13-2003 04:50 PM
My Mandrake can not run the following commands. futurist Linux - General 2 03-23-2003 09:12 AM
Cannot run commands after su bugsbunny Linux - Newbie 5 02-07-2003 11:25 AM
Scripts won't run commands Xyphoid Linux - General 4 08-08-2002 08:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 09:01 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