September 10, 2008
實在是找不到 /etc/inittab 呢
翻了這本鳥哥私房菜半天 還是對不太起來
原來Ubuntu自6.10之後就換了"upstart"的方式了 以前的init好就就被代換
以下是找到的資訊
PS 什麼是upstart 說實在我也搞不太懂 待解
====
how to change default runlevel in 7.04?
1./etc/inittab.
You're right. It's gone. It left as of Edgy Eft, as Ubuntu now manages start-up services with "upstart."
The file does exist in pre-Edgy Ubuntu's, and other flavors of Linux, so you were not crazy to look there
.
2. default runlevel in Ubuntu
In redhat/suse, the default run level is 5. I came from RH, and like you, expected the same in Ubuntu. After the "upstart" transition, the notion of runlevels is supposedly gone, but if forced to choose, the default run level is actually 2 in Ubuntu, not 5.
2. You don't want GNOME to start at boot, how?
So yes, in other flavors of Linux, you'd probably just change run levels, because on run level would have X, and another wouldn't. But in Ubuntu, *all* run levels start GNOME, so here's an easier way:
In /etc/rc2.d, you will see a file S13gdm. This starts the GNOME system.
Simply change that file to K13gdm.
# sudo mv S13gdm K13gdm
(It's possible the number between the "S" and the "gdm" will be slightly different than 13. That's OK.)
This leaves the package installed, but just not started at boot.
To start X later, run:
# sudo /etc/init.d/gdm start.
***Ubuntu uses only two runlevels for startup rc1.d and rc2.d.
接著告訴大家怎麼在commandline中換runlevel
http://bbs.nsysu.edu.tw/txtVersion/boards/linux/M.1192639446.D.html
翻了這本鳥哥私房菜半天 還是對不太起來
原來Ubuntu自6.10之後就換了"upstart"的方式了 以前的init好就就被代換
以下是找到的資訊
PS 什麼是upstart 說實在我也搞不太懂 待解
====
how to change default runlevel in 7.04?
1./etc/inittab.
You're right. It's gone. It left as of Edgy Eft, as Ubuntu now manages start-up services with "upstart."
The file does exist in pre-Edgy Ubuntu's, and other flavors of Linux, so you were not crazy to look there
2. default runlevel in Ubuntu
In redhat/suse, the default run level is 5. I came from RH, and like you, expected the same in Ubuntu. After the "upstart" transition, the notion of runlevels is supposedly gone, but if forced to choose, the default run level is actually 2 in Ubuntu, not 5.
2. You don't want GNOME to start at boot, how?
So yes, in other flavors of Linux, you'd probably just change run levels, because on run level would have X, and another wouldn't. But in Ubuntu, *all* run levels start GNOME, so here's an easier way:
In /etc/rc2.d, you will see a file S13gdm. This starts the GNOME system.
Simply change that file to K13gdm.
# sudo mv S13gdm K13gdm
(It's possible the number between the "S" and the "gdm" will be slightly different than 13. That's OK.)
This leaves the package installed, but just not started at boot.
To start X later, run:
# sudo /etc/init.d/gdm start.
***Ubuntu uses only two runlevels for startup rc1.d and rc2.d.
接著告訴大家怎麼在commandline中換runlevel
http://bbs.nsysu.edu.tw/txtVersion/boards/linux/M.1192639446.D.html
ubuntu目前採用upstart而非傳統的sysinit管理方式
各種設定檔案放在/etc/event.d底下
其中的rc-default檔案內容如下
=========================
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
start on stopped rcS
script
runlevel --reboot || true
if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab
|| true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
else
telinit 2
fi
end script
============================
仔細觀察可以發現裡面會先檢查/etc/inittab中有沒有
id:5:initdefault:
這行文字
如果沒有的話,則預設啟動為runlevel 2
如果想要修改預設的runlevel,可以有以下方法
1.增加/etc/inittab並寫入
id:5:initdefault:
2.將/etc/event.d/rc-default裡面最後的
telinit 2
都改成
telinit *
由於ubuntu的其他runlevel有什麼功能並不是十分清楚
個人查看rc3.d到rc5.d其中的內容幾乎都是相同
跟rc2.d的內容僅有差在S99stop-readahead以及S10powernowd.early
如果只是不想要圖形介面的話,可以自行將rc2.d的資料夾內容中的
S13gdm改名為K13gdm或_S13gdm即可
如果還是想要執行圖形介面的話
執行
#/etc/init.d/gdm
即可
以上方法個人沒有實際測試過,僅有根據手上的7.04 LiveCD及以下網誌推論
http://www.wretch.cc/blog/kenshinn&article_id=2536325
http://ku777.blogspot.com/
http://blog.mypapit.net/2007/03/where-can-i-find-inittab-in-ubuntu-edgy-eft-or-feisty-fawn.html
sudo init 0 進入runlevel 0 等於關機
sudo init 6 進入runlevel 6 重新開機
在每一個/etc/rcX.d/ X=0~6
S開頭的是開機會執行,後面數字為順序
K開頭的是依數字大小關閉程式 通常k開頭的只會在rc0.d or rc6.d
如果有k與s開頭 就會先把k開頭跑完在跑s開頭





















