个人工具
登录
查看“启动”的源代码 - Ubuntu中文
页面
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“启动”的源代码
来自Ubuntu中文
←
启动
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
Ubuntu 系统的启动流程、增/删启动项 ==init== Linux 内核启动 init ,init进程ID是1,是所有进程的父进程,所有进程由它控制。 ==/etc/event.d== Ubuntu 的启动由'''upstart'''控制,自9.10后不再使用/etc/event.d目录的配置文件,改为/etc/init。 ==runlevel== 查看当前的运行级别,Ubuntu 桌面默认是2。 <pre>runlevel</pre> Ubuntu 的系统运行级别: <pre> 0 系统停机状态 1 单用户或系统维护状态 2~5 多用户状态 6 重新启动 S </pre> 切换运行级别,执行命令: <pre>int [0123456Ss]</pre> 即在 init 命令后跟一个参数,此参数是要切换到的运行级的运行级代号,如:用 init 0 命令关机;用 init 6 命令重新启动。 ==/etc/rc2.d== 该目录为runlevel=2环境(就是Ubuntu默认情况)的启动项 <pre>qii@ubuntu:/etc/rc2.d$ ls README S20nginx S20xinetd S50rsync S90binfmt-support S99grub-common S19postgresql-8.4 S20speech-dispatcher S25bluetooth S50saned S91apache2 S99ondemand S20fancontrol S20wicd S50cups S70dns-clean S91lighttpd S99rc.local S20kerneloops S20winbind S50pulseaudio S70pppd-dns S99acpi-support </pre> 其中'''S'''表示启动,随后的'''数字'''表示启动的顺序。 手动的话将'''S'''重命名为'''K''',运行 <pre>sudo update-rc.d script defaults</pre> 可以禁用某个服务,不过比较麻烦,方便的方法是'''sysv-rc-conf'''。 ==runlevel下的增/删== ===sysv-rc-conf === 查看/修改不同运行级别的启动项,可以发现Ubuntu(其实是Debian)2-5之间的runlevel效果是一样的。 <pre>sudo apt-get install sysv-rc-conf </pre> <pre>sudo sysv-rc-conf </pre> ===update-rc.d=== 添加启动项,例如mysql <pre>qii@ubuntu:/etc/rc2.d$ sudo update-rc.d mysql defaults update-rc.d: warning: /etc/init.d/mysql missing LSB information update-rc.d: see <http://wiki.debian.org/LSBInitScripts> Adding system startup for /etc/init.d/mysql ... /etc/rc0.d/K20mysql -> ../init.d/mysql /etc/rc1.d/K20mysql -> ../init.d/mysql /etc/rc6.d/K20mysql -> ../init.d/mysql /etc/rc2.d/S20mysql -> ../init.d/mysql /etc/rc3.d/S20mysql -> ../init.d/mysql /etc/rc4.d/S20mysql -> ../init.d/mysql /etc/rc5.d/S20mysql -> ../init.d/mysql </pre> 删除启动项 <pre>qii@ubuntu:/etc/rc2.d$ sudo update-rc.d -f mysql remove Removing any system startup links for /etc/init.d/mysql ... /etc/rc0.d/K20mysql /etc/rc1.d/K20mysql /etc/rc2.d/S20mysql /etc/rc3.d/S20mysql /etc/rc4.d/S20mysql /etc/rc5.d/S20mysql /etc/rc6.d/K20mysql </pre> ===rcconf=== 查看,修改当前运行级别的启动项 <pre>sudo apt-get install rcconf</pre> <pre>sudo rcconf</pre> ==bashrc== Ubuntu默认shell为bash,.bashrc即为配置文件,在用户输入完用户名和密码后生效,可添加启动项目。 ==.profile和.xprofile== <pre>/etc/profile</pre> ==autostart== <pre>/etc/xdg/autostart /usr/share/autostart /usr/share/gdm/autostart /usr/share/gnome/autostart ~/.config/autostart ~/.kde/share/autostart ~/.local/share/autostart </pre> 这些目录下的启动项目是这样的文件(举例) <pre>Launchy.desktop</pre> KDE SC 4系统设置中设定的启动项便是 <pre>~/.config/autostart</pre> 只在KDE中自动启动,就是设定.desktop文件的字段 <pre>OnlyShowIn=KDE;</pre> [[Category:系统]]
返回至
启动
。