


What are the basic knowledge of linux operating system
Basic knowledge of the Linux operating system: 1. The operating system distinguishes between physical memory and virtual memory; 2. Understand the relationship between memory and hard disk; 3. Common vulnerabilities in each part, such as the CPU is prone to such bottlenecks. Server, dynamic web server; 4. Master some optimizations of Linux itself.
Basic knowledge of linux operating system:
1. General introduction to the operating system
•CPU: Just like the human brain, it is mainly responsible for the judgment of related matters and the actual processing mechanism.
Query command: cat /proc/cpuinfo
•Memory: The memory block in the brain, where the information collected from skin, eyes, etc. is recorded for CPU to make judgments . Query command: cat /proc/meminfo
Physical memory
Physical memory is the capacity of the memory stick we insert into the motherboard memory slot. When looking at the computer configuration, the main thing to look at is the physical memory
Virtual Memory
Virtual memory technology is used in Windows, that is, part of the hard disk space is used as memory. When the memory is fully occupied, , the computer will automatically call the hard disk to act as memory to relieve memory tension.
Relationship: Both virtual memory and physical memory may be used in Windows. In Linux, virtual memory will be used only when the physical memory is used up
•Hard disk: The memory block in the brain, Record important data so it can be used again in the future.
Query command: fdisk -l (requires root permission)
2. The relationship between memory and hard disk
The specific command will be introduced later
3. Operating system monitoring command>Write a separate copy
•vmstat
•sar
• iostat
•top
•free
•uptime
•netstat
•ps
•strace
•lsof
4. How to analyze the operating system
Actual process: Read data》Data>Hard disk》Virtual memory (swaP)》Memory》 cpu cache》Execution queue
Analysis direction, just the opposite
5. Vulnerabilities that often occur in various parts
•CPU: This type of bottleneck is prone to occur Mail servers, dynamic web servers
•Memory: Print servers, database servers, static web servers that are prone to such bottlenecks
•Disk I/O: Projects with frequent read and write operations
•Network bandwidth: Frequently uploading and downloading large amounts of projects
6. Some optimizations of Linux itself
1. System installation optimization
When installing a Linux system, disk partitioning and SWAP memory allocation directly affect system performance. Regarding the setting of virtual memory SWAP, there is no longer the so-called requirement that virtual memory be twice the physical memory. However, according to experience, if the memory is small (physical memory is less than 4GB), the SWAP swap partition size is generally set to twice the memory; If the physical memory is about 4GB and less than 16GB, you can set the SWAP size to be equal to or slightly smaller than the physical memory; if the memory is more than 16GB, in principle you can set SWAP to 0, but it is best to set a certain size of SWAP
• 2. Kernel parameter optimization
For example, if the system deploys an oracle database application, then you need to optimize the system shared memory segment (kernel.shmmax, kenerl.shmmni, kernel.shmall),
system Semaphore (kernel.sem), file handle (fs.file0max) and other parameters are optimized and set; if a WEB application is deployed, then the network parameters need to be optimized according to the characteristics of the web application, such as modifying net.ipv4.ip_local_port_range, net. ipv4.tc_tw_reuse, net.core.somaxconn and other network
Kernel parameters
• 3. File system optimization
The optional file systems under Linux are ext2, ext3 , xfs, ReiserFS
The Linux standard file system starts from VFS, then ext, ext2, ext2 is the standard file system on Linux, and ext3 is formed by adding logs on the basis of ext2. From VFS to ext3, the design ideas have not changed much. They were all designed based on the super block and inode design concepts of the early UNIX family. The XFS file system is an advanced log file system developed by SGI. It provides low-latency, high-bandwidth access to file system data by distributing disk requests, locating data, and maintaining cache consistency. Therefore, XFS is extremely scalable and very Robust, with excellent logging capabilities, strong scalability, and fast writing. ReiserFS is a high-performance log file system developed under the leadership of Hans Reiser. It manages data through a completely balanced tree, including file data, file names, log support, etc. Compared with ext2 and ext3, the biggest advantage is that access performance and security are greatly improved. It has the advantages of efficient and reasonable use of disk space, first-class log management mechanism, special search method, massive disk storage, etc.
4. Key knowledge
Physical memory and virtual memory
(1). How to check physical memory and virtual memory?
Top command can view the values of physical memory and virtual memory
(2).Buffer
is a memory chip on the hard disk controller, which has extremely fast access speed. It is a buffer between the internal storage of the hard disk and the external interface. Since the internal data transmission speed of the hard disk is different from the external interface transmission speed, the cache plays a buffering role. The size and speed of the cache are important factors directly related to the transmission speed of the hard disk, and can greatly improve the overall performance of the hard disk.
(3).Cache
CPU cache (Cache Memory) is a temporary memory located between the CPU and the memory. Its capacity is much smaller than the memory but the exchange The speed is much faster than memory. The emergence of cache is mainly to solve the contradiction between the CPU operation speed and the memory read and write speed. Because the CPU operation speed is much faster than the memory read and write speed, this will cause the CPU to spend a long time waiting for data to arrive or write data to the memory. . The data in the cache is a small part of the memory, but this small part is about to be accessed by the CPU in a short period of time. When the CPU calls a large amount of data, it can avoid the memory and call it directly from the cache, thereby speeding up the reading speed.
(4).CPU interrupt
When the CPU finishes executing a current instruction, if the peripheral sends an interrupt request to the CPU, then the CPU will respond if the , an interrupt response signal will be issued, and interrupts will be turned off at the same time, indicating that the CPU is no longer accepting interrupts from another device. At this time, the CPU will find which device the source of the interrupt request is and save the contents of the CPU's own program counter (PC). He will then transfer to the interrupt service routine that handles that interrupt source. After the CPU saves the on-site information and performs equipment services (such as exchanging data), it will restore the on-site information. After these actions are completed, open the interrupt and return to the next instruction of the originally interrupted main program.
(5). Context switching
Context Switch or environment switching
In a multi-tasking system, context switching refers to the CPU An event that occurs when control is transferred from a running task to another ready task.
In the operating system, when the CPU switches to another process, it is necessary to save the state of the current process and restore the state of the other process: the currently running task changes to the ready (or suspended, deleted) state, and another one is selected. The specified ready task becomes the current task. Context switching includes saving the running environment of the current task and restoring the running environment of the task to be run.
The process context is represented by the PCB (process control block, also called PCB, task control block) of the process, which includes process status, CPU register values, etc.
Usually save the current state of the CPU by performing a state save, and then perform a state restore to restart the operation.
Context switching can have a negative impact on performance. However, some context switches are more expensive than others; one of the more expensive context switches is the cross-core context switch. A thread can run on a dedicated processor or across processors. Threads served by a single processor have processor affinity (Processor Affinity), which is more efficient. Preempting and scheduling threads on another processor core can cause cache misses as a result of cache misses and excessive context switches to access local memory. In short, this is called "cross-core context switching".
6. Processes and threads
Process concept
Process is the basic representation of resource allocation Unit is the basic unit of scheduling operation. For example, when a user runs his or her own program, the system creates a process and allocates resources to it, including various tables, memory space, disk space, I/O devices, etc. Then, put the process into the process's ready queue. The process scheduler selects it and allocates CPU and other related resources to it before the process actually runs. Therefore, the process is the unit of concurrent execution in the system.
Thread concept
A thread is the smallest unit for performing operations in a process, which is also the basic unit for executing processor scheduling. If a process is understood as a task logically completed by the operating system, then a thread represents one of the many possible subtasks to complete the task
The relationship between process and thread
(1) A thread can only belong to one process, and a process can have multiple threads, but there is at least one thread. (2) Resources are allocated to processes, and all threads of the same process share all resources of the process.
(3) The processor is assigned to threads, that is, the threads are actually running on the processor.
(4) Threads need to cooperate and synchronize during execution. The threads of different processes must use message communication to achieve synchronization.
Related learning recommendations: linux video
##Note:
1.Linux is a case-sensitive system. For example, Mozilla, MOZILLA, mOzilla and mozilla are four different commands (but only the fourth mozilla is a truly valid command). Also, my_filE, my_file, and my_FILE are three different files. The user's login name and secret are also case-sensitive (this is because the tradition of UNIX systems and C language has always been case-sensitive).
2. The file name can have up to 256 characters, and can contain numbers, periods ".", underscores "_", horizontal bars "-", plus other characters that are not recommended.
3. Files with "." in front of the file name are generally not displayed when entering the "ls" or "dir" command. These files can be regarded as hidden files. Of course, you can also use the command "ls -a" to display these files.
4. "/" is equivalent to "\" under DOS (the root directory, which means the parent directory of all other directories, or a spacer symbol between directories and between directories and files). For example, cd /usr/doc.
5. Under Linux system, all directories are displayed under a single directory tree (different from the drive identification of DOS system). This means that all files and directories on all physical devices are combined under a single directory tree.
6. In the configuration file, lines starting with # are comment lines. When modifying the configuration file, try not to delete the old settings - you can add "#" to the original settings to turn them into comment lines. Always add some comments about the modifications corresponding to the modification places. You will find that in future management Benefit a lot from it.
7.Linux is an inherited multi-user operating system. Your personal settings (and those of other users) are placed in your home directory (usually /home/your_user_login_name). The file names of many configuration files begin with ".", so users generally cannot see these files.
8. System-wide settings are generally placed in the directory /etc.
9. Similar to other multi-user operating systems, under Linux, files and directories have their own owners and access permissions. Generally speaking, you are only allowed files to your home directory (/home/your_user_login_name). Learn some relevant knowledge about file permission management, otherwise you will definitely find Linux to be very troublesome.
10. Command parameter options are generally guided by "-", followed by one character (or "--", when the option exceeds one character). In this way, "-" is a bit like "/" under DOS. For example, enter the command rm --help.
Related recommendations: Programming video course
The above is the detailed content of What are the basic knowledge of linux operating system. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



This study provides a comprehensive and in-depth analysis of software uninstallation problems that may arise during the penetration testing and security audit process of KaliLinux, and contributes solutions to ensure system stability and reliability. 1. Understand the installation method of the software. Before uninstalling the software from kalilinux, it is a crucial step to first determine its installation path. Then, the appropriate offloading solution is selected accordingly based on the selected path. Common installation methods include apt-get, dpkg, source code compilation and other forms. Each strategy has its own characteristics and corresponding offloading measures. 2. Use the apt-get command to uninstall software. In the KaliLinux system, the apt-get functional component is widely used to execute software packages efficiently and conveniently.

Recently, the domestic operating system Kirin Linux has attracted much attention. As a senior computer engineer, I have a strong interest in technological innovation, so I have personally experienced the installation process of this system, and now I will share my experience with you. Before executing the installation procedure, I was fully prepared for the relevant steps. The first task is to download and copy the latest Kirin Linux operating system image to a USB flash drive; secondly, for 64-bit Linux, ensure that important data in personal devices have been backed up to deal with potential installation problems; finally, shut down the computer and insert the USB flash drive. After entering the installation interface and restarting the computer, press the F12 function key promptly, enter the system boot menu and select the USB priority boot option. With a beautiful and simple startup screen appearing in front of you

In fact, after a computer is used for a long period of time, the overall performance will show a downward trend, and the adaptability to the Windows system will continue to decline. In addition to the reasons of the computer itself, the Windows system continues to be enhanced and expanded, and the hardware requirements are also getting higher and higher. Therefore, it is not surprising that old computers experience lag after installing Windows system. Previously, many friends were asking in the background about system lags, what to do with old computers? If you find that installing the new Windows 10 system on your old computer causes lags and operational problems, it may be a good choice to consider switching to Linux. Dabaicai has compiled 5 micro-Linux systems, which are suitable for old computers and can effectively reduce CPU usage and make your

Methods to solve the problem of garbled characters displayed on the Linux command line. In the Linux operating system, sometimes we will encounter garbled characters displayed when using the command line interface, which will affect our normal viewing and understanding of the command output results or file contents. The causes of garbled characters may be due to incorrect system character set settings, terminal software not supporting the display of specific character sets, inconsistent file encoding formats, etc. This article will introduce some methods to solve the problem of garbled characters displayed on the Linux command line, and provide specific code examples to help readers solve similar problems.

The Linuxext2 file system is a file system used on most Linux operating systems. It uses an efficient disk storage structure to manage the storage of files and directories. Before we delve into the physical storage structure of the Linuxext2 file system, we first need to understand some basic concepts. In the ext2 file system, data is stored in data blocks (blocks), which are the smallest allocable units in the file system. Each data block has a fixed size, usually 1KB, 2KB or 4

If you are using a Linux operating system and want the system to automatically mount the drive on boot, you can do this by adding the device's unique identifier (UID) and mount point path to the fstab configuration file. fstab is a file system table file located in the /etc directory. It contains information about the file systems that need to be mounted when the system starts. By editing the fstab file, you can ensure that the required drives are loaded correctly every time the system starts, thus ensuring stable system operation. Automatically mounting drivers can be conveniently used in a variety of situations. For example, I plan to back up my system to an external storage device. To achieve automation, ensure that the device remains connected to the system, even at startup. Likewise, many applications will directly

Why do processes in Linux sleep? In the Linux operating system, a process can become dormant due to a number of different reasons and conditions. When a process is in a dormant state, it means that the process is temporarily suspended and cannot continue execution until certain conditions are met before it can be awakened to continue execution. Next, we will introduce in detail several common situations when a process enters hibernation in Linux, and illustrate them with specific code examples. Waiting for I/O to complete: When a process initiates an I/O operation (such as reading

Working with files in the Linux operating system requires the use of various commands and techniques that enable developers to efficiently create and execute files, code, programs, scripts, and other things. In the Linux environment, files with the extension ".a" have great importance as static libraries. These libraries play an important role in software development, allowing developers to efficiently manage and share common functionality across multiple programs. For effective software development in a Linux environment, it is crucial to understand how to create and run ".a" files. This article will introduce how to comprehensively install and configure the Linux ".a" file. Let's explore the definition, purpose, structure, and methods of creating and executing the Linux ".a" file. What is L
