Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Ubuntu system Service Settings Command how to use chkconfig

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the ubuntu system service settings command chkconfig how to use, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Installation commands:

Sudo apt-get install chkconfig

(sysv-rc-conf can be used instead)

Function description: check and set up various services of the system.

Syntax: chkconfig [--add] [--del] [--list] [system Services] or

Chkconfig [--level] [system Services] [on/off/reset]

Note: this is a program developed by redhat in accordance with gpl rules, which can query which system services, including various daemon, will be executed by the operating system in each execution level (runlevel).

Linux os divides the operating environment into the following seven levels:

0: power on (please do not switch to this level)

1: text interface in single user mode

2: multi-user mode text interface, without network file system (NFS) function

3: multi-user mode text interface, with network file system (NFS) function

4: some distributions of linux use this level to enter x windows system

5: some distributions of linux use this level to enter x windows system

6: restart

Parameter:-- add adds the specified system service

-- del deletes the specified system service

-- level specifies the execution level in which the system service should be turned on or off

-- list lists all system services and level codes that can currently be managed from the chkconfig directive

On/off/reset registers at the specified execution to turn on / off / reset the system service

The chkconfig command is mainly used to update (start or stop) and query the run-level information of system services. Keep in mind that chkconfig does not automatically disable or activate a service immediately, it simply changes symbolic connections.

Syntax:

Chkconfig-- list [name]

Chkconfig-add name

Chkconfig-del name

Chkconfig [--level levels] name

Chkconfig [--level levels] name

Chkconfig displays usage when it runs with no parameters. If you add the service name, check to see if the service is started at the current run level. If yes, return true, otherwise return false. If on,off or reset is specified after the service name, chkconfi changes the startup information of the specified service. On and off refer to the service being started and stopped, respectively, and reset refers to the startup information of the reset service, regardless of what is specified in the problematic initialization script. On and off switches, the system is only valid for runlevel 3, 4 and 5 by default, but reset is valid for all runlevels.

The-- level option specifies the runlevel to view, not necessarily the current runlevel.

It is important to note that there can be only one start script or stop script per runlevel. When switching runlevels, init does not restart services that have already been started, nor does it stop services that have been stopped again.

Chkconfig-- list: displays the running status information (on or off) of all runlevel system services. If name is specified, only the status of the specified service at different runlevels is displayed.

Chkconfig-- add name: add a new service. Chkconfig ensures that each runlevel has a startup (S) or kill (K) entry. If it is missing, it is automatically created from the default init script.

Chkconfig-- del name: delete the service and remove the associated symbolic link from / etc/rc [0-6] .d.

Chkconfig [--level levels] name: sets whether a service is started, stopped, or reset at the specified runtime level. For example, to stop the nfs service at the 3re4p5 runlevel, the command is as follows:

Chkconfig-level 345 nfs off

Run-level files:

Each service managed by chkconfig needs to add two or more lines of comments to the script under the corresponding init.d. The first line tells chkconfig the default run level to start and the priority to start and stop. If a service is not started at any runtime level by default, use-instead of runlevel. The second line describes the service and can be commented with / across lines.

For example, random.init contains three lines:

# chkconfig: 2345 20 80

# description: Saves and restores system entropy pool for /

# higher quality random number generation.

In addition, the concept of the runtime level of the Linux system is introduced:

There are many kinds of runlevels in Linux, the common one is the multi-user 2jin3pr 4jin5, many people know that 5 is the level at which X-Windows is run, and 0 is the shutdown. Run-level changes can be switched through the init command. For example, suppose you want to keep the system in a single-user state, then you can use init1 to switch. During the run-level switching of Linux, the system automatically looks for the files starting with K and S under the corresponding runtime directory / etc/rc [0-6] .d, and executes these scripts in the following numerical order. The maintenance of these scripts is tedious, and Linux provides chkconfig commands to update and query system services at different runtime levels.

Example:

1. View the status of services at different levels of execution:

$chkconfig-list

two。 List the startup of the system service vsftpd at each execution level:

$chkconfig-list vsftpd

3. At execution level 3, 5, shut down the vsftpd system service:

$chkconfig-- level 35 vsftpd off

4. Turn on the vsftpd system service at execution level 2, 3, 5:

$chkconfig-- level 235 vsftpd on

5. Turn off some services that you don't need->

If there is no printer:

Chkconfig-level 235 cups off

If there is no local area network:

Chkconfig-level 235 smb off

If the remote user login is not required:

Chkconfig-level 235 sshd off

If you don't need a timed task:

Chkconfig-level 235 crond off

If you do not need to add new hardware:

Chkconfig-level 235 kudzu off

Thank you for reading this article carefully. I hope the article "how to use ubuntu system Service setup Command chkconfig" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report