LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (http://www.linuxquestions.org/questions/fedora-35/)
-   -   Equivalent to /etc/init.d in Fedora (http://www.linuxquestions.org/questions/fedora-35/equivalent-to-etc-init-d-in-fedora-4175418880/)

0men 07-26-2012 11:49 PM

Equivalent to /etc/init.d in Fedora
 
Heya fedora peeps.

Quick question and very basic for you guys. Im a Debain fan but im helping a friend install a Fedora 16 on his laptop. Say if i want to turn off ssh, i normally just go /etc/init.d then chmod -x ssh. But how do i do that from the command line on a fedora system ?

Basic, i've read something about systemctl :S, but would prefer doing chmod -x, if possible in a Fedora environment.

Thanks for your help

Slackyman 07-27-2012 01:42 AM

You can find them in /etc/rc.d/init.d.

RockDoctor 07-27-2012 07:05 AM

Perhaps
Code:

service ssh disable

acid_kewpie 07-27-2012 07:18 AM

where did this idea of stopping it being executable come from? I've never heard of that and just sounds crude and clunky.

cynwulf 07-27-2012 07:34 AM

I believe it's the "standard" UNIX way of disabling init scripts. It's still the standard way of disabling Slackware's init scripts.

TobiSGD 07-27-2012 10:04 AM

Yep, standard on Slackware, because the main init script checks if they are set to executable and only runs them in that case. But not the correct way on Debian.

acid_kewpie 07-27-2012 10:21 AM

that sounds horrible. Wonderfully simple, sure, but that doesn't make it good. the executable flag means the file is execut**ABLE**, not that it should be executed. That's a hack.

Slackyman 07-27-2012 02:58 PM

Quote:

Originally Posted by acid_kewpie (Post 4739403)
that sounds horrible. Wonderfully simple, sure, but that doesn't make it good. the executable flag means the file is execut**ABLE**, not that it should be executed. That's a hack.

It's not "horrible": it's the BSD Init-Style!
You have many different init scritpts in the init path and a main script check for the ones with the executable flag and run them.
Utils and scripts like chkconfig, service [name] start/stop/restart, ntsysv were created to make the daemons-services management easier.

hpfeil 07-31-2012 10:08 AM

Forget everything you know about /etc/init.d. Examine the files in /usr/lib/systemd/system. The *.service files control services. To make one active, create a link in /usr/lib/systemd/system/multi-user.target.wants; delete the link to disable a service. Suffering from congenital indolence, as I oftentimes do, I use "systemctl" to do all that.

> systemctl status sshd.service
sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
Active: active (running) since Tue, 31 Jul 2012 06:58:26 -0700; 6s ago
Process: 7905 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS)
Main PID: 7910 (sshd)
CGroup: name=systemd:/system/sshd.service
└ 7910 /usr/sbin/sshd -D

> systemctl stop sshd.service
sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
Active: inactive (dead) since Tue, 31 Jul 2012 06:59:56 -0700; 3s ago
Process: 7910 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=0/SUCCESS)
Process: 7905 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/sshd.service

[notice that the service is still loaded, or enabled]

> systemctl disable sshd.service
rm '/etc/systemd/system/multi-user.target.wants/sshd.service'

[now the sshd service will no longer start - reverse the process, enable and start, if you want to run sshd again]

> systemctl --help
> man systemctl

IMHO, systemd is a lot easier to deal with than all of those /etc/init.d or /etc/rc.d files. My /etc/init.d directory is empty. (The *.wants directories coorespond to different run-levels.)


All times are GMT -5. The time now is 06:10 AM.