Linux service disable autostart

How do I prevent Linux services from auto-starting?

I have recently migrated from Windows to Linux (xubuntu) I am a developer and have installed everything I need, LAMP. In Windows I used to turn off all unnecessary services — I don’t need the Apache or MySQL service running all the time. Whenever I needed MySQL I used to use:

I think you should include the exact version of ubuntu that you are using. New ubuntu versions use upstart, which has its own gotchas.

Edit:I am usning Xubuntu latest version 10.04, but id don’t want to use and GUI for this, only from terminal. Looks like @prhq got something in his answer. What is upstart?

3 Answers 3

In most linux distributions you can manually start/stop services by (as root or using sudo) running the following commands:

# /etc/init.d/apache2 start # /etc/init.d/mysqld start # /etc/init.d/apache2 stop # /etc/init.d/mysqld stop 

Which services that are automatically started is controlled by file links in /etc/rc[runlevel].d/ . Find your current runlevel by using the command «runlevel» as root

Which here indicates runlevel 2 Now you just have to remove those files in /etc/rc2.d/ which you don’t want started.

Removing apache and Mysql on a desktop is usually ok, but be aware of removing other services.

This is rather misleading, even if you said «most distributions». I would qualify your recipe as distro specific.

Which did you have in mind? I can only think of ArchLinux(but those users should already know what they are doing). Of course some distros have specific tools, but the above technique works on them as well.

Quite strange, i can see a file called S91apache2 in the /etc/rc2.d directory, i guess it starts the apache2 . but i can’t find any file regarding MySQL. Where can i learn about this auto-starting daemons?

Then the mysql server might not be configured for automatic start. This site looks like having a good explanation: yolinux.com/TUTORIALS/LinuxTutorialInitProcess.html

Читайте также:  Аппаратный raid массив linux

For Ubuntu versions that use systemd (15.04 and later) use:

systemctl disable service 

This will do the job. It will disable the service and won’t restart after a reboot. To temporarily enable simply start the service. Not enable.

To find the service name use

systemctl start service — Use it to start a service. Does not persist after reboot

systemctl stop service — Use it to stop a service. Does not persist after reboot

systemctl restart service — Use it to restart a service

systemctl status service — Shows the status of a service. Tells whether a service is currently running.

systemctl enable service — Turns the service on, on the next reboot or on the next start event. It persists after reboot.

systemctl disable service — Turns the service off on the next reboot or on the next stop event. It persists after reboot.

Ubuntu 10.04 is in the middle of a transition between two service management systems: SysVinit (the traditional system, used by most Linux distributions) and Upstart (a newer system pushed by Ubuntu and becoming available in more and more distributions).

SysVinit service management scripts are in /etc/init.d . You can start the service with /etc/init.d/SERVICENAME start and stop it with /etc/init.d/SERVICENAME stop . Whether the service is started automatically on boot depends on the presence of symbolic links in /etc/rc?.d where ? is a digit from 2 to 5 (the runlevel). The easiest way to prevent a service from starting automatically on boot is to use update-rc.d SERVICENAME disable .

Upstart service management configuration files are in /etc/init . You can start the service with start SERVICENAME and stop it with stop SERVICENAME . The configuration file /etc/init/SERVICENAME.conf contains a line indicating when to start the service: start on … . An easy way of disabling these services is to change that line to start on never and (…) . If you don’t want to edit the file, you can also completely disable the service without confusing the packaging system by renaming it to not end in .conf .

dpkg-divert --add --local --divert /etc/init/foo.conf.disabled --rename /etc/init/foo.conf 

As of Ubuntu 10.04, Apache comes with a SysVinit script and Mysql comes with an Upstart script.

Источник

How to Disable Autostart for a Service at boot on Linux CentOS 7 / RHEL 7

In CentOS 7 and Red Hat Enterprise Linux (RHEL) 7, you can disable the autostart of a service at boot time. This can be useful when you want to prevent a service from starting automatically during the boot process. In this guide, we will go through the steps to disable the autostart of a service at boot on CentOS 7 / RHEL 7.

Читайте также:  Nvidia opencl driver linux

Step 1: Open the Terminal

The first step is to open the terminal on your CentOS machine. You can do this by clicking on the terminal icon or by using the keyboard shortcut “Ctrl + Alt + T”.

Step 2: Check the Status of the Service

Before disabling the autostart of a service, you should check the current status of the service. You can do this by using the following command:

Replace “” with the name of the service you want to disable the autostart for.

[root@centos7 ~]# sudo systemctl disable named-chroot.service rm '/etc/systemd/system/multi-user.target.wants/named-chroot.service'

Step 3: Disable the Autostart of the Service

To disable the autostart of a service, you need to use the “systemctl” command with the “disable” option. You can do this by using the following command:

Replace “” with the name of the service you want to disable the autostart for.

Step 4: Verify the Autostart Status of the Service

To verify that the autostart of the service has been disabled, you can use the following command:

If the output is “disabled”, the autostart of the service has been successfully disabled.

Step 5: Restart the System

After disabling the autostart of the service, it is recommended to restart the system to ensure that the changes take effect. You can do this by using the following command:

Commands Mentioned:

  • sudo – a command that allows users to run programs with the security privileges of another user, typically the superuser.
  • systemctl – a command that is used to control the systemd system and service manager.

Conclusion:

In this guide, we have gone through the steps to disable the autostart of a service at boot on CentOS 7 / RHEL 7. By disabling the autostart of a service, you can prevent it from starting automatically during the boot process. If you have any questions or suggestions, feel free to comment below.

Dimitri Nek

Dimitri is a Linux-wielding geek from Newport Beach and a server optimization guru with over 20 years of experience taming web hosting beasts. Equipped with an arsenal of programming languages and an insatiable thirst for knowledge, Dimitri conquers website challenges and scales hosting mountains with unmatched expertise. His vast knowledge of industry-leading hosting providers allows him to make well-informed recommendations tailored to each client’s unique needs.

Читайте также:  Zfs on linux стабильность

Источник

Disable autostart for a service without uninstalling? [duplicate]

How can I disable autostart for a service without uninstalling? For example, I’d like to leave tomcat installed, but I don’t want it turning on every time I restart.

4 Answers 4

Open terminal ( Ctrl + Alt + T ) and enter the following command:

sudo update-rc.d tomcat disable 

Basically update-rc.d will modify existing runlevel links for the script /etc/init.d/tomcat by renaming start links to stop links.

If your tomcat is tomcat6 you will need to do «sudo update-rc.d tomcat6 disable» else you will get error.

You might want to consider this message in the update-rc.d : The disable|enable API is not stable and might change in the future.

More generic and more visual, with a nice UI: sysv-rc-conf

Uncheck the boxes for tomcat7 (runlevels 2 to 5), quit and that’s it.

cool, that’s a tool I haven’t seen before. It was useful to confirm that the update-rc.d command actually had worked

The disable|enable API is not stable and might change in the future. I suggest you use the following command to remove all the symlinks in /etc/rc?.d/ :

update-rc.d -f tomcat remove 

This one worked for me. I had uninstalled tomcat manually yet it was trying to shut it down before any reboot. Disable without -f parameter yelded «file does not exists».

For upstart jobs, you need to disable service like this (e.g. mysql):

$ sudo -s # echo "manual" > /etc/init/mysql.override # exit 
$ echo "manual" | sudo tee /etc/init/mysql.override > /dev/null 

+ 1 million, this is what worked for me. I was trying to stop transmission-daemon from starting on startup and the update-rc.d method used to work, but it looks like its been converted to an Upstart script now so this is the only method that works

Thanks, this worked for me and disabling mongodb! Couldn’t seem to get it working with echo so I did it the oldschool sudo vi /etc/init/mongodb.override way

Источник

Оцените статью
Adblock
detector