Ubuntu runlevel修改

来源:互联网 发布:linux挂载emc磁盘阵列 编辑:程序博客网 时间:2024/06/06 10:07

安装Unbuntu 12.04。

据说Ubunut的一个UI相对友好的Linux版本,但我的需求是仅仅将其作为服务器使用,偶尔用用UI界面。所以我希望启动Ubuntu时,直接进入Shell命令行。

印象中,Linux可以通过修改runlevel来改变启动级别,以达到我上述目的。但Ubuntu却显得有点特别。

先说方案:

# 查看当前启动级别runlevel  # 结果应该是2                           # 将runlevel设置为3sudo vi /etc/inittab                           # 增加下面这一行到inittab中id:3:initdefault:                           ## 以上仅仅是一个启动级别的改动,但是3和2基本是没有区别。下面需要对3进行定制sudo vi /etc/init/lightdm.conf                           # 将start on ((filesystem           and runlevel [!06]           and started dbus           and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1                or stopped udev-fallback-graphics))          or runlevel PREVLEVEL=S)                           # 修改为start on ((filesystem           and runlevel [!036]           and started dbus           and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1                or stopped udev-fallback-graphics))          or runlevel PREVLEVEL=S)                           # 使得lightdm不在级别3中启动

改变当前启动级别的好处是,当你有时需要进入GUI界面时,直接执行下面的命令即可:

sudo init 2

总结:

1. 变更当前启动级别
2. 定制新的启动级别

=======================

关于Ubuntu的启动级别与Redhat的对比:
Debian系(ubuntu是基于debian)的Linux一直是用runlevel 2来默认启动,并且runlevel定义也与redhat有区别。

debian的runlevel级别定义如下:

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

可以发现2~5级是没有任何区别的。

而redhat的runlevel级别定义如下:

0 – Halt
1 – Single
2 – Not used/User definable
3 – Full multi-user NO display manager
4 – Not used/User definable
5 – Full multi-user with display manager (GUI)
6 – Reboot

对应的配置文件夹如下:

/etc/rc0.d Run level 0
/etc/rc1.d Run level 1
/etc/rc2.d Run level 2
/etc/rc3.d Run level 3
/etc/rc4.d Run level 4
/etc/rc5.d Run level 5
/etc/rc6.d Run level 6

再者,网上有很多文章都是关于如何disable gdm (Graphic Display Manager ?)的,这是Ubuntu在11.04之前的默认GUI引擎,但现在已经变更为lightdm了。所以关于gdm的设置也就无效了。

原创粉丝点击