Run commands when Linux is started

Source: Internet
Author: User
Run the Command & amp; #65279; 1. linux startup sequence: (1) BIOS self-check www.2cto.com (2) run the system kernel and check the hardware (3) run the system's first process init (4) init read the system boot configuration file: the information in/etc/inittab is...
Run the command restart 1 during Linux startup. linux startup sequence: (1) BIOS self-check www.2cto.com (2) run the system kernel and check the hardware (3) run the system's first process init (4) init read the system boot configuration file: initialize the information in/etc/inittab. d/rc. sysinit ------ system initialization script/etc/rc. d/rcX. d/[KS] * ------ configure the service/etc/rc according to the running level. d/rc. local --------- execute local special configurations other --------- special services of different running levels Linux starts to run the init Program to start initialization of related programs. one concept related to startup is the runtime level, the running level is the current running level of the operating system. at different running levels, you can define the startup programs that belong to the running level. the running level of the system can be specified in the/etc/inittab file, the running-level program passes through the slave source/etc/rc. d/init. d link To the destination/etc/rcX. d, X indicates the default running level of the system. Therefore, the default startup script is placed under/etc/rc. d/init. d. Someone suggested to execute the corresponding commands in. login, or write the commands in. bashrc (using tcsh shell, in. tcshrc. This is not acceptable ,. login is executed when a user logs on. The user may not need to log on locally, or log on multiple times remotely. tcshrc is executed when the shell is started. after logon, the user usually opens the shell multiple times, so that the command or program will be executed multiple times. 2. the default running level is as follows: #0-stop (do not set initdefault to 0) #1-single-user mode #2-multiple users, but there is no NFS #3-full multi-user mode #4-not used #5-X11 #6-restart (do not set initdefault to 6) detailed explanation of each running level: 0 indicates that the machine is shut down. 1 is the single-user mode, just like the security mode in Win9x. 2: Multi-user mode, but not supported by NFS. 3 is a complete multi-user mode, which is a standard operation level. 4. Generally, you can use it to do things in some special cases. For example, you can switch to this mode to make some settings when the battery of your laptop is exhausted. 5 is X11, and it enters the X Window System. 6. restart the init 6 server.
3. there are two ways to enable the system to run the specified program in the startup sequence: Step 4. One way is to configure the service according to the running level. Www.2cto.com is used to execute special local configurations. For example, when a task is started, run the command cvslockd: Method 1: (1) create a self-starting script/etc/rc. d/init. d/cvslockd with the following content :#! The attributes of the/bin/bash/usr/local/bin/cvslockd setting file are executable: # chmod + x/etc/rc. d/init. d/cvslockd (2) view the computer running level. if you see id: 5: initdefault: in the file/etc/inittab, the system running level is 5. (3) to the/etc/rc5.d Directory, make a soft connection to the executable file you want to execute, and start with the uppercase letter "S" when naming, the number size after S indicates the order of execution. the larger the number, the higher the execution order. # Ln-s/etc/rc. d/init. d/cvslockd/etc/rc5.d/S100cvslockd # ln-s/etc/rc. d/init. d/cvslockd/etc/rc0.d/K20cvslockd mode 2: in/etc/rc. d/rc. add exec/usr/local/bin/cvslockd to local. this method starts cvslockd at the end.

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.