LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   the proper way to shutdown services. (https://www.linuxquestions.org/questions/linux-general-1/the-proper-way-to-shutdown-services-130156/)

Blu-star 12-30-2003 04:11 PM

the proper way to shutdown services.
 
hey!

what is the proper way to make programs not to start at systemstartup.
when i first installed slackware and ran ps -aux i saw that there was a few things i didnīt want running, one was sendmail and the other OpenSSH.

i went to /etc/rc.d and i saw there was a file called rc.sendmail there, i did a chmod ugo-rwx on that file, and after that it hasnīt started, is this the real way to do this? if not, how should i do?

the OpenSSHd i commented out from rc.inet2 (i think it was inet2).

help out a newbie please :)

MartinN 12-30-2003 04:31 PM

No, that's not the right way. First find out what runlevel you are in. As root, type
runlevel
It's probably 2 or 3 if you have text login or 5 if you are using graphical login.

Now, go to the directory /etc/rc.d/rcN.d where N=your runlevel. This directory contains a lot of symbolic links to the directory ../init.d/

Remove the links to the services you are not using.

Regards
Martin

mr_manny 12-30-2003 05:40 PM

here is another way....
[root@myBOX manny]# /sbin/runlevel
N 3

Redhat
To display what is configured for a particular runlevel, try the following:
[root@myBOX manny]# /sbin/chkconfig --list | grep 3:on
keytable 0:off 1:on 2:on 3:on 4:on 5:on 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off
vmware 0:off 1:off 2:on 3:on 4:off 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
random 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ipchains 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off
lpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
portmap 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
xinetd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@myBOX manny]#

to shutoff a particular service/deamon, try the following
[root@myBOX manny]# /sbin/chkconfig sshd off

you will notice that sshd is no longer configured to run:

[root@myBOX manny]# /sbin/chkconfig --list | grep 3:on
keytable 0:off 1:on 2:on 3:on 4:on 5:on 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off
vmware 0:off 1:off 2:on 3:on 4:off 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
random 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ipchains 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off
lpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
portmap 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
xinetd 0:off 1:off 2:on 3:on 4:on 5:on 6:off


to enable a service/deamon, it's the opposite:
[root@myBOX manny]# /sbin/chkconfig sshd on

hope this helps,
manny

thegeekster 12-30-2003 06:44 PM

Re: the proper way to shutdown services.
 
Quote:

Originally posted by Blu-star
...i went to /etc/rc.d and i saw there was a file called rc.sendmail there, i did a chmod ugo-rwx on that file, and after that it hasnīt started, is this the real way to do this? if not, how should i do?...
Not quite. You only need to remove the executable bit (x) to stop a service from starting, not all the permissions. In the /etc/rc.d directory (in Slackware at least), list the directory with the -l option ( ls -l /etc/rc.d ). the default permissions for a service with the x permission removed would look like this:

-rw-r--r-- 1 root root

while the ones that do start at boot would look like this:

-rwx-r-xr-x 1 root root

What you're doing with that particular chmod command is locking all users out of those bootup scripts, including root, which will make it look like this (you won't even be able to open up the file to look at it):

---------- 1 root root

To restore any files you may have locked, you can run this command:

chmod a+r /etc/rc.d/* ; chmod u+w /etc/rc.d/*

None of the other files will be affected. Only the files with all permissions removed (the locked ones) will be restored without setting the x bit.


The correct command to stop a service starting at boot would be:

chmod a-x /etc/rc.d/<filename>

(Notice that you can use 'a' in the command instead of 'ugo' to accomplish the same thing)


NOTE: Using chmod will prevent/allow services starting during boot globally, ie., regardless of runlevel. If you only want to change it for a particular runlevel, then use the method outlined by MartinN. Only, I would just comment out the desired service (not remove it) in case you may change your mind in the future. ;)

Blu-star 12-31-2003 09:14 AM

thanks for the help!

really appriciated.

ugge 12-31-2003 09:19 AM

You might have the command ntsysv mhich will help you do this just by (un)checking services to start at current run level. These setting will kick in next boot, or when you change run level.

thegeekster 12-31-2003 06:18 PM

Quote:

Originally posted by ugge
You might have the command ntsysv mhich will help you do this just by (un)checking services to start at current run level. These setting will kick in next boot, or when you change run level.
ntsysv is a RedHat specific util and might not work with Slack, which is what he said he installed in the very first post.............AFAIK, RH does things a little differently than Slack when it comes to booting up the services. :)

ugge 01-01-2004 03:12 AM

Thanx for the info

detpenguin 01-01-2004 12:57 PM

is there a list of what each program does someplace? how would i know which programs i need running, and which are just there for convenience?

thegeekster 01-01-2004 07:21 PM

Quote:

Originally posted by detpenguin
is there a list of what each program does someplace? how would i know which programs i need running, and which are just there for convenience?
I haven't come across anything, yet, that list basic startup daemons that would apply for all distros. Keep in mind that different systems may require a couple of different startup daemons for essential operation. Anyway, here's some links to look at: :study:

Common Startup Services (Daemons) - Describes some of the different startup services, but seems to list some services specific to a RedHat-based distro not found on all distros.

Slackware.com - System Startup - Slackware startup is based on BSD startup and this shows some basic daemons. This might give you an idea of what may be essential.

Red HatŪ Linux 6 Unleashed: Chapter 6 - Describes the startup and shutdown of RH. The second section (different page) talks about the different scripts and daemons.

Linux Startup Manual - The name says it all. <EDIT> Describes the startup process of a System V compatible system. Many Linux distributions make use of this style, as opposed to a BSD style. The difference is in a System V compatible distro there is given a subdirectory for each runlevel, while BSD compatible systems give one startup script to each runlevel (not subdirectories). </EDIT>


HTH :)

detpenguin 01-01-2004 09:15 PM

excellent!!! thanks geekster!


All times are GMT -5. The time now is 02:36 PM.