Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Chapter III Foundation of Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Before you can master Kali Linux, you must be able to operate a general-purpose Linux system easily. It will be helpful to be proficient in Linux, as most Web,Email and other Internet services run on Linux servers.

In this section, we will cover the basics of Linux as much as possible, but we assume that you already have a general knowledge of computers, including CPU, RAM, motherboards, and hard drives, as well as device controllers and connectors associated with them.

3.1What is Linux? What can I do?

The term "Linux" is usually used to refer to the entire operating system, but in fact, Linux refers to the operating system kernel, which is started by the boot loader, which is self-started by the BIOS/UEFI. The role played by the kernel is similar to that of a conductor in an orchestra-he ensures coordination between hardware and software. This role includes managing hardware, processes, users, permissions, and file systems. The kernel provides a common foundation for all other programs on the system, usually running in Ring 0, also known as kernel space.

User space: we use the term "user space" to refer to all the things that happen together outside the kernel.

Programs that run in user space have many core utilities from the GNU project, most of which are run from the command line. You can use them in scripts to automate many tasks. For more information, see Section 3.4.

Let's take a quick look at the various tasks handled by the Linux kernel.

3.1.1 driver hardware

The first task of the kernel is to control the hardware of the computer. The kernel detects and configures devices when the computer is powered on, or when devices are plugged in or removed (for example, USB devices). The kernel also needs to make it effective for upper-layer software through a simple programming interface so that applications can use these devices without paying attention to the details of the devices (such as which expansion slot is plugged in, etc.). The programming interface provides a layer of abstraction, which, for example, allows videoconferencing software to use it without caring about the manufacturer and model of the camera. The software can use the video (V4L) interface for Linux, and the kernel converts calls to the interface into the actual hardware commands needed for the camera to be used.

The kernel exports the detected hardware data through / proc/ and / sys/ virtual file systems. Applications typically access these devices by creating / dev/ files. The specific files represent the hard drive (for example, / dev/sda), partition (/ dev/sda1), mouse (/ dev/input/mouse0), keyboard (/ dev/input/event0), sound card (dev/snd/*), serial port (/ dev/ttyS*) and other components.

There are two types of device files: blocks and characters. The former has the characteristics of a large chunk of data: it has a limited size, and you can access bytes of data anywhere in this piece of data. The latter behaves like a string of characters that you can read and write, but you cannot navigate to a given location and rewrite it at will. To find out the type of file for a given device, check the command ls-l to output the first character checked. For block devices, the first character is b, and for character devices, the first character is c:

As you might expect, disk drives and partitions use block devices, while mice, keyboards and serial ports use character devices. In both cases, the programming interface includes device-specific commands that can be called through ioctl system calls.

3.1.2 Unified File system

The file system is a prominent aspect of the kernel. UNIX-like systems combine all the file storage used into a single hierarchy, which allows users and applications to access data through known hierarchical locations.

The starting point of this hierarchical tree is called the root, which is represented by the character "/". This directory can contain named subdirectories. For example, the home subdirectory of / is called / home/. Accordingly, this subdirectory can also contain other subdirectories, and so on. Each directory can also contain files for data storage. Therefore, / home/buxy/Desktop/hello.txt represents a file named hello.txt that is stored in the buxy subdirectory under the home subdirectory under the root directory in the Desktop subdirectory. The kernel converts between the naming system and the storage location on disk.

Unlike other systems, Linux deals with only one hierarchy, and it can integrate data from multiple disks. One of these disks will become the root, and the other disks will be mounted in the directory in the reference hierarchy (the mount command is called mount). In this way, these disks can be used at the mount point. This allows the user's home directory (usually stored in / home/) to be stored on a separate hard drive that contains the buxy directory (and other users' directories). Once you mount the hard drive in / home/, these directories can be accessed in the usual way, such as the previous example / home/buxy/Desktop/hello.txt.

For data stored on the hard disk, there are a variety of file system formats corresponding to it. The most widely used is the ext2,ext3,ext4 file system format, among others. For example, VFAT is a file system historically used by DOS and Windows operating systems. Linux's support for the VFAT file system allows the hard drive to be accessible in Kali as it is in Windows. In any case, before you can mount a hard drive, you must prepare a file system, which is formatting. For example, the command mkfs.ext3 (mkfs stands for Make FileSystem) formats the hard disk into the ext3 file system format. These commands require a device file parameter that represents the partition to be formatted (for example, / dev/sda1, the first partition of the first hard disk). This operation is destructive to the data, so it is usually run only once, unless you want to erase the file system and start over.

Network file systems such as NFS are also used, which do not store data on the local hard disk. Instead, the data is transferred over the network to the server, and the data is stored and retrieved as needed. Thanks to the file system abstraction, you don't have to worry about how these disks are connected, so these files are still accessed in a regular hierarchy.

3.1.3 process management

A process is an example of a program running, which requires memory to store the data of the program itself and its operations. The kernel is responsible for creating and tracking processes. When the program runs, the kernel first sets aside some memory, loads the executable code from the file system into memory, and then starts running the code. The kernel holds information about this process, the most obvious of which is an identification number called the process identifier (PID).

Like most modern operating systems, those with Unix-like kernels, including Linux, can handle multiple tasks. In other words, they allow the system to run multiple processes simultaneously. In fact, there is only one process running at any one time, but the kernel divides the CPU time into small chunks and then runs each process in turn. Because these time slices are very short (within milliseconds), it creates the illusion that multiple processes are running in parallel, which are only active in their own time slices and idle the rest of the time. The job of the kernel is to adjust its scheduling mechanism to maintain these parallel running states while maximizing global system performance. If the time slice is too long, the application may not have the desired response. If it is too short, the system will waste time by switching tasks frequently. These decisions can be refined by process priority, and high-priority processes will run longer cycles and divide time slices more frequently than low-priority processes.

Multiprocessor systems: the limitation described above, which runs only one process at a time, is not always applicable: the actual limit is that there can be only one running process per processor core. Multiprocessor, multi-core, or hyperthreaded systems allow multiple processes to run in parallel. However, the same time slicing system is used to handle situations where there are more active processes than effective processor cores. This is not common: a basic system, even a mostly idle system, usually has dozens of running processes.

The kernel allows multiple independent instances of the same program to run, but each instance only allows access to its own time slice and memory. Their data are also independent.

3.1.4 Rights Management

Unix-like systems support multiple users and groups and allow permission control. In most cases, the process is identified by the user who started it. This process is only allowed to do what the user who started it has permission to do. For example, opening a file requires the kernel to check the process identity based on access permissions (see Section 3.4.4 for more details).

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report