Automatically execute scripts or specified programs when Linux is started.

Source: Internet
Author: User

Environment: XP host + vmvm + fedora9

First, let's talk about some real things. To automatically mount your shared folder on XP after the VM is powered on and started, you can do this:

Vim/etc/rc. Local

Write the script you want to process or the Program executed in the background and save it.

/Etc/init. d/network restart

Sleep 3

Mount-t cifs-o User = fish, password = fish // 192.168.0.100/Linux/mnt/Windows

The following describes the basic knowledge:

The RedHat Startup Mode and execution sequence are as follows:

Load the kernel

Run the INIT program

/Etc/rc. d/RC. sysinit # The first script executed by init/etc/rc. d/RC $ runlevel # $ runlevel is the default running mode/etc/rc. d/RC. local # after the corresponding level of service is started, execute the file (in fact, you can also write the command to be executed to this file)

/Sbin/mingetty # Wait for User Login

In RedHat,/etc/rc. d/rc. sysinit mainly performs the same initialization in each running mode, including:

Incoming keymap and system font

Start swapping

Set Host Name

Set the NIS domain name

Check (fsck) and mount the File System

Open quota

Mount sound card module

Set system clock

And so on.

/Etc/rc. d/RC executes scripts in the corresponding directory according to the running mode specified by its parameters (the running level, which can be set in the inittab file. All parameters starting with kxx are called with the Stop parameter. All parameters starting with sxx are called with the start parameter. The call sequence is from xx to xx. (XX indicates the Starting sequence.) For example, assume that the default running mode is 3,/etc/rc. d/RC will call/etc/rc as described above. d/rc3.d.

It is worth mentioning that the operating modes 2, 3, and 5 in RedHat put/etc/rc. d/RC. local is the last in the initialization script, so you can add some commands that need to be executed before logging on to this file.

Init is waiting for/etc/rc. d/RC after execution (because/etc/inittab/etc/rc. d/RC's action is wait). It will run/sbin/mingetty on each specified virtual terminal and wait for the user to log on.

So far, the Linux Startup has ended.

Init running level and command

What is INIT:

Init is an indispensable program in Linux.

The INIT process is a user-level process started by the kernel.

After the kernel is started by itself (it has been loaded into the memory, started to run, and initialized to all the device drivers and data structures), it starts a user-level program init, complete the boot process. Therefore, init is always the first process (its process number is always 1 ).

In the past, the kernel used init to find it. The correct position (for Linux) is/sbin/init. If the kernel cannot find init, it will try to run/bin/sh. If the run fails, the system will also fail to start.

Running level

So what is the runtime level?

Simply put, the running level is the function level currently running in the operating system. This level ranges from 1 to 6 and has different functions.

Different runtime levels are defined as follows:

#0-stop (never set initdefault to 0)

#1-single-user mode # s init S = init 1

#2-multiple users without NFS

#3-full multi-user mode (Standard Operation Level)

#4-useless

#5-X11 multi-user graphic mode (XWindow)

#6-Restart (do not set initdefault to 6)

These levels are specified in the/etc/inittab file. This file is the main file found by the INIT program. The first service to run is the file stored in the/etc/rc. d directory. In most Linux releases, the startup script is located in/etc/rc. d/init. d. These scripts are connected to the/etc/rc. d/rcN. d directory by using LN commands.

These running levels correspond to the script file RCN (0, 1 .. 6). d under your file.

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.