ubuntu 11.04 改变默认运行等级

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
马里奥遇上麦兜
帖子: 4
注册时间: 2010-10-14 18:35

ubuntu 11.04 改变默认运行等级

#1

帖子 马里奥遇上麦兜 » 2011-07-23 1:10

想将ubunut 11.04 的默认运行级别改为命令行模式,按照下面的方法来做,
"Ubuntu开机启动到字符界面

默认安装的Ubuntu Linux会直接到图形界面。不过很多时候我并不需要在图形界面上做事,字符界面的命令行就足够了。想起在RedHat里可以通过修改/etc /inittab来把默认运行等级(run level)从5改到3来实现,不幸的是Ubuntu中并没有这个文件。刚刚在Google上找了一遍,发现Ubuntu也是可以兼容inittab的, 不过需要自己手工建一个罢了。

Ubuntu安装后默认的run level为2,这个可以用runlevel命令查看。因为runlevel=2,所以在启动过程中自动执行/etc/rc2.d/目录下的以S开头的脚 本。Ubuntu之所以能直接启动到图形界面,是由于运行gdm所致。所以,只要把gdm的启动脚本禁用就可以了,方法就是把文件名的第一个字母S改成 K:

cd /etc/rc2.d
sudo mv S30gdm K30gdm
这是一种方法,而且非常简单。但我更习惯于设定一个新的run level,让那个新的run level作为启动到字符界面。这样便于管理。Ubuntu没有/etc/inittab文件,只好新建一个了,内容只有一行:

id:3:initdefault:
这样下次启动时就会自动运行/etc/rc3.d/目录下的脚本,而不再是/etc/rc2.d/中的。所以接下来要进入到/etc/rc3.d/中,看看gdm的启动脚本文件名:

ls -l *gdm
如果是以S打头的,把文件名改成以K打头的就行了。"


但是,敲入 ls -l *gdm 时,提示"no such file or directory"
查看一下rc3.d里面内容如下
root@ubuntu:/etc/rc3.d# ls -al
total 20
drwxr-xr-x 2 root root 4096 2011-07-18 15:53 .
drwxr-xr-x 130 root root 12288 2011-07-23 00:46 ..
-rw-r--r-- 1 root root 677 2011-03-29 04:10 README
lrwxrwxrwx 1 root root 20 2011-07-14 20:23 S20kerneloops -> ../init.d/kerneloops
lrwxrwxrwx 1 root root 27 2011-07-14 20:23 S20speech-dispatcher -> ../init.d/speech-dispatcher
lrwxrwxrwx 1 root root 19 2011-07-14 20:23 S25bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root 23 2011-07-14 21:16 S38open-vm-tools -> ../init.d/open-vm-tools
lrwxrwxrwx 1 root root 20 2011-07-14 20:23 S50pulseaudio -> ../init.d/pulseaudio
lrwxrwxrwx 1 root root 15 2011-07-14 20:23 S50rsync -> ../init.d/rsync
lrwxrwxrwx 1 root root 15 2011-07-14 20:23 S50saned -> ../init.d/saned
lrwxrwxrwx 1 root root 19 2011-07-14 20:23 S70dns-clean -> ../init.d/dns-clean
lrwxrwxrwx 1 root root 18 2011-07-14 20:23 S70pppd-dns -> ../init.d/pppd-dns
lrwxrwxrwx 1 root root 14 2011-07-18 15:53 S75sudo -> ../init.d/sudo
lrwxrwxrwx 1 root root 24 2011-07-14 20:23 S90binfmt-support -> ../init.d/binfmt-support
lrwxrwxrwx 1 root root 22 2011-07-14 20:23 S99acpi-support -> ../init.d/acpi-support
lrwxrwxrwx 1 root root 21 2011-07-14 20:23 S99grub-common -> ../init.d/grub-common
lrwxrwxrwx 1 root root 18 2011-07-14 20:23 S99ondemand -> ../init.d/ondemand
lrwxrwxrwx 1 root root 18 2011-07-14 20:23 S99rc.local -> ../init.d/rc.local
root@ubuntu:/etc/rc3.d# cd ..
root@ubuntu:/etc# cd rc2.d
root@ubuntu:/etc/rc2.d# ls -l *gdm
ls: cannot access *gdm: No such file or directory

求各位大虾指导指导...小生无以为报,谢谢.
附件
上边命令图示
上边命令图示
头像
peteryeh64
论坛版主
帖子: 9379
注册时间: 2008-12-20 15:43
系统: 家kubuntu20.04
来自: 心靈深處

Re: ubuntu 11.04 改变默认运行等级

#2

帖子 peteryeh64 » 2011-07-23 8:32

...不知道LZ是不是說讓 "ubuntu开机进入命令行" 的意思...?
[论坛版主行为规定]+[PITIVI簡易教程]+[ubuntu裝迅雷]
[releases.ubuntu.com]+[cdimage.ubuntu.com]+[old-releases.ubuntu.com]
[學ubuntu必須拜讀懶蝸牛"笨兔兔的故事"=viewtopic.php?f=112&t=162040][Linux明日的希望在中國]
头像
liu滔
帖子: 7212
注册时间: 2010-10-09 23:01

Re: ubuntu 11.04 改变默认运行等级

#3

帖子 liu滔 » 2011-07-23 10:42

peteryeh64 写了:...不知道LZ是不是說讓 "ubuntu开机进入命令行" 的意思...?
是的,也就是开机运行在runlevel 3~不过我也不会,帮顶
长头发的和尚
帖子: 12134
注册时间: 2008-01-11 17:02

Re: ubuntu 11.04 改变默认运行等级

#4

帖子 长头发的和尚 » 2011-07-23 11:58

没图形界面我会死的...
你往幸福的方向挥挥手,从此我便追随你永不回头。
头像
373992900
帖子: 4202
注册时间: 2010-06-14 13:37

Re: ubuntu 11.04 改变默认运行等级

#5

帖子 373992900 » 2011-07-23 12:30

没图形界面要做什么事?
马里奥遇上麦兜
帖子: 4
注册时间: 2010-10-14 18:35

Re: ubuntu 11.04 改变默认运行等级

#6

帖子 马里奥遇上麦兜 » 2011-07-23 16:54

peteryeh64 写了:...不知道LZ是不是說讓 "ubuntu开机进入命令行" 的意思...?
就是将默认运行等级改为3啊.
马里奥遇上麦兜
帖子: 4
注册时间: 2010-10-14 18:35

Re: ubuntu 11.04 改变默认运行等级

#7

帖子 马里奥遇上麦兜 » 2011-07-23 16:55

373992900 写了:没图形界面要做什么事?
可以切换回来的吗.
readbook
帖子: 2
注册时间: 2009-02-27 10:48

Re: ubuntu 11.04 改变默认运行等级

#8

帖子 readbook » 2011-10-09 13:44

11.04的server版默认是没有桌面的,不安装就行了
hacker85
帖子: 585
注册时间: 2010-02-25 11:19

Re: ubuntu 11.04 改变默认运行等级

#9

帖子 hacker85 » 2012-02-26 20:57

我遇到了和楼主一样的问题。
看你的原理介绍的时候貌似很详细,可是无论是在rc2.d还是在rc3.d里都没有这个gdm文件。
回复