(reproduced) Linux that point (middle)

Source: Internet
Author: User
Tags aliases set set

Original address: http://www.cnblogs.com/fnng/archive/2012/03/19/2407162.html

This article is only reproduced for the purpose of their own study

2012-03-22 13:31 by Zerg, 2343 Read, 5 reviews, Favorites, compilation

today is the first day after the resignation, originally wanted to write the work summary, there are many things need to tidy up and study. This is my second time after graduation anxiety and confusion. I hope I can find a job earlier!

To get to the point, in fact, Linux to learn a lot of things. I'm not going to be able to finish it with three posts. However, since got a "up" out, the topic I will not change. This article is set as "medium"! If you write the "next", not finished, you may get a "next", "next two" out. ^_^:), perhaps, wrote this is not down, haha! After all, just a blog, and no one manuscripts, so, more casual. Commenting on the top should be my biggest motivation!

Use of aliases

In the previous section, when I looked at the files in the current directory, I said a ll command to see the first floor reply that he was the alias of the ls-l command, not all Linux have. aliases, as the name implies, different two names refers to a person, different two commands have the same effect. now, you must be wondering what aliases are in your system. [[email protected] alias in ~]# alias query Systemalias cp= ' Cp-i 'alias l.= ' ls-d. *--color=tty 'alias ll= ' ls-l--color=tty 'alias ls= ' ls--color=tty 'alias mv= ' Mv-i 'alias rm= ' Rm-i 'alias vi= ' vim 'alias Which= ' Alias |/usr/bin/which--tty-only--read-alias--show-dot--show-tilde 'How to define an alias, if I use a DOS under the custom copy and do not want to use CP, then you can define a copy alias for the CP. [[email protected] ~]# alias COPY=CP assign the CP command function to copy[[email protected] ~]# alias drm= "RM-RF" defines a DRM alias for the "RM-RF" command. [[email protected] ~]# unalias copy de-alias Vim/vi Editor                                                                                      This part should belong to the focus, about the VI of a lot of things, seemingly out of a few books specifically about VI. There are cows who use this program super fast. For most of us, it's OK to use them.Vim/vi is a powerful screen text editor, the most commonly used text editor on Linux and UNIX, and it is the function of creating, editing and displaying text files. vim/vi no menus, only commands.    for ease of operation, we operate on a copy of a file with content. [[email protected] test]# cp/etc/services services.test Copy the/etc/services file to the current directory. Vim is a reinforced version of VI, when a lot of users are still accustomed to using VI to edit files[[email protected] test]# Vim services.test Enter file   three modes of VI:

three modes of conversion:Enter a, I, O into the insert mode in command mode Press ESC to enter Command mode in insert mode Command mode input: (colon) into edit mode instruction Error in edit mode returns Command mode  Do not feel a bit around, in fact, we just remember, vi into the file, press I key can be edited on the file. when the edits are complete, press the ESC key to exit edit mode. The exit must be remembered in three. : Q is exited (when the file has not changed): q! Do not save the exit (when the file changes): Wq Save and exit Vim/vi  Learn some of the commands below to help us quickly edit and use VI   Command mode:The command mode mainly uses the direction key to move the cursor position to edit the text, the following list the common Operation command and the meaningThe upper, lower, left, and right keyboards and H, J, K, l keys are all moving cursors respectively. $------------Move to end of line0 (0)-----Move to the beginning of the lineH----------Move to upper screenM----------Move to the center of the screenL----------Move to the bottom of the screenGG---------to the first line of the fileG----------to end of filePagedn--- Move down one pagePageUp--- Move up one paged+ Arrow key ----delete textDD--- Delete entire linePP--- full line replicationR---Modify the character of the cursorS---Delete the column where the cursor is located and enter the input mode Insert mode:  You can enter "Insert mode" from "Command mode " by the following commanda------------append text after the labelA------------Additional text at the end of our linei-------------insert text before the cursorI-------------Insert text at the beginning of the banko------------Insert a new line under the cursorO-----------Insert a new line on the cursor ESC--------exit "Insert Mode" edit mode:
Editing mode mainly for some text editing aids, such as String search, substitution, saving files and other operations.
: Q---end VI program, if the file has been modified, save the file first:q! ---Mandatory Exit VI program : Wq---- Save the changes and exit the program: Set Nu---Causes the line number to appear before each line of text: Set Nonu------The line number before each line is canceled: N------------to Nth row    Linux boot process parsing      This part belongs to the theoretical knowledge, interested and I have a look together. The boot process of Linux, that is, the startup process of Linux, what the boot sequence is, and what Services Linux has launched for us.   system Boot Process:  

    1. BIOS self-Test
    2. Start Grub/lilo
    3. Load kernel
    4. Executing the INIT process
    5. Initializing with the/etc/inittab file
BIOS self-test The computer is self-checking by the BIOS after the power is switched on, that is, the so-called post (Power on selftest), and then the boot block is read from the hard disk, floppy disk, or CDROM in the boot order set in the BIOS. In a PC, booting Linux starts at the address 0xffff0 in the BIOS. The first step in the BIOS is a power-on self-test (POST). The job of POST is to detect the hardware. The second step of the BIOS is to enumerate and initialize the local device. Given the different uses of BIOS functionality, the BIOS consists of two parts: the POST code and the runtime service. When the POST is finished, it is cleaned out of memory, but the BIOS runtime service remains in memory and the target operating system can use the services. to boot an operating system, the BIOS runtime searches for active and bootable devices in the order defined by the CMOS settings. The boot device can be a floppy disk, a CD-ROM, a partition on the hard disk, a device on the network, or even a USB flash. Typically, Linux is booted from the hard disk, where the master boot Record (MBR) contains the primary boot loader. The MBR is a 512-byte sector that is located in the first sector on the disk (0 0 Cylinder 1 sectors). When the MBR is loaded into RAM, the BIOS will give control to the MBR. extracting information from MBRto view the contents of your MBR, use the following command: # dd If=/dev/hda of=mbr.bin bs=512 count=1 # od-xa Mbr.binthis DD command needs to run as the root user, which reads the first 512 bytes of content from/dev/hda (the first IDE disk) and writes it to the Mbr.bin file. The OD command prints the contents of this binary file in 16 binary and ASCII format. Start Grub/liloboth grub and Lilo are boot loaders. In the simplest sense, the boot loader boot loader boots the operating system. When the machine boots its operating system, the BIOS reads the first 512 bytes on the boot media (known as the Master boot record,mbr). Only one operating system's boot record can be stored in a single MBR, so there is a problem when more than one operating system is required. Therefore, a more flexible boot loader is required. the comparison between GRUB and LILO as described in the beginning of this article, all bootloader programs work in a similar way to meet common purposes. However, there are a number of differences between LILO and GRUB:* LILO does not have an interactive command interface, while GRUB has. * LILO does not support network booting, while GRUB is supported. * LILO Physically stores information about the location of the operating system that can be booted in the MBR. If you modify the Lilo configuration file, you must rewrite the Lilo first stage boot loader to the MBR. This is a more dangerous option than GRUB, because an incorrectly configured MBR may make the system unable to boot. With grub, if the configuration file is misconfigured, it simply goes to the GRUB command-line interface by default. Safety tips:with regard to security, anyone who has access to the boot disk/CD can bypass all of the security measures mentioned in this article by simply using grub.conf or lilo.conf without setting security. In particular, when using GRUB, it is a serious security vulnerability because it is capable of booting into single-user mode. An easy way to solve this problem is to disable booting through CDs and floppy disks in the machine's BIOS and make sure that a password is set for the BIOS so that others cannot modify the settings. Load Kernelwhen the kernel image is loaded into memory, the kernel phase begins. The kernel image is not an executable kernel, but a compressed kernel image. Usually it is a zimage (compressed image, less than 512KB) or a bzimage (larger compressed image, greater than 512KB), which is compressed in advance using zlib. In front of this kernel image is a routine that implements a small set of hardware settings, extracts the kernel contained in the kernel image, and then puts it into high-end memory, and if there is an initial RAM disk image, it is moved into memory and marked for later use. The routine then invokes the kernel and starts the process of booting the kernel. manual boot in GRUBIn the GRUB command line, we can use the INITRD image to boot a specific kernel, as follows: [[email protected] hzh]# vi/etc/grub.conf View the grub.conf configuration file grub> kernel/bzimage-2.6.14.2[Linux-bzimage, setup=0x1400, size=0x29672e]grub> initrd/initrd-2.6.14.2.img[Linux-initrd @ 0x5f13000, 0xcc199 bytes]grub> Bootuncompressing Linux ... Ok, booting the kernel.If you do not know the name of the kernel to boot, simply use the slash (/) and press the Tab key. GRUB displays a list of kernel and INITRD images. executing the init processThe init process is the starting point for all processes in the system, and after the kernel is booted inside, the INIT program is loaded in this thread (process) space, and its process number is 1. The init process is the initiator and controller of all processes. Because it is the first process to run on any UNIX-based system (such as Linux), the Init process's number (process Id,pid) is always 1. If there is a problem with Init, the rest of the system collapses. The init process has two functions. The first function is to play the role of ending the parent process. Because the init process is never terminated, the system can always be sure of its existence and refer to it when necessary. If a process is terminated before the end of all the child processes it derives from, the case must be referenced with Init. At this point, those child processes that have lost the parent process will have Init as their parent process. To quickly execute the PS-AF command, you can list a number of processes that have a parent process id,ppid of 1. The second role of Init is to manage various run levels by running the appropriate program at a specific runlevel (Runlevel). Its role is defined by the/etc/inittab file. initializing through the/etc/inittab file Init's job is to execute the appropriate scripts for system initialization based on/etc/inittab, such as setting up keyboards, fonts, loading modules, setting up networks, and so on. for Redhatlinux, the Order of execution is:
/etc/rc.d/rc.sysinit            

Sets the initial $path variable.
Configure the network.
Initiates an interchange for virtual memory.
Sets the host name of the system.
Check the root file system for necessary repairs.
Check the root file system quota.
Open quotas for users and groups for the root file system.
Reloads the root file system in read/write mode.
Clears the mounted File system table/etc/mtab.
Enter the root file system into the mTAB.
Prepare the system for loading the module.
Find the relevant files for the module.
Check the file system to make the necessary repairs.
Load all other file systems.
Clears several/etc files:/etc/mtab,/etc/fastboot, and/etc/nologin.
Delete the UUCP lock file.
Delete obsolete subsystem files.
Delete the outdated PID file.
Sets the system clock.
Open the interchange.
Initializes the serial port.
Loading the module.
/etc/rc.d/rcx.d/[ks]
first terminate the service that begins with "K", and then start the service with the beginning of "S". for each runlevel, there is a subordinate directory in the/ETC/RC.D subdirectory. The naming method for the subordinate subdirectories of these runlevel is RCX.D, where x is the number representing the run level. For example, all command scripts running level 3 are stored in the/ETC/RC.D/RC3.D subdirectory. In sub-directories at each runlevel, there are symbolic links to the command scripts in the/ETC/RC.D/INIT.D subdirectory, but these symbolic links do not use the original name of the command script in the/ETC/RC.D/INIT.D subdirectory. If the command script is used to start a service, its symbolic link name begins with the letter S; if the command script is used to close a service, its symbolic link will begin with the letter K. In many cases, the order in which these command scripts are executed is important. If you do not configure the network interface first, there is no way to use the DNS service to resolve the host name! In order to arrange their execution sequence, the letter S or K is followed by a two-digit number, the value is small in front of the large number of execution. For example:/etc/rc.d/rc3.d/s50inet will be executed before/etc/rc.d/rc3.d/s55named. The command scripts stored in the/ETC/RC.D/INIT.D subdirectory, which are symbolic links, are the real doers, and they complete the process of starting or stopping various services. When/ETC/RC.D/RC runs through each specific run-level subdirectory, it invokes each command script execution sequentially, in order of the number. It runs the command script that starts with the letter K, and then runs the command script that begins with the letter S. For a command script that starts with the letter K, the stop parameter is passed, and the start parameter is passed similarly to a command script that begins with the letter S. Executive/etc/ec.d/rc.localRedhat Linux Operating modes 2, 3, 5 all make/etc/rc.d/rc.local the last one in the init script, so the user can add in this file some commands that need to be executed before the other initialization work. In the days of maintaining the Linux system, it is certain that the system administrator will need to modify the boot or shutdown command scripts. If the changes are only useful when booting the boot, and the changes are not significant, consider simply editing the/etc/rc.d/rc.local script. This command script is executed at the last step of the boot process. Execute/bin/login ProgramThe login program will prompt the user to enter the account number and password, and then code and confirm the correctness of the password, if the two are consistent, the users to initialize the environment, and give control to the shell, that is, waiting for users to log in. The Linux boot process has ended many times. Modify the hardware and software time of the machineAbout, modify the system's hardware and software time, not particularly important to the novice, the software (refers to the system time) time is very good modification, hardware (refers to CMOS time) time does not know how to modify. Not interested can be ignored.[[email protected] hzh]# date view native software clock[[email protected] hzh]# hwclock view hardware clock for this machine[email protected] hzh]# Hwclock--help--set Set the RTC to the time given with--date--hctosys Set the system time from the hardware clock--SYSTOHC Set the hardware clock to the current system time If there is a time that is wrong, we can modify it by the above command. [[email protected] hzh]# Hwclock--hctosys Set the system time corresponding to the hardware time. [[email protected] hzh]# Hwclock--SYSTOHC set the hardware time corresponding to the system time.  If two times is wrong, we can set the time ourselves[email protected] hzh]# hwclock--set--data= "month/day/year: minutes: Seconds"

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.