Linux Basic Concepts

Source: Internet
Author: User

Basic concepts

This article describes several common concepts of Linux in a personal perspective:
Why can't programs on Windows run on Linux?
What the heck is the programmer doing?
System Library-based programming and API-based programming
Shared libraries
Copy when writing
The security context of the process
Why can't programs on Windows run on Linux?
The bottom of the computer is the hardware, the hardware is kernel, and then up is the library, the library can not run itself, but to wait for the program to execute the call, the module is the same, the programmer can be based on the interface provided by the library programming, this library is also known as the shared library, according to the shared library program, porting to the same operating system can still work, but why can't programs on Windows run on Linux? The reason is not limited to the library, the library is the API (program call interface), in addition to an interface is called ABI (program running interface), Windows software Linux is not used for many reasons because the ABI is different, the API is different can be remedied, Two systems can be solved with the same library, but the difference between the ABI is difficult to compensate.
System architecture from the bottom up is the order: hardware-driver-kernel-system-System call interface-Program call interface-Virtual machine/program
Note: The virtual machine mentioned here is not the virtual machine we use, but a description, such as when we write Jave program on Windows, we usually install the Jave environment, this Java operating environment we call Jave virtual machine, This virtual machine contains jave to call the library, the Java library is actually the system call interface and then abstract processing.
What the heck is the programmer doing?
As an operational dimension that has not yet been started, what do programmers look at in their current perspective?
I think programmers writing programs are like playing with more complex bricks.
When we buy the building blocks is a bunch of scattered parts, we can use this pile of scattered things into a variety of things, Systemcall and API are parts library, the programmer is to make this part of a thing, such as all are made into a car, different children have different spellings, Some children spell out the car sturdy, generous, run smooth, and some children to spell out the car bloated, ugly, barely able to run, programmers are so, not only programmers are so, most of the industry practitioners are so, I think the reason for IQ is the second, the main reason or "reality", about the reality of the problem, I will write a special article to talk about their superficial understanding, there is not much to say.
On the other hand, from this point of view, the programmer also write the program "part provider" to provide "parts" can be, then "parts" from where? Real-life parts are provided by various manufacturers, each manufacturer to provide good after a brick factory to the packaging of these parts sold to customers, such as:


In this sense, programmers are rational use of resources, combined with their own "logic" to form a program. This thing is not the same for everyone, but there are always some common modular routines, which is probably what they call the framework of it! Most programmers may be in line with the rules, which may be "Everyone is born original, but gradually become a pirate", after all, senior programmers to fight ideas, ideas, creative programmers should do is to imitate, think master logic routines.
The modules and functions in the library where are these gadgets coming from? These things are also written by programmers, everyone for me, I for everyone! In the case of system call, what is in the library is provided by the programmer of the writing system, and if it is an API, it may be provided by the author of the language.
System Library-based programming and API-based programming
Basic System library programming is lower level, such programs are more difficult to write and efficient, and API-based programming is more advanced, the human is easier to understand, but the efficiency is not high, but also directly hardware-oriented, such as writing the operating system programmer will be hardware-oriented, more difficult, but more efficient operation.
Shared Libraries
Programmers write programs If it is based on a shared library to write, then the premise of this program run is that the shared library in memory, if other programs also rely on the library, then other programs do not have to go to the hard disk call, directly to the memory of this library copy can be, such a library is called a shared library. Shared libraries and programs are parallel and all in memory and are controlled by the kernel.
The concept of sharing is now very much the way, we often use the virtual machine link cloning, sharing bicycles, virtualization technology are more or less using the concept of sharing, what is the purpose of sharing? I think the purpose of sharing is to use resources reasonably, and we use the virtual machine clones that we use frequently to illustrate. My physical machine on the three independent virtual Linux system, memory consumption is about 60%, for obsessive-compulsive I, the memory of 50% is already uncomfortable, if you open a virtual machine, and then create two link clones on this basis, also have three virtual machines, But the memory occupancy rate is only about 40%. Open three independent virtual machines are three virtual machine occupied by the resources are running in memory, so the resources are 1+1+1=3, when we use linked clones, their common use of parts, such as the kernel is shared, that is, three virtual machines together using a kernel, so the memory occupancy rate is low.
Copy when writing
In Red Hat 5, in the 6 era, the process of user space is the parent process fork () itself, the parent process and the child process is just the beginning of a shared memory space, wait until the child process to modify some resources of the parent process, the parent process is not allowed, then the child process will be used to copy the resources and then "separate portal" , of course, the process of a separate portal involves the kernel, because assigning a page box to a new process is what the kernel should do.
The security context of the process
Tom and Manry on the same host to jointly launch the LS command, assuming that the LS command is the owner of Tom, then their permissions are the same? Different, so does the process know differently?
Process is the user is initiated, the process in the computer is the user's agent, the process to whom the identity of the WHO, the user has what permissions, the process has what permissions, here to be clear, the process is also owned by all and belong to the group, LS command all the people are Tom, if it is Tom initiated, So Tom is the owner of the process, and that is the security context of the process. This process is done by the kernel.
When manry to access LS, if everyone and the owning group of LS are not manry, then LS is run as someone else.
Suid is actually achieved by breaking the security context of the process.

Linux Basic Concepts

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.