Bootloader - LILO or GRUB
Debian/Ubuntu uses GRUB.
- First GRUB finds HDD by its' UUID.
- Then OS kernel needs to see, where it is located on the HDD (by its UUID)
- Then additional tools are loaded to help OS boot (initrd). These tools are not used by the OS after boot (files are in /boot folder)
GRUB files can be edited in /boot/grub folder
Boot Logs + System Logs
dmesg command - changes, that take place in memory in boot process and after that as well
dmesg file (/var/log/dmesg) - what took place in memory during boot. After boot, nothing is written here at all.
messages file (/var/log/messages) - kernel info + application logs (like Apache) are stored here. This is the usual place to go for info in case of problems.
Init
Init - the very first process to boot in a kernel, in charge of all other processes.
pstree command - view process tree with hierarchy
Runlevels
Runlevels are modes, in which Linux runs.
0 - Halt
1 - Single User Mode (recovery mode), no password needed to login as ROOT user
2 - Debian/Ubuntu - default, everything runs here
3 - RedHat/CentOS/SUSE - text mode (no GUI)
4 - Wildcard (no used by default, custom mode)
5 - RedHat/CentOS/SUSE - GUI mode (XWindows)
6 - Reboot
Config file: /etc/inittab
- It tells Init what to do
- Sets default runlevel
Init is being replaced by Upstart (in Ubuntu, later - everywhere else).
Init.d
/etc/init.d
Folder with scripts. Something can be stopped/started here:
./vmware-tools stop - will stop the demon
./vmware-tools start - will start back the demon
./vmware-tools status - check status
*Примечание:
GREP - команда, позволяющая искать текст где угодно. Если для grep указать кусок текста, будут выведены только строки с этим текстом.
EX: /etc# ls -l | grep rc.
Будут выведены только файлы с именем, содержащим "rc." кусок
Запуск разных скриптов в зависимости от Runlevel
В папке /etc есть ряд подпапок, таких как rc2.d, rc3.d и т.д., если зайти в одну из папок, то будет видно, что там находятся ярлыки на запуск скриптов из папки /etc/init.d
При этом имена ярлыков с названием с "K" = Kill process, с буквы "S" = Startup process. Нумерация соответствует последовательности запуска скриптов. Например, сначала нужно запустить службу networking, а потом зависимые от нее, такие как NFS. Если запустить сначала NFS, она повиснет. А убивать, соответственно, надо в обратном порядке.
Написать symbolic link:
ln -s ../init.d/nfs S88
Switching runlevels
Init -t 5 1 # switch to runlevel 1 in 5 seconds
Init -t 10 2 # switch to runlevel 1 in 10 seconds
More proper way is:
telinit -t 5 1 # switch to runlevel 1 in 5 sec
telinit -t 10 2 # switch to runlevel 2 in 10 sec
The difference between init and telinit is:
In some systems like UNIX only telinit command will be accepted. In those systems, init does not accept commands from a user, even a ROOT.
SHUTDOWN
shutdown -k - do not shutdown, just warn people
shutdown -r - reboot
shutdown -r now - reboot in +0 minutes (NOW!)
shutdown 5 [warning message]- shutdown in 5 minutes, send a warning to everybody on the terminal
shutdown 5 &[warning message]- shutdown in 5 min, send a warning, return to console (shutdown process is in background)
shutdown -c - cancel pending shutdown