Linux services, runlevels, and rc.d scripts

Reference:

[1] https://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts

A Linux service is an application (or set of applications) that runs in the background waiting to be used, or carrying out essential tasks.

In the directory /etc/rc.d, you will find either a set of files named rc.0, rc.1, rc.2, rc.3, rc.4, rc.5, and rc.6, or a set of directories named rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d. You will also find a file named /etc/inittab including info about runlevels.The system uses these files (and/or directories) to control the services to be started.The boot process uses these parameters to identify the default runlevel and the files that will be used by that runlevel.

About runlevel, you might assume that this refers to different levels that the system goes through during a boot up. Instead, think of the runlevel as the point at which the system is entered. Runlevel 1 is the most basic configuration (simple single user access using an text interface), while runlevel 5 is the most advanced (multi-user, networking, and a GUI front end). Runlevels 0 and 6 are used for halting and rebooting the system. The following table shows a generic list of configurations (and some examples of different distros) taken from Linux - The Complete Reference (R.Peterson, Osbourne/McGraw-Hill).


Run Level


Generic


Fedora Core


Slackware


Debian

0 Halt Halt Halt Halt
1 Single-user mode Single-user mode Single-user mode Single-user mode
2 Basic multi-user mode (without networking) User definable (Unused) User definable - configured the same as runlevel 3 Multi-user mode
3 Full (text based) multi-user mode Multi-user mode Multi-user mode - default Slackware runlevel
4 Not used Not used X11 with KDM/GDM/XDM (session managers) Multi-user mode
5 Full (GUI based) multi-user mode Full multi-user mode (with an X-based login screen) - default runlevel User definable - configured the same as runlevel 3 Multi-user mode
6 Reboot Reboot Reboot Reboot
0:关机 1:单用户模式 2:无网络支持的多用户模式 3:有网络支持的多用户模式 4:保留,未使用 5:有网络支持有X-Window支持的多用户模式 6:重新引导系统,即重启 Linux 系统处于正常状态时,服务器主机开机(或重新启动)后,能够由系统引导器程序自动引导 Linux 系统启动到多用户模式,并提供正常的网络服务。如果系统管理员需要进行系统维护或系统出现启动异常时,就需要进入单用户模式或修复模式对系统进行管理了。使用单用户模式有一个前提,就是您的系统引导器(grub)能正常工作,否则要进行系统维护就要使用修复模式。特注:进入单用户模式,没有开启网络服务,不支持远程连接 Linux 系统中不同的运行级别(Run Level)代表了系统的不同运行状态,例如 Linux 服务器正常运行时处于运行级别3,是能够提供网络服务的多用户模式;而运行级别 1 只允许管理员通过服务器主机的单一控制台进行操作,即“单用户模式”。

Linux Boot Process

When you boot your computer, the first thing that it will do is load the bootloader -- either GRUB or LILO in most cases. The bootloader will then load the Linux kernel -- the core operating system. Next, a process called init starts. This process reads the file /etc/inittab to establish the runlevel to use. The runlevel is the start mode for the computer.

Once init knows the runlevel it will look for the appropriate files or directories as defined in /etc/initab.

Init will then either run the script files defined by /etc/initab, or run the script files in the directories defined by /etc/initab (depending on the set up of your system).

Finally, init will present you with the logon mode that you‘ve selected.

时间: 2024-07-29 02:16:45

Linux services, runlevels, and rc.d scripts的相关文章

Linux树莓派中/etc/rc.local不执行的问题

最近研究在树莓派中嵌入式开发java程序,并打算和Salesforce进行通信.需要开发一个java的web server,不想弄那么复杂,于是打算在linux系统中/etc/rc.local写想要执行的语句,比如java –jar /root/test.jar.但是在开机的时候,发现/etc/rc.local里面的命令并没有执行,这是个头疼的事情.第一次我考虑到的是,可能在里面的某些语句,比如service isc-dhcp-server start.这类开启服务的语句,如果dhcp服务在ho

Linux开机启动文件rc.local无法执行怎么办?

rc.local是Linux系统中的一个重要的开机启动文件,每次开机都要执行这个文件.但是有一些用户的Linux系统无法执行这个文件,并导致了一系列的问题.遇到这个问题我们应该怎么办呢? 在Linux系统中,有一个重要的开机自动启动脚本文件: /etc/rc.local--->/etc/rc.d/rc.local 不小心删除了,然后重新创建了一个,但问题出来了,无法自动执行了. 原因: 开机启动的/etc/rc.d/rc3.d/ 文件夹下的链文件失去效应了,修改下即可. 解决方法: 把/etc/

Linux开机启动程序rc.local

目录 1./etc/rc.local是/etc/rc.d/rc.local的软链接 2.rc.local文件的原始内容 3.rc.local文件的配置 4.应用经验 5.版权声明 在CentOS7中,实现开机启动程序主要有两种方法: 1)把要启动的程序配置成自定义的系统服务,该方法我已经介绍过,请阅读:CentOS7添加自定义系统服务. 2)在/etc/rc.local脚本文件中编写启动程序的脚本,本文将详细介绍这种方法. 1./etc/rc.local是/etc/rc.d/rc.local的软

Linux启动脚本rc.local 不执行的解决方法

目录 1./etc/rc.local是/etc/rc.d/rc.local的软链接 2.看看/etc/rc.d/rc.local的权限 3.修改/etc/rc.d/rc.local的可执行权限 4.重启解决 5.版权声明 如果Linux启动脚本/etc/rc.local文件没有被执行,可能是因为rc.loca文件没有可执行权限,按以下步骤解决这个问题. 1./etc/rc.local是/etc/rc.d/rc.local的软链接 执行ls -l /etc/rc.local看看. 2.看看/etc

linux笔试

在对linux基本知识的归纳总结之后,这里是一份linux的测试题.希望能帮助大家复习和熟悉linux知识. 一.选择题 1.cron 后台常驻程序 (daemon) 用于:  A. 负责文件在网络中的共享  B. 管理打印子系统 C. 跟踪管理系统信息和错误  D. 管理系统日常任务的调度 2.在大多数Linux发行版本中,以下哪个属于块设备 (block devices) ?  A. 串行口 B. 硬盘  C. 虚拟终端 D. 打印机 3.下面哪个Linux命令可以一次显示一页内容?  A.

linux复习

linux的特点           - 免费的/开源           - 支持多线程/多用户           - 安全性好           - 对内存和文件管理优越       关机命令       shutdown -h now(立即进行关机)      shutdown -r now (现在重新启动计算机)      reboot (现在重新启动计算机)       进入桌面       startx       用户登录       登录时尽量少用root账户登录,因为它是系

linux测试题

http://www.2cto.com/os/201307/225399.html  2013最新linux运维面试题 在对linux基本知识的归纳总结之后,这里是一份linux的测试题.希望能帮助大家复习和熟悉linux知识. 一.选择题 1.cron 后台常驻程序 (daemon) 用于:  A. 负责文件在网络中的共享  B. 管理打印子系统 C. 跟踪管理系统信息和错误  D. 管理系统日常任务的调度 2.在大多数Linux发行版本中,以下哪个属于块设备 (block devices) 

linux中inittab文件详解

init的进程号是1(ps -aux | less),从这一点就能看出,init进程是系统所有进程的起点,Linux在完成核内引导以后,就开始运行init程序. init程序需要读取配置文件/etc/inittab.inittab是一个不可执行的文本文件,它有若干行指令所组成. 理解Runlevel: runlevel用来表示在init进程结束之后的系统状态,在系统的硬件中没有固定的信息来表示runlevel,它纯粹是一种软件结构.init和inittab是runlevel影响系统状态的唯一原因

【转】linux中inittab文件详解

原文网址:http://www.2cto.com/os/201108/98426.html linux中inittab文件详解 init的进程号是1(ps -aux | less),从这一点就能看出,init进程是系统所有进程的起点,Linux在完成核内引导以后,就开始运行init程序. init程序需要读取配置文件/etc/inittab.inittab是一个不可执行的文本文件,它有若干行指令所组成. 理解Runlevel: runlevel用来表示在init进程结束之后的系统状态,在系统的硬