2

Possible Duplicate:
Chkconfig alternative for Ubuntu Server?

In Fedora I can do

$ chkconfig --list | grep ssh

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

sshd            0:off   1:off   2:off   3:off   4:off   5:off   6:off

and it shows all run levels. Then I can use

chkconfig sshd on

or

chkconfig sshd off

How can I do the same in my Ubuntu 11.04? + How do i mention in which runlevel it should start?

0

2 Answers 2

2

chkconfig is for sysv init system and Ubuntu uses upstart, to list all services and their status type initctl list. Currently there is no tool to enable or disable services in upstart so you have to manually rename the file in /etc/init so it doesn't end with .conf.

2
  • How do i say which runlevel?
    – user25165
    Sep 7, 2011 at 16:37
  • 1
    Runlevels are different on Debian and Ubuntu (vs. RPM distros). There really are only two effective runlevels. 1 and 2. Level one is the same as single-user mode on (most) any Linux. Runlevel 2 is what you would think of as 5 on Fedora. Sep 7, 2011 at 18:21
1

Even if Ubuntu uses Upstart, not all services have been migrated to it yet and hence the old System-V style init scripts (files in /etc/init.d/.)

According to the manual page of chkconfig, off and on are used for stopping or starting services, not disabling them.

  • To start the SSH daemon (which is named ssh), run: sudo start ssh
  • Similarly, to stop it: sudo stop ssh

To list the status of all services, use: (N.B. output is lengthy and goes to stderr)

sudo service --status-all 2>&1 | more

These commands work for both the Upstart scripts as well as for the services in /etc/init.d/.

3
  • chkconfig we use for always to start when system starts. Is this same when we use "sudo start ssh" will it always start in any runlevel?
    – user25165
    Sep 7, 2011 at 16:36
  • How do i say which runlevel ssh should start? like chkconfig.
    – user25165
    Sep 7, 2011 at 16:37
  • 1
    For services using /etc/init.d/, you could use ls -1 /etc/rc?.d/*apache2. Upstart scripts can be checked with initctl show-config ssh, it would show. Note that Upstart still places wrapper scripts in /etc/init.d/ for compatibility reasons.
    – Lekensteyn
    Sep 7, 2011 at 16:51