Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I am a newbiew running SuSE Linux Enterprise Server 8.2
I want to start a program (inetd) each time my server is booted.
Currently, I have this working by adding the following lines to the /root/.profile file :
# 18 Oct 2005, Start the inetd process
inetd &
So, when i reboot the machine, I log-in as root and inetd is started. However, when others are using the machine and su (switch user) to root, a new inetd is started. After a few weeks, there are lots of inetd processes running.
What/Where is the correct file where I should startup inetd? I assume this file is run only once during boot up and then never again. Or is there a better solution to fix this? Is see the inetd man page says, "inetd should be run at boot time by /etc/init.d/inetd", but I'm not sure what this means. Please add some detail to your answers as I am a newbie!
inetd or xinetd should be started automatically by the system. You should not run it as a user There should only be one inetd (or xinetd) running.
On my Debian inetd is started by the script /etc/init.d/inetd.
On my Redhat xinetd is started by /etc/init.d/xinetd.
(Actually this is started by links in /etc/rc?.d back to the files in /etc/init.d.)
You do not need BOTH inetd and xinetd. I don't use Suse so don't know which it runs. If it runs inetd then your configuration should be in /etc/inetd.conf. If it runs xinetd then your configuration will be individual files under the directory /etc/xinetd.d (there is also an /etc/xinetd.conf but that file deals with the startup rather than the services like inetd.conf).
Okay. I do have the file /etc/init.d/inetd. It is a script.
My rc?.d files exist in /etc/init.d/rc?.d
In which rc?.d should I add my link to /etc/init.d/inetd?
p.s. Just out of curiosity, is there a file that does what I wanted in my first post (i.e. a startup file that is run once during bootup and then never again?)
Answering your last question first. Yes. That is the purpose of the /etc/init.d scripts.
The ? in rc?.d is the run level that the script gets executed in. 1 = single user, 2 = first multi-user, 3=second multi-user etc... (Type "man init" for info on the different run levels.) Typically networking and X windows are started in run level 3 or 4.
/etc/init.d/rc?.d probably ALREADY has links to the script in init.d. It will have specialized names as for example:
From Debian:
lrwxrwxrwx 1 root root 15 Feb 11 2005 /etc/rc0.d/K20inetd -> ../init.d/inetd
lrwxrwxrwx 1 root root 15 Feb 11 2005 /etc/rc1.d/K20inetd -> ../init.d/inetd
lrwxrwxrwx 1 root root 15 Feb 11 2005 /etc/rc2.d/S20inetd -> ../init.d/inetd
lrwxrwxrwx 1 root root 15 Feb 11 2005 /etc/rc3.d/S20inetd -> ../init.d/inetd
lrwxrwxrwx 1 root root 15 Feb 11 2005 /etc/rc4.d/S20inetd -> ../init.d/inetd
lrwxrwxrwx 1 root root 15 Feb 11 2005 /etc/rc5.d/S20inetd -> ../init.d/inetd
lrwxrwxrwx 1 root root 15 Feb 11 2005 /etc/rc6.d/K20inetd -> ../init.d/inetd
From RedHat:
lrwxr-xr-x 1 root root 16 Aug 4 14:23 /etc/rc0.d/K50xinetd -> ../init.d/xinetd
lrwxr-xr-x 1 root root 16 Aug 4 14:23 /etc/rc1.d/K50xinetd -> ../init.d/xinetd
lrwxr-xr-x 1 root root 16 Aug 4 14:23 /etc/rc2.d/K50xinetd -> ../init.d/xinetd
lrwxr-xr-x 1 root root 16 Aug 4 14:23 /etc/rc3.d/S56xinetd -> ../init.d/xinetd
lrwxr-xr-x 1 root root 16 Aug 4 14:23 /etc/rc4.d/S56xinetd -> ../init.d/xinetd
lrwxr-xr-x 1 root root 16 Aug 4 14:23 /etc/rc5.d/S56xinetd -> ../init.d/xinetd
lrwxr-xr-x 1 root root 16 Aug 4 14:23 /etc/rc6.d/K50xinetd -> ../init.d/xinetd
The entries with "K" in their name are stop (kill) entries and the ones with "S" in their names are the start entries. If you examin the script you'll see it has a function defined as "start)", one defined as "stop)" and others. The number following the "K" or "S" gives the order in which it stops or starts. (50 would start after 30 but before 70).
If inetd is not being started automatically it suggests your configuration may have something odd in it. After a boot do "ps -ef |grep inetd" and see if its running. If not then try running "/etc/init.d/inetd start" from the command line and see if it gives you any errors that would tell you why it didn't start.
FYI: If you make changes to inetd.conf and need to restart inetd you shouldn't stop it and start it but just do "kill -1 inetd". This sends a sighup to inetd and inetd interprets that a command to reread its configuration file.
jlightner - thanks for your help on this. I will test this change on Monday and report back on this post. Is there a command I can run to see which run level I am currently in? (this will save me figuring this out using trial and error!)
You'll notice that all of the files in the rc?.d directories (where "?" is a number corresponding to a runlevel) are symbolic links. In other words, they "point to" the actual script-files which are stored in a common location.
You will also notice that all of those links have a consistent name: "S" or "K", followed by a two-digit number, followed by a descriptive name. "S" stands for start, "K" for kill. The two digits are used to put the file-names in a certain order ... init works through the files in ascending (or descending) order by name.
The file which ultimately drives the process is /etc/inittab, and the man pages on init and inittab are very informative.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.