UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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.
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:
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.
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.
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.