Stop unnecessary services

Stop unnecessary services

Linux starts many unnecessary services (programs) that are not used immediately after installation.
Services that are not used consume server resources unnecessarily just by being started and running, which is not desirable for security measures.
There are two commands to stop services: service and chkconfig, but the service command will cancel the settings and start the stopped service when the server is restarted.
Stop the service with the chkconfig command, which will keep the service stopped even after restarting the server.

chkconfig <Service Name> off

Stop the database mysql using chkconfig
[root@Lion ~]# chkconfig –list mysql
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
↑Check mysql service startup status.
In the above, it is set to start at run levels 2, 3, 4, and 5.

[root@Lion ~]# chkconfig mysql off
↑Execute “chkconfig mysql off” to prevent mysql from starting on all run levels. run “chkconfig mysql off” to prevent mysql from starting at all run levels.

[root@Lion ~]# chkconfig –list mysql
mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
↑Check the status of the mysql service startup again.
 All runlevels are set to off and will not start.