0%

Ubuntu11.04 之后的 runlevel 定义

Ubuntu 是个不错的 Linux 发行版,至少当时我 Linux 启蒙的时候用的就是这个,也习惯了 Debian 的 apt-get 的软件库

然而有时候吧,我开 Linux 只是做做服务器的实验什么的,开机自动进图形界面反而会有一些费时。因此我想让 Ubuntu 启动之后直接进 tty1 的代码界面。

下面开始搞。

Debian 的 runlevel 跟常见的一般 Linux 发行版有些与众不同,一般的定义为:

1
2
3
4
5
6
7
0 - Halt
1 - Single
2 - Full muti-user with display manager(GUI)
3 - Full muti-user with display manager(GUI)
4 - Full muti-user with display manager(GUI)
5 - Full muti-user with display manager(GUI)
6 - Reboot

系统默认启动进去是 runlevel2

2~5 的运行级别被设定成完全相同,我一般习惯于把 GUI 关掉,默认用 CLI 进行登陆,但是又希望需要图形界面的时候能够很快启动,于是就可以从这里下手。默认用一个不带 GUI 的运行模式启动,需要的时候再切换成带有 GUI 的模式进行工作。

GUI 启动配置


Ubuntu11.04 之后的版本 GUI 都使用 Light Display Manager 来进行管理,配置文件在:

/etc/init/lightdm.conf

内容里面开头的一段,设置了在哪一运行级别下启动和停止:

1
2
3
4
5
6
7
8
9
10
11
start on ((filesystem

and runlevel [!06]

and started dbus

and plymouth-ready)

or runlevel PREVLEVEL=S)

stop on runlevel [016]

通过修改 start on 中的内容,可以让其不在我们默认的运行级别中运行。

修改默认运行级别


默认运行级别的设置在这里:

/etc/inittab

可能有默认没有这个文件的情况,貌似我装 14.04 的时候就是这样,新建一个就好。

在里面写上下面这句话,id 后面的数字就是默认的启动级别。(注意最后的冒号不能少!!!)

1
id:3:initdefault: