Linux system architecture and Linux kernel basic architecture

Source: Internet
Author: User
Tags system log

The basic architecture of Linux is summarized by the following two graphs (two graphs are the same, but the focus is slightly different)




From the knowledge, Linux is composed of two parts: User space and kernel space. Kernel space and user space are two different states of program execution, which can transfer from user space to kernel space through system call and hardware interrupt.


Due to the different versions of the Linux system, there is a slight difference in the directory structure, here are two directories as a comparison and learning

For the Linux system, the source code directory Example 1 is as follows:

LINUX directory structure and main content 1
The "/" root directory section has the following subdirectories:
The/usr directory contains all commands, libraries, documents, and other files. These files will not be changed during normal operation. This directory also contains the main applications for your Linux distribution, for example, Netscape.
The/var directory contains files that were changed during normal operation: Spool files, record files, lock files, temporary files, and page format files.
The/home directory contains the user's files: parameter settings files, personalization files, documents, data, EMAIL, cached data, and so on. This directory should be maintained at the system provincial level.
The/proc directory contains all the unreal files. They do not actually exist on the disk, and they do not occupy any space. (Ls–l can be used to display their size) when viewing these files, they are actually accessing the information that exists in memory, which is used to access the system
/bin the execution files (binary) that are required for the system to be started, these files can be used by ordinary users.
/sbin System execution files (binary), these files are not intended to be used by ordinary users. (normal users can still use them, but specify a directory.) )
/etc Operating system configuration file directory.
The home directory of the/root system administrator (also called superuser or root user).
/dev Device file directory. Linux devices are treated as files, which allows the hardware to be abstracted, read-write, network-shared, and temporarily loaded into the file system. Under normal circumstances, the device will have a separate subdirectory. The contents of these devices will appear in separate subdirectories. Linux does not have a so-called driver.
/lib a shared library of programs and core modules under the root file system directory.
/boot files for the bootstrap loader (LILO or GRUB). When the computer starts (if there are multiple operating systems, it is possible to allow you to choose which operating system to start), these files are first loaded. This directory will also contain the Linux kernel (compressed file vmlinuz), but the Linux kernel can also exist elsewhere, as long as Lilo is configured and Lilo knows where the Linux kernel is.
/opt optional applications, such as KDE under REDHAT 5.2 (REDHAT 6.0, KDE in other xwindows applications, main execution program in/usr/bin directory)
/tmp temp file. The directory will be cleaned up automatically.
/lost+found files recovered during file system repair
The more important parts of the "/usr" directory are:
/USR/X11R6 x-windows System (version one, release 6)
/usr/x11 with/USR/X11R6 (/USR/X11R6 's symbolic Connection)
/usr/x11r6/bin a large number of small x-windows applications (and possibly symbolic connections for large execution of files in other subdirectories).
/usr/doc Linux documentation (in the updated system, this directory is moved to/usr/share/doc).
/usr/share separate the data from your computer structure, for example, the words in a dictionary.
/usr/bin and/usr/sbin are similar to directories under the "/" root directory (/bin and/sbin), but are not used for basic booting (for example, in emergency maintenance). Most of the commands are in this directory.
/usr/local an application installed by a local administrator (or a separate subdirectory may be available for each application). After the "main" installation, this directory may be empty. Content in this directory should exist after reinstalling or upgrading the operating system.
/usr/local/bin may be a user-installed small application, and some symbolic connections to large applications in the/usr/local directory.
Contents of the/proc directory:
/proc/cpuinfo information about the processor, such as type, manufacturer, model, and performance.
/proc/devices the list of all devices configured by the current running kernel.
/PROC/DMA The DMA channel that is currently in use. /proc/filesystems the file system that is currently running the kernel configuration.
/proc/interrupts is using the interrupt, and how many interrupts were there.
/proc/ioports the I/O port that is currently in use.
For example, use the following command to read the CPU information of the system.
Cat/proc/cpuinfo
To summarize, say:
· The user should present the file under the/home/user_login_name directory (and its subdirectories).
· In most cases, the local administrator installs additional software in the/usr/local directory and signs the main execution program that is connected under/usr/local/bin.
· All settings of the system are in/etc directory.
· Do not modify anything in the root directory ("/") or/usr directory unless you really know what to do. These directories are best kept consistent with Linux publishing.
· Most tools and applications are installed in the directory:/bin,/usr/sbin,/sbin,/usr/x11/bin,/usr/local/bin.
· All the files are under a single directory tree. There is no so-called "driver".


For the Linux system, the source code directory Example 2 is as follows:

/Linux File System entry, is also at the highest level of the directory;
The commands required by the/bin base system are located in this directory and are required by the smallest system, such as LS, CP, mkdir, and so on, functions and/usr/bin are similar, the files in this directory are executable, commands that ordinary users can use. The most basic command required to be a basic system is to put it here.
The boot/boot Linux kernel and the files required for booting system programs, such as the Vmlinuz initrd.img files, are located in this directory. In general, the GRUB or LILO system Boot Manager is also located in this directory;
/dev Device file storage directory, such as sound card, disk ...
/etc System configuration file location, some server configuration files are also here, such as user account and password configuration file;
/home directory is the default directory for ordinary users;
/lib Library File storage Directory
/lost+found in the ext2 or ext3 file system, when the system crashes unexpectedly or the machine shuts down unexpectedly, some file fragments are placed here. When the system starts, the Fsck tool checks here and repairs the corrupted file system. Sometimes problems with the system, a lot of files are moved to this directory, may be repaired in a manual way, or moved to the original location of the file.
/media plug-and-play storage device mount point is automatically created in this directory, such as the USB disk system automatically mounts, will be in this directory to generate a directory, Cdrom/dvd automatically mount, will also create a directory in this directory, similar to CDROM directory. This is only available on the latest release kits, such as Fedora Core 4.0 5.0. Can see the definition of/etc/fstab;
/misc
/mnt This directory is typically used to store mounted storage devices, such as CDROM directory. You can see the definition of/etc/fstab. Sometimes we can put the system boot automatically mount file system, put the mount point here is also possible. The main view is how to define the/etc/fstab, such as CD-ROM can be mounted to the/mnt/cdrom.
/OPT represents the optional meaning, and some packages are also installed here, which is the custom package, such as in Fedora Core 5.0, where OpenOffice is installed. Some of the packages we compile ourselves can be installed in this directory, and software installed through the source package can be used through the./configure--prefix=/opt/directory.
When the/proc operating system is running, the process (running program) information and kernel information (such as CPU, hard disk partition, memory information, etc.) are stored here. /proc directory masquerading file system proc mount directory, Proc is not a real file system, its definition can be see/etc/fstab.
/root the home directory for Linux super User root;
/sbin most of the commands involved in system Management, is the super-user root executable command storage, ordinary users do not have permission to execute the command under this directory, this directory and/usr/sbin;/usr/x11r6/sbin or/usr/local/ The Sbin directory is similar; we'll remember that all the directories sbin contain are root permissions to execute.
/tmp Temporary file directory, sometimes when users run the program, will produce temporary files. /tmp is used to store temporary files. The/var/tmp directory is similar to this directory.
/usr This is a directory of system storage programs, such as commands, help files, and so on. There are a lot of files and directories under this directory. When we install a Linux distribution that is officially provided by the package, it is mostly installed here. If a server configuration file is involved, the configuration file is installed in the/etc directory. The/usr directory includes the font directory/usr/share/fonts, help directory/usr/share/man or/usr/share/doc, normal user executable file directory/usr/bin or/usr/local/bin or/usr/ X11r6/bin, the super-user root executable command to store directories, such as/usr/sbin or/usr/x11r6/sbin or/usr/local/sbin, and the program's header file to store the directory/usr/include.
/var The content of this directory is constantly changing, see the name to know, we can understand as vary abbreviation,/var under/var/log This is used to store the system log directory. /var/www directory is to define the Apache server site storage directory,/var/lib used to store some library files, such as MySQL, as well as the storage of MySQL database;
Let us add some more important directories to use;
/ETC/INIT.D This directory is used to store scripts that the system or server starts in System V mode, which is common in systems that are started or initialized in the mode v. such as Fedora/redhat;
/ETC/XINIT.D if the server is running in xinetd mode, its script will be placed in this directory. Some systems do not have this directory, such as Slackware, and some older versions do not. In Rehat/fedora, a newer version exists in the comparison.
/ETC/RC.D This is a directory of the Slackware distribution, which is the location of the BSD startup script, such as defining the NIC, the server opening script, etc.
/ETC/X11 is the location of x-windows related configuration files;
For example, the following:
[[email protected] ~]#/etc/init.d/sshd start Note: Start the sshd server
[[email protected] ~]#/etc/init.d/sshd Stop Note: Stop the SSHD server
Start sshd: [OK]
This is the typical sshd server System V-mode startup script, which runs this script to start the sshd server.
/usr/bin This directory is a directory of executable programs, the normal user has permission to execute, when we install a program from the system's own package, most of his executable files will be placed in this directory. such as when installing the Gaim software package. Similar directories are/usr/local/bin; sometimes files in/usr/bin are/usr/local/bin linked files;
/usr/sbin This directory is also a directory of executable programs, but mostly contains commands that involve system administration. Only root privileges can be performed; similar directories are/sbin or/usr/local/sbin or/usr/x11r6/sbin, etc.;
/usr/local This directory is generally used to store the user self-compiled installation software storage directory, usually through the source package installed software, if not specifically designated installation directory, is generally installed in this directory. There are subdirectories under this directory. Check it out for yourself.
/usr/lib and/lib directory is similar, is the library file storage directory;
/usr/share System common store of things, such as/usr/share/fonts is a font directory, users are common.
/usr/share/doc and/usr/share/man Help file, is also common use it;
/USR/SRC is the kernel source directory, such as the following kernel source directory, such as Linux, linux-2.xxx.xx directory. Some systems will also install the source software package here. For example Fedora/redhat, when we install FILE.SRC.RPM, these packages will be installed in the corresponding directory/usr/src/redhat. Please refer to: "Brief introduction to the use of file.src.rpm". Another Fedhat 4.0 5.0, the directory of his kernel source package is located in a directory in the/usr/src/kernels directory (only after installation will generate the corresponding directory);
/var/adm such as package installation information, logs, management information, etc., in the Slackware operating system has this directory. It doesn't seem to be in fedora, so take a look.
/var/log System log storage, analysis log to see this directory of things;
/var/spool printer, mail, proxy server, such as spool directory;


The contents of the above catalogue are excerpted from: http://www.xtzj.com/read-htm-tid-69582.html


Linux kernel Architecture:




The Linux kernel source code is located in the/usr/src/linux directory.

The/include subdirectory contains most of the included files needed to build the kernel code, which rebuilds the kernel with other modules.

The/init subdirectory contains the kernel initialization code, which is the starting point for the kernel to work.

The/arch subdirectory contains all the hardware structure-specific kernel code. such as: I386,alpha

The/drivers subdirectory contains all of the device drivers in the kernel, such as block devices and SCSI devices.

The/FS subdirectory contains all of the file system's code. such as: Ext2,vfat and so on.

The/net subdirectory contains the network code for the kernel.

The/MM subdirectory contains all the memory management code.

The/IPC subdirectory contains the interprocess communication code.

The/kernel subdirectory contains the main kernel code.









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.