How to modify and view CentOS startup service

Time:2020-2-25

Each time the system is powered on, different services are started according to different runlevel levels. This article will show you how to modify and view the boot service of Linux system.

Press [Ctrl] + [ALT] + [F7] / [F8] to view the services being started when the system is started!!!!

As we all know, Linux provides us with different startup levels 0-6 in 7, so which services will be started by different startup levels. You can use chkconfig — list to view, and you can use chkconfig service name — level 3 {on| of} to modify whether you want to start or stop at another level.

1. For example: to stop the sshd service in the third startup level.

[[email protected] rc3.d]# chkconfig sshd –level 3 off

2. It can also be modified manually. There are many directories corresponding to different runlevels in / etc / rc.d/ directory, which indicates that those services should be started and stopped when entering a certain startup level.

For example:

[[email protected] etc]# ls /etc/rc.d

init.d rc0.d rc2.d rc4.d rc6.d rc.sysinit

rc rc1.d rc3.d rc5.d rc.local

Take RC3. D as an example, which records the services that need to be stopped and started when entering init 3.

Here is the contents of the RC3. D Directory:

[[email protected] etc]# ls /etc/rc.d/rc3.d/

K02avahi-dnsconfd K89pand S25bluetooth

K02dhcdbd K89rdisc S25netfs

K02NetworkManager K91capi S25pcscd

K02NetworkManagerDispatcher K99readahead_later S26apmd

K05conman S04readahead_early S26hidd

The beginning of K represents the service that needs to be stopped at this start level. The number is the order of execution at the time of stop, and then the service is clear.

S starts with those services.

Note: first execute the K start, then the s start. So services starting with s will overwrite services starting with K.

Booting and Linux service of Linux setup program

Here’s just what I know, for example

The requirement is that I use VNC viewer under windows to connect to Linux server

#vncserver

Set the password, and now I can use VNC to connect to the Linux Desktop under windows. At this time, if my Linux server system is restarted, I have to click vncserver again, so I want Linux server to start vncserver automatically when I start it

What are the methods?

1. I can set vncserver as a system service and start it. Use the following command to check whether vncserver is a system service

#chkconfig –list|grep vnc

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

Now we need to set vncserver to start up automatically, using the following command

#chkconfig –level 5 vncserver on#chkconfig –list|grep vnc

vncserver 0:off 1:off 2:off 3:off 4:off 5:on 6:off

At this time, if you restart the system, vncserver will automatically start up as a service. But now if you want to use VNC immediately, just click the command vncserver

2. We can write the command vncserver in the scripts to be run when Linux starts. What are the scripts to be executed when Linux starts?

I know the following:

/etc/rc.local

/etc/rc.sysinit

/etc/inittab

/etc/profile

Remember the difference and connection between Linux service and Linux booting.