手机
当前位置:查字典教程网 >操作系统 >Ubuntu/Debian >Ubuntu Update-rc.d命令详细介绍
Ubuntu Update-rc.d命令详细介绍
摘要:Ubuntu或者Debian系统中update-rc.d命令,是用来更新系统启动项的脚本。这些脚本的链接位于/etc/rcN.d/目录,对应...

Ubuntu或者Debian系统中update-rc.d命令,是用来更新系统启动项的脚本。这些脚本的链接位于/etc/rcN.d/目录,对应脚本位于/etc/init.d/目录。在了解update-rc.d命令之前,你需要知道的是有关Linux系统主要启动步骤,以及Ubuntu中运行级别的知识。

一、Linux系统主要启动步骤

读取 MBR 的信息,启动 Boot Manager。

加载系统内核,启动 init 进程, init 进程是 Linux 的根进程,所有的系统进程都是它的子进程。

init 进程读取 /etc/inittab 文件中的信息,并进入预设的运行级别。通常情况下 /etc/rcS.d/ 目录下的启动脚本首先被执行,然后是/etc/rcN.d/ 目录。

根据 /etc/rcS.d/ 文件夹中对应的脚本启动 Xwindow 服务器 xorg,Xwindow 为 Linux 下的图形用户界面系统。

启动登录管理器,等待用户登录。

二、运行级别

Ubuntu中的运行级别

0(关闭系统)

1(单用户模式,只允许root用户对系统进行维护。)

2 到 5(多用户模式,其中3为字符界面,5为图形界面。)

6(重启系统)

切换运行级别

init [0123456Ss]

例如:init 0 命令关机; init 6 命令重新启动

启动项管理工具

sudo install sysv-rc-conf //或者使用带gui的工具bum

sudo sysv-rc-conf

三、update-rc.d命令详解

从所有的运行级别中删除指定启动项

update-rc.d -f remove

按指定顺序、在指定运行级别中启动或关闭

update-rc.d start|stop

实例:update-rc.d apachectl start 20 2 3 4 5 . stop 20 0 1 6 .

解析:表示在2、3、4、5这五个运行级别中,由小到大,第20个开始运行apachectl;在 0 1 6这3个运行级别中,第20个关闭apachectl。这是合并起来的写法,注意它有2个点号,效果等于下面方法:

update-rc.d apachectl defaults

A启动后B才能启动,B关闭后A才关闭

update-rc.d A defaults 80 20

update-rc.d B defaults 90 10

启动和关闭顺序为90,级别默认

update-rc.d defaults 90</p> <p>Insert links using the defaults:

update-rc.d foobar defaults</p> <p>Equivalent command using explicit argument sets:

update-rc.d foobar start 20 2 3 4 5 . stop 20 0 1 6 .</p> <p>More typical command using explicit argument sets:

update-rc.d foobar start 30 2 3 4 5 . stop 70 0 1 6 .</p> <p>Remove all links for a script (assuming foobar has been deleted

already):

update-rc.d foobar remove</p> <p>Example of disabling a service:

update-rc.d -f foobar remove

update-rc.d foobar stop 20 2 3 4 5 .</p> <p>Example of a command for installing a system initialization-and-shut‐

down script:

update-rc.d foobar start 45 S . start 31 0 6 .</p> <p>Example of a command for disabling a system initialization-and-shutdown

script:

update-rc.d -f foobar remove

update-rc.d foobar stop 45 S .

修改LINUX默认启动级别

# 0 – 停机(千万不要把initdefault设置为0 )

# 1 – 单用户模式

# 2 – 多用户,但是没有NFS

# 3 – 完全多用户模式

# 4 – 没有用到

# 5 – X11

# 6 – 重新启动(千万不要把initdefault设置为6 )

# 对各个运行级的详细解释:

0 为停机,机器关闭。

1 为单用户模式,就像Win9x下的安全模式类似。

2 为多用户模式,但是没有NFS支持。

3 为完整的多用户模式,是标准的运行级。

4 一般不用,在一些特殊情况下可以用它来做一些事情。例如在笔记本电脑的电池用尽时,可以切换到这个模式来做一些设置。

5 就是X11,进到X Window系统了。

6 为重启,运行init 6机器就会重启。

修改级别

vi /etc/inittab

把id:3:initdefault:中的3改为5就是默认进入图形界面了

【Ubuntu Update-rc.d命令详细介绍】相关文章:

ubuntu下安装和配置SVN的详细方法介绍

在Ubuntu下如何将chm文件转成pdf格式的方法介绍

Ubuntu如何安装Xtreme以便用于软件应用的下载

Ubuntu下电子书软件Calibre安装使用教程

Ubunt如何安装网络打印机的详细图文步骤

ubuntu14.04怎么建立wifi热点?

Ubuntu 命令技巧大全整理

Ubuntu邮件客户端Thunderbird常用的快捷键

ubuntu安装postgresql和使用方法

在Ubuntu系统下安装Guake来美化终端界面

精品推荐
分类导航