Slackware linux 101
content:
All processes of the parent run Level Run Level Configure the Running System Change the Run Level Shutdown on the Running System Change the Running Level Shutdown Reference About the author to the evaluation of this article
What happened when booting the Linux machine
Joe "Zonker" BROCKMEIER (JBROCKMEIER@earthlink.net) Advanced Edit, User Friendly Media 2001 March
Joe BROCKMEIER studies the Slackware Linux Init process. He discussed how the system initialized service, what various runages are, and how to add or remove services from the default installation to customize the system.
Linux users are increasingly mature, which means they want to configure the system into tasks they want to complete. But the current Linux distribution is usually included with automatic configured devices and launch services, such as Sendmail or Apache. These distributions do not take into account that they do not change their default settings to run services, such as Apache - users do not know - will let hackers and people who use scripts to mess. And this can be used to better utilize system resources - such as more processor time available for Quake or your favorite compiler. Since the lack of control is a "bad thing", let's take a look at the Linux system boot during the init process, what happens on the various running levels involved, and how to customize the system during system or run level Switch between.
Our example uses the Slackware Linux release on the X86 platform (see Refer to the references later this article). Most information can be used in other Linux distributions, but there is slightly different in the details. In particular, it is better to say that it is more similar to the BSD UNIX structure, although the programs in the latest release of Slackware have made some concessions, but they want to add the service to the startup, but expect These services are the System V directory structure. (See the difference between the sidebar, "BSD and system V init script".)
What happens when all the parents of all processes are booted by Linux machines? After the computer's BIOS completes its task, the system reads the first bit of the hard disk (or the floppy disk, or the CD-ROM, or ZIP drive ... Linux is very flexible), and will encounter the boot loader. Although GRUB and other loading procedures have gradually become popular, it is usually the Linux Loader, which is generally called LILO.
Then LILO puts the Linux kernel into memory and starts to show its magic. The Linux core initializes devices such as SCSI cards, and hardware devices built into other kernels. The kernel is then running init, which is the first process running outside the system except the kernel. If you perform PS AX | GREP 1, you will see the process ID (PID) of the init is 1.
After loading init, it reads inittab to see what to do next. INITTAB tells initTab to enter what run level, and where to find the configuration files for the run level.
The run level run is defined by all services on the system (essentially an operation mode). Linux can have several ways: single user mode, single user networking mode, multi-user mode, starting with multiple user modes of the X window, and so on. This part will explain the concept of running level, which runs on SLACKWARE, which has been called what is called.
The run level is indicated by numbers or letters. Unfortunately, not all Linux distributions can reach a consensus on all run levels. In some releases, the run level 3 is a multi-user way to log in using the X window. And other, such as Slackware, specify the run level 3 into a multi-user way to use the console login. As far as I know, all Linux distributions agree that the run level 0 is "downtime", run level 1 or "s" is a single user mode (will be described in detail later), and the run level 6 is a reboot system. The run level of Slackware is as follows:
Running level 0 = System downtime 1 = Single user mode (XDM, GDM, KDM) Run Level 5 = Never Use Run Level 6 = Reboot Running Level S or S = Single User Way
There is no record run level 7 to 9, in theory, they apply to custom run levels when needed. But I haven't tried to create one yet.
The difference between the BSD and System V init scripts SLACKWARE Linux uses the BSD init script to talk very easy, but what is this? Simulation The Linux and UNIX systems of the BSD INIT style have a /etc/rc.d/ directory, where each running level contains an init script. Therefore, if you want to view or modify the INIT script of the Run Level 4, you should edit file /etc/rc.d/rc.4. On the other hand, its init script is based on the System V system has an independent directory for each run level. Therefore, if you want to edit the run level 4 INIT script, you should find the /etc/rc4.d/ directory and find the script corresponding to the service to be modified in the directory. This difference has led to the design difference between Berkeley Software Distribution (BSD) UNIX and AT & T System V UNIX, which created its own UNIX business versions. They together with VI and Emacs are one of the intense debates of the computer world. SiStem v init layouts are like many Linux distributions, Slackware now also comes with a directory and rc.sysvinit init script for maintaining compatibility.
Running Level Configuration If you are not Slackware Linux, the structure of the configuration file will be greatly different from what I talked. In addition to the initTab file, all Slackware startup configuration files are in the /etc/rc.d/ directory.
By default, there are 5 running RC. * Scripts in the directory, if Symlink is added to RC.6 from RC.0, then there can be 6.
Running level init script is:
Rc.0 = rc.0 file is to RC.6 Symlink Rc.m = multi-user run level 2, 3, and 5 init script rc.k = "management" run level, single user mode rc.s = system initialization Script RC.4 = INIT Script RV.6 (Automatically Guided into the Selected X Session Manager) of RC.6 = Script executed by init when rebooting or stopping the system
The remaining RC. * Files in the catalog are used to launch system services such as networking, kernel modules, PCMCIA, Samba, Apache, NetAtalk, and GPM. If you want a service (such as Apache), you cannot use it at any run level, use Chmod to make the permissions of the file from executable from executable. Remove the file or reach the same effect, but I don't recommend this practice. Maybe you will find the service to be re-enabled in a day later, but I don't know how to do it. Rc.inet1 scripts are responsible for starting basic networking services, such as setting host names (IP and DHCP). Rc.inet2 scripts are responsible for launching all other inet services, such as NFS, packages, SSH servers, and other networked daemons.
All SLACKWARE / Etc/rc.d/rc.* files are Bash Shell scripts, can be hand-edited. However, for the network, you may try the NetConfig utility first. Although multiple name servers are required to be handled manually /etc/resolv.conf, it may handle all the operations you want to perform, and it is very easy to use.
If you are a Linux beginner and want to modify the system, you may make sure you have a boot floppy disk, and you should copy all the RC. * Files you want to edit. If you don't get your mind, I usually save the file as rc. *. OLD, so that they become an unhappun file.
Well using the running system, now the system has already run, however you need to do some operations in a single user mode - what to do? The next part of this article explains how to change the run level at the system runtime, rather than changing the run level by reboot, but also illustrates why this operation is performed and when executed.
Telinit Command: Change the Run Level telinit command on the running system can be used to change the run level. When performing Telinit S (or wants to change any run level) as root, it changes the run level, turn off the previous run level, and then start the next one.
To some extent, you are rebooting a part of the system. However, the ability to shut down and restart services is one of the cutest quality of Linux. Want to change the IP address of the machine? No problem, just make some changes, then restart the networked service. As long as all configurations are correct, backup and running are so fast, it is difficult to argue if they have made changes. On the other, even if the wallpaper on the desktop must be rebooted, try to do this :)
The only thing that does need to reboot or completely shut down Linux machines is if you are adding or changing hardware, assuming that you are using unpackable devices, or have been interrupted and need to make the machine offline to repair damage. Unlike other operating systems, I have never seen the problem of resolving these systems without rebooting without resolving issues. I have managed to use commands such as HDPARM to hang a non-productive machine, I hope this happens.
Suppose you want to perform some system maintenance, and these system maintenance requires the system in a single user mode. For example, use HDPARM to adjust your hard drive. The first step is that Su (switching) to the root user.
Then execute the Telinit command to enable the system to enter a single user mode:
Telinit S -T 60
The variable "-t" is optional; it tells Telinit waiting for 60 seconds before really switching to a single user mode. However, as long as this command is executed, anyone who logs in to the machine will see a warning on the console indicating that the system will switch the run level or will stop within 60 seconds.
In 60 seconds, init will turn off the processes that are not used in single-user mode and enable the system to enter a single user. You will then prompt you to enter the root user password to perform system maintenance. The process used by the system into single-user mode is slightly different. By default, single-user mode requires init to call the Sulogin command on the console and require ROOT login in a single user mode.
After the system enters the single user mode, you should see the following message:
Give root password for system maintenance
(or Type Control-D for Normal Startup):
After the maintenance is performed, the following command can be executed to enable the system back to the previous run level:
Telinit 3
This command tells the system to re-enter the multi-user run level. In this command, "2" or "4" can be used instead of "3". On the SLACKWARE system, the Run Level 4 will enable you to enter a multi-user mode using one of the X-window Display Manager, so you will log in directly to the X window.
If you hang up UPS on the serial cable of the serial cable, the UPS can be sent to the system to send a signal in the case of power out. This is very useful if your product level system has a large file system. I have seen what happened when I didn't completely uninstall 100GB RAID EXT2 file system (complete FSCK for approximately 4 hours). On the other hand, the correctly configured UPS can remind the system to power off and send the SIGPWR signal to Telinit / Init, which enables the init to switch the system to a single user mode or completely shut down the system based on its configuration.
It's good to shut down. Because you have been using a computer, you have been tired, and I am going to relax to Big Blue Room. Fortunately, you already know that it is a major tabogen on the power switch directly at the end, but maybe I don't know all the methods of the shutdown system.
In Linux, you can use the "three-story" reboot system: CTRL Alt DEL keyword sequence sends a message to the system, inform it to perform a shutdown process and restart. In other words, unless you don't do it.
If you want to disable the keyword order, you need to comment out a line of code in the inittab:
Some slackware inittab
# Script to Run When Going Multi User.
RC: 2345: Wait: /etc/rc.d/rc.m
# What to do at the "three finger salute".
#ca :: ctrlatdel: / sbin / shutdown -t5-rf now
Comment Out The Above Line to Disable Ctrl Alt Del HotKey.
What happens when shutdown? Calling the shutdown command can gradually turn off the system. However, ShutDown itself does not complete all work, it notifies init: should enter the run level 0, 1 or 6.
The shutdown command also notifies all users logged in to the machine: The machine will turn off. After this, you will lock the login command, so there is no other person to start the session.
To use the shutdown command to close the Linux system, use the following command:
Shut down
SHUTDOWN-H now
If you want to log out and save the file to the user, use the following command:
Shutdown -h -t 60
The "-h" switch of the shutdown command tells the system to completely shut down after downtime. If an APM is enabled in the kernel, it will turn off the power for you, otherwise you can press the switch at this time. The "-t" switch is the time required before the system starts to shut down, in seconds. If you want to discard the shutdown, use this switch to be implemented. To stop suspending, enter:
Shutdown -c
This command will cancel all previous Shutdown commands. If you don't want to turn off the system for some reason, you should send a "system is about to turn off", then "-k" can be used in ShutDown.
Know how to use Telinit and INIT to modify the Linux system. In this article, we discussed the basics of the INIT script of the run level and the SLACKWARE Linux release. Between the various issues, the directory structure and file location are different, but after reading this article, you should be able to master the system's init script, even if you are not Slackware Linux.
Reference
Please visit the Slackware Linux home page. Please subscribe to the installation, configure, and custom Slackware Linux, which is a guide from Joe BrockMeier with other people's Slackware beginners. For additional background knowledge, please read "How Your Computer Boots". Please go deep into the design difference between Berkeley Software Distribution (BSD) UNIX and AT & T System V, and VI and EMACS, which is one of the intense debates of the computer world.
About the author Joe "Zonker" BROCKMEIER has been using Linux since 1996, and he recently wrote article related to Linux. He is the advanced editor of User Friendly Media, and is a written editor of Linux Magazine, Enterprise Linux Magazine and UNIX REVIEW. Joe originally engaged in radio broadcasting, he has a degree in English and communications / news majors, but he likes to play with his 11 (!) Computer, and watch the police flakes in his spare time. Can contact him through jbrockmeier@earthlink.net.