"Linux command line and Shell script Programming Daquan (3rd edition)" Reading notes

Source: Internet
Author: User

First chapter initial Linux Shell

Linux can be divided into 4 parts:

-Linux kernel

-GNU Tools

-Graphical desktop environment

-Application software

The core of the Linux system is the kernel. The kernel controls all the hardware and software on the computer system, allocates the hardware if necessary, and executes the software as needed.

The kernel is primarily responsible for the following 4 functions:

-System memory Management

-Software program Management

-Hardware Device Management

-File System Management

One of the main functions of the operating system kernel is memory management. The kernel manages not only the available physical memory on the server, but also the creation and management of virtual memory (memory that does not actually exist).

The kernel implements virtual memory through storage space on the hard disk, which is called swap space. The kernel constantly exchanges the contents of virtual memory between the swap space and the actual physical memory, which makes the system think it has more usable memory than the physical memory.

Memory storage units are divided into chunks, called pages, by group. The kernel places each memory page in physical memory or swap space. The kernel then maintains a memory page table that indicates which pages are in physical memory and which pages are swapped to disk.

The kernel records which memory pages are in use and automatically copies memory pages that are not accessed for a period of time to the swap space area (called swap out, swapping out), even if there is memory available. When a program accesses a memory page that has been swapped out, the kernel must swap out the physical memory for another memory page to make room for it, and then swap in the requested memory page from swap space. Obviously, this process takes time and slows down the running process. As long as the Linux system is running, the process of swapping out memory pages for running programs will not stop.

The Linux operating system is called a process in a running program. Processes can run in the foreground, display the output on the screen, or run in the background to hide behind the scenes. The kernel controls how the Linux system manages all processes running on the system.

The init process is the first process created by the kernel to start other processes on the system. When the kernel starts, it loads the INIT process into internal virtual memory. When the kernel starts any other process, it assigns a private area to the new process in virtual memory to store the data and code used by the process. Some Linux systems use/etc/inittab to manage the process of booting from the system when it is powered on. Others use the/ETC/INIT.D directory, where scripts are automatically started or stopped, and these scripts are started by portals in the/ETC/RCX.D directory, where x represents the RunLevel. These portals are actually symbolic links to the startup script in the/ETC/INIT.D directory.

The init system of the Linux operating system uses a runlevel. The run level determines the init process running the/etc/inittab file or certain specific types of processes defined in the/ETC/RCX.D directory.

At run Level 1 o'clock, only basic system processes and one console terminal process are started. Also known as single-user mode. Single-user mode is often used for urgent file system maintenance when the system is in trouble. In this mode, only one person can log on to the operating data on the system.

The standard start-up run level is 3, and most applications are started at this run level.

Run Level 5 supports the start of a graphical X Window System.

Any Linux system that needs to communicate with the device needs to include its driver code in the kernel code. The driver code acts as an intermediary between the application and the hardware device, allowing the kernel to exchange data with the device. There are two methods for inserting device driver code in the Linux kernel:

-device driver code compiled into the kernel

-Device driver module that can be plugged into the kernel

The first method is obsolete, and the second method allows the driver code to be inserted into the running kernel without compiling the kernel. At the same time, the kernel module can be removed from the kernel when the device is no longer in use.

The Linux system treats hardware devices as special files, called device files, into 3 types:

-character-type device files

-Block Device files

-Network device files

A character device file refers to a device that processes data only one character at a time. Most types of modems and terminals are created as character-type device files. A block device file is a device, such as a hard disk, that handles large chunks of data each time it is processed. Network device files refer to devices that are sent and received using packets, including various network cards and a special loopback device. This loopback device allows Linux systems to communicate with themselves using common network programming protocols.

Linux creates a special file called a node for each device on the system. All communication with the device is done through the device node. Each node has a unique numeric pair that is used by the Linux kernel to identify it. Numeric pairs include a master device number and a secondary device number. Similar devices are classified under the same master device number, and the secondary device number identifies a specific device under the primary device group. The main device number is used to distinguish between different kinds of devices, while the secondary device number is used to differentiate multiple devices of the same type.

The Linux kernel uses a virtual file system (SYSTEM,VFS) as an interface for interacting with each file system. This provides a standard interface for any type of file system communication within Linux. When each file system is mounted and used, the VFS will slow down the information in the kernel.

This core set of tools for use by Linux systems is called the coreutils (core utilities) package, which includes:

-Tools for working with files

-Tools to manipulate text

-Tools to manage processes

Putting multiple shell commands into a file is executed as a program, and these files are called shell scripts. All Linux default distributions are bash shells.

The most popular package for X window is x.org. In addition to the Fedora Wayland and Ubuntu has developed a Mir display server.

In addition to X Window, there is the GNOME desktop and KDE desktop, Unity desktop.

A complete Linux System package is known as a release version. There are 3 versions of the distribution:

-Complete Core Linux distribution

-specific use of the release version

-LiveCD Beta release


This article is from the "Alex Blog" blog, make sure to keep this source http://houjun19830610.blog.51cto.com/9269760/1871781

"Linux command line and Shell script Programming Daquan (3rd edition)" Reading notes

Related Article

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.