Linux boot with level type
-
- View current run level
- Switch run level
- The main startup steps of the Linux system:
-
- 1. Read the MBR information and start Boot Manager
- 2. Load the system kernel and start the init process
- 3. The init process reads the information in the /etc/inittab file and enters the preset run level,
- 4. Start the Xwindow server xorg according to the corresponding script in the /etc/rcS.d/ folder
- 5. Start the login manager and wait for the user to log in
- Use of tool sysv-rc-conf
- Common system services
- Self-startup
The general operating level of linux is 6 levels (of which 4 is generally not defined, but it should be possible): 0-6,
0 :关机
1 :单用户mod
2–5:为多用户模式,基本无区别(这与一般的linux不一样,2为默认级别)
6 :重启
S :单用户恢复模式,运行很少进程以及服务
参考:http://book.51cto.com/art/200905/126183.htm
查看运行级别: $runlevel
更改运行级别: telinit *(0 -6 S)(一般没必要更改为S)
在/etc/rc$.d目录种定义了各种运行级别的运行服务;
要在ubuntu中关闭X服务,x客户端,桌面启动器等进程就行了
那你可以直接终止这些服务就可以了,但是我门要定义的是一开机就进入终端的模式。(ubuntu server版就默认进入终端,那是应为本来就没配置图形X服务)
由于2-5都是大致一样的,在/etc/rc1-5.d目录中找不到桌面启动器的服务,可能老版本的有,我的是ubuntu11.10,
然后在/etc/init/lightgdm.conf中找到了关于启动器的配置,默认是从2-5都是启动X的,那可以修改该配置,使某个运行级别不启动桌面启动即可。(这是linuxmint的配置)ubuntu的应该为gdm的配置。
下面的文本是说明ubutnu虽然使用的upstart的,但也遵循intitab的
修改/etc/inittab (没有的话新建一个,root用户)
View current run level
runlevel
#runlevel 显示上次的运行级别和当前的运行级别,“N”表示没有上次的运行级别
Switch run level
int [0123456Ss]
#即在 init 命令后跟一个参数,此参数是要切换到的运行级的运行级代号,如:用 init 0 命令关机;用 init 6 命令重新启动。
The main startup steps of the Linux system:
1. Read the MBR information and start Boot Manager
Windows uses NTLDR as the Boot Manager. If multiple
versions of Windows are installed in your system , you need to select the system you want to enter in NTLDR.
Linux usually uses GRUB with powerful functions and flexible configuration as Boot Manager.
2. Load the system kernel and start the init process
The init process is the root process of Linux, and all system processes are its child processes.
3. The init process reads the information in the /etc/inittab file and enters the preset run level,
Run the scripts in the corresponding folder of the run level in sequence. The script is usually started with the start parameter
and points to a program in the system.
Normally, the startup script in the /etc/rcS.d/ directory is executed first, and then the
/etc/rcN.d/ directory. For example, if you set the run level to 3, its corresponding startup
directory is /etc/rc3.d/.
4. Start the Xwindow server xorg according to the corresponding script in the /etc/rcS.d/ folder
Xwindow is a graphical user interface system under Linux.
5. Start the login manager and wait for the user to log in
The Ubuntu system uses GDM as the login manager by default. After you
enter the user name and password in the login manager interface , you can log in to the system. (You can
find a link called S13gdm in the /etc/rc3.d/ folder)
Use of tool sysv-rc-conf
#安装
sudo apt-get install sysv-rc-conf
#使用
sudo sysv-rc-conf
The operation interface is very simple, you can use the mouse to click, or use the keyboard arrow keys to locate, use the space bar to select, use Ctrl+N to turn to the next page, Ctrl+P to turn to the previous page, and Q to exit.
Common system services
APP | Description |
---|---|
acpi-support | Advanced power management support |
acpid acpi | Daemon. These two are used for power management and are very important |
alsa | Sound subsystem |
alsa-utilsanacron | The cron subsystem will execute the scheduled tasks during system shutdown the next time the system is running |
apmd | acpi extension |
etc | Task scheduling system similar to cron. Suggest to close |
binfmt-support | The core supports other binary file formats. Suggest to open |
bluez-useful | Bluetooth device support |
bootlogd | Start the log. Turn it on |
cron | Task scheduling system, it is recommended to open |
cupsys | Printer subsystem. |
dbus | Message bus system (message bus system). Very important |
dns-clean | When using a dial-up connection, clear the dns information. |
evms | Enterprise Volumn Management system |
fetchmail | Mail user agent daemon, used to collect mail |
gdm gnome | Login and desktop manager. |
gdomapgpm | Mouse support in the terminal. |
halt | Don't touch it. |
hdparm | Adjust the hard disk script, the configuration file is /etc/hdparm.conf. |
hibernate | System hibernation |
hotkey-setup | Notebook function key support. Support types include: HP, Acer, ASUS, Sony, Dell, and IBM. |
hotplug and hotplug-net | Plug and play support is more complicated, it is recommended not to touch it. |
hplip HP | Printer and graphics subsystem |
ifrename | Network interface rename script. If you have ten network cards, you should turn it on |
inetd | In the file /etc/inetd.conf, comment out all the services you don't need. If the file does not contain any services, it is safe to close it. |
klogd | important. |
linux-restricted-modules-common | Restricted module support. |
/lib/linux-restricted-modules/ | The modules in the folder are restricted modules. For example, for some drivers, if you are not using a restricted module, you do not need to enable it. |
lvm | Logical volume management system support. |
makedev | It is very important to create a device file. |
mdamd | Disk Array |
module-init-tools 从/etc/modules | Load the expansion module, it is recommended to open it. |
networking | Network support. It is very important to activate the network by default in the /etc/network/interfaces file. |
ntpdate | It is recommended to close the time synchronization service. |
pcmcia pcmcia | Device support. |
powernowd | Mobile CPU energy saving support |
ppp and ppp-dns | Dial-up connection |
readahead | Preload library files. |
reboot | Don't touch it. |
resolvconf | Configure DNS automatically |
rmnologin | Clear nologin |
rsync | rsync daemon |
sendsigs | Send signal during restart and shutdown |
single | Activate single user mode |
ssh | ssh daemon. Suggest to open |
stop-bootlogd | Stop the bootlogd service in 2,3,4,5 run levels |
sudo | Check sudo status. important |
sysklogd | System log |
udev & udev-mab | Userspace dev filesystem (userspace dev filesystem). important |
umountfs | Unmount the file system |
urandom | Random number generator |
usplash | Boot screen support |
vbesave | Graphics BIOS configuration tool. Save the state of the graphics card |
xorg-common | Set up the X service ICE socket. |
adjtimex | Tools to adjust the core clock |
dirmngr | Certificate list management tool, works with gnupg. |
hwtools irqs | Optimization tool |
libpam-devperm | After the system crashes, a daemon used to repair device file permissions. |
lm-sensors | Onboard sensor support |
mdadm-raid | Disk Display Manager |
screen-cleanup | Script to clear boot screen |
xinetd | An inetd super daemon that manages other daemons |
Self-startup
touch /etc/init.d/xxDaemo.sh
Write the following content, the purpose is to establish environment variables, start the corresponding program
#!/bin/sh
#FOR XWindow
xhost +
#FOR QT
export TSLIB_ROOT=/usr/QT_5.14.1_INSTALL/TSLIB_INSTALL
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_TSEVENTTYPE=input
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointercal
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CONSOLEDEVICE=none
#
export QT_ROOT=/usr/QT_5.14.1_INSTALL/QT_5.14.1_INSTALL
export QML_IMPORT_PATH=$QT_ROOT/qml
export QML2_IMPORT_PATH=$QT_ROOT/qml
export QT_QPA_PLATFORM_PLUGIN_PATH=$QT_ROOT/plugins
export QT_QPA_GENERIC_PLUGINS=tslib
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:rotation=270:mmsize=240x160
export QT_QPA_FONTDIR=/usr/share/fonts/ms
export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event1
export QT_QPA_FB_HIDECURSOR=1
export QT_DEBUG_PLUGINS=0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/X11_INSTALL/lib:/usr/XCB_INSTALL/lib:$QT_ROOT/lib:$TSLIB_ROOT/lib
export PATH=$PATH:$TSLIB_ROOT/bin:/opt/opencv/bin:$QT_ROOT/bin
start() {
start-stop-daemon -S -q -m -b -p /var/run/opencv.pid \
--exec /opt/opencv/bin/opencv
[ $? = 0 ] && echo "START opencv OK" || echo "START opencv FAIL"
}
stop() {
# printf "Stopping gnnga_screen: "
start-stop-daemon -K -q -p /var/run/opencv.pid
[ $? = 0 ] && echo "STOP opencv OK" || echo "STOP opencv FAIL"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
Add executable permissions
chmod +x /etc/init.d/xxDaemo.sh
Establish soft connection
#确认当前运行级别,当然也可以依据上面的命令使用int X设置一个运行级别
runlevel
#得到数字后再rcX.d中建立软连接,X为得到的数字
ln -s /etc/init.d/xxDaemo.sh /etc/rcX.d/S99xxDaemo