Thursday 29 August 2019

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:


net start mysql

How do I do the same in Linux?



  1. Disabling not-needed daemons from auto-starting?

  2. Starting them only when I need them?



Answer



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


# runlevel
N 2

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.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...