Linux boot program (2)

Source: Internet
Author: User
Article title: Linux boot program (2 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Author: ink right hand
  
Write your own rc command script
  
  
In the days when the Linux system is maintained, the system administrator must modify the script for starting or shutting down the system. There are two ways to achieve the purpose of modification:
  
● If the modification only takes effect during boot, and the modification is not significant, you can simply edit the/etc/rc. d/rc. local script. This command script program is executed at the last step of the boot process.
  
● If the modifications are meticulous or you want to shut down the process to make it stop running explicitly, you need to add a command script program in the/etc/rc. d/init. d subdirectory. The script program must accept the Start and Stop parameters and complete corresponding operations.
  
The first method is to edit the/etc/rc. d/rc. local script. of course, the two methods are relatively simple. If you want to add content to this command script program, you only need to open it using your favorite editor program, and then attach the command to be executed to the end of the file. This is indeed very convenient for the modification of one or two rows.
  
If you need to use a command script program, you must select the second method. Writing an rc script is not as difficult as you think. Here is an example to see how it is implemented (by the way, you can use our example as a template to modify and add as needed ).
  
Suppose you want to call a special program every 60 minutes to bring up a message and remind you to leave the keyboard for a while. the command script contains the following parts:
  
● Description of the functions of the script program (so that it will not be forgotten one year later );
  
● Verify that the script program exists before trying to run it;
  
● Accept the start and stop parameters and perform the required actions.
  
After the parameter is specified, we can compile the script program of the command. This program is very simple. you can write it yourself. I will not give it here.
  
After writing a new command script program, add the necessary symbolic links to the relevant running level sub-directories to control the startup or stop of the script program. In my impression, I only want to make it start in runlevel 3 or runlevel 5 because I think only these two runlevel is the place where daily work is done. Finally, we hope the script program will be closed when it enters the running Level 6 (restart.
  
  
Activate or disable a service item
  
  
Sometimes, you may find that a certain service is not required to be started during the boot process. This is especially true if you are considering replacing Windows NT files and print servers with Linux.
  
We already know that you can change the symbolic link name in a specific sub-directory of the running level to prevent the service from being started. for example, you can change the first letter of its name from S to K. Once you have mastered the command line and symbolic links, you will find that this is the fastest way to activate or disable services.
  
When learning this renaming method, you may feel that the graphic operation interface ksysv is easier to grasp. Although it was originally designed and used in the KDE environment, it also runs well in the default GNOME environment installed in Red Hat Linux 7.2. To start it, simply open an xterm window and enter the ksysv command. A window appears, listing all the parameters that can be modified and online help is also needed.
  
Warning: If you are learning the knowledge of this article in a real system, you need to use more common sense. When you try to modify the startup script program, remember that the modifications may make your system unable to work normally and cannot be restored using the restart method. Do not experiment with new settings on a running system. back up all the files you want to modify. The most important thing is to prepare a boot disk at hand to prevent unexpected events.
  
  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.