Commenting services in init.d

Posted on 2005-04-28
Last Modified: 2010-04-20
I'm in /etc/init.d  and see a bunch of services (ie: ssh, smb ) etc.

I understand this is where you can start/stop services from starting up when you boot up linux?

Should I do a " vi sshd  "

Then what do I do?  The config is pretty big, not sure what to comment to disable it
Question by:dissolved
    LVL 8

    Assisted Solution

    To disable service loading during boot use

    /sbin/chkconfig service_name off

    For example,
    /sbin/chkconfig sshd off

    To enable one,
    /sbin/chkconfig sshd on

    Author Comment

    isnt there a way to do it with inetd.conf?  
    LVL 23

    Expert Comment

    No, inetd.conf pertains only for services that run through the inetd
    superserver: servers that don't run as stand-alone programs

    (but are launched each time a client connects to the port that inetd listens on)

    You need to either use chkconfig   or take out the symlinks by hand
    (using chkconfig is best and easiest)
    LVL 8

    Expert Comment

    inetd is very old and deprecated.
    Newer systems use xinetd but daemon mode is a preffered way to run sshd.
    Trust me. :-)

    Nevertheless, You can still use xinetd to run ssh.
    You should build a file /etc/xinetd.d/ssh with the following content:

    service ssh
    socket_type = stream
    wait = no
    user = root
    server = /usr/sbin/sshd
    port = 22
    server_args = -i
    # only_from =
    only_from =
    log_on_failure = ATTEMPT HOST RECORD

    And must restart the service
    /etc/rc.d/init.d/xinetd restart
    To disable ssh add line inside {}
    And restart xinetd

    If your system system still use inetd (like rh6), just comment ssh line in the /etc/inetd.conf
    and restart inetd daemon.
    killall -HUP inetd

    If you still want to use inetd and xinetd instead of daemon mode and if you use new linux system
    you have to run these commands anyway to disable sshd
    /etc/init.d/sshd stop
    /sbin/chkconfig sshd off
    LVL 23

    Accepted Solution

    Adding entries to *inetd.conf   is done to enable not disable services
    the truth is to disable optional services  run by init.d,  chkconfig is used

    What running

    chkconfig service on/off

    does is  change symlinks in subdirectories under /etc/rc.d

    Here's how it works in SysV style init which is very popular among Linux distributions now:
    when your system boots up, it enters a runlevel.
    The default runlevel is specified in /etc/inittab


    Current runlevel can be changed with the init command, i.e.
    'telinit 0'   or 'init 0'  as root is the same as issuing   shutdown -h now
    or '/sbin/halt'...  other runlevels have different special meanings

    Where XXX is generally either 5 or 3, the system is set to that default at bootup

    /etc/rc.d/rc5.d     corresponds to the services that are stopped or started in runlevel 5
    (Graphical mode runlevel)

    just as   /etc/rc.d/rc3.d   corresponds to services started/stopped when entering runlevel 3

    (Runlevel 0  corresponds to system halt, 6 is reboot, 1 is single user)

    Each directory contains symlinks to files in /etc/init.d

    if it contains  S01blah,   then  the service 'blah' will be started
    the numbers determine the sort order

    (Services that other services depend on will have lower numbers)

    Then you may see symlinks named things such as K20nfs    or K15sshd,
    say in runlevel 1...

    The 'K' means kill or stop service  when entering that runlevel

    So you use chkconfig to change those symlinks for you... because it's
    convenient, and avoid you needing to go through the tedium of editing them
    all by hand or figuring out the right number corresponding to the start/stop orders  :)

    Author Comment

    by:dissolved services that start up with init...only become active when someone attempts a connection on that port. So init is a listening service?
    LVL 23

    Expert Comment


    > services that start up with init...only become active when someone attempts a connection on that port. So >init is a listening service?

    Well, replace the word "init" with the word "inetd"  every place where it appears in the
    above sentence and it is correct.

    Inetd and Init are quite different.  
    Init is not a listener or network service

    although it manages some system  tasks like login gettys
    and starts/stops system service programs

    (Inetd is just one service [inetd is a network service])
    LVL 16

    Assisted Solution

    Init is the proverbial 'grandfather of all' processes. It is the first process that the kernel runs. It is responsible for spawning all other processes
    Inetd is your super-server. It manages your network related daemons and listens on many ports. Whenever a reques comes on, lets say telnet port, it spawns the telnet daemon to serve that request.

    Author Comment

    thanks everyone

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
    In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now