――For some reason, I learned LPIC 101 102 in a short-term intensive manner. ――I am learning with a feeling of grasping the concept, deepening my understanding of Linux rather than passing the exam. There are many parts where the command is not memorized (Ping-t remembered the range of 101 quite a bit, but Ping-t is interesting)
――This article summarizes my own interpretation of how Linux works at the moment (2020/12/21). To be honest, what is an OS rather than Linux? There are many stories like this.
――In order to deepen my understanding, I try to describe as much as possible even in a very rudimentary explanation. (If you don't like the explanation because it's too verbose, but it's okay!)
――There may be some misinterpretations, I'm sorry, I would appreciate it if you could let me know if there is anything.
--I often hit Linux commands when developing with Rails in a mac OS environment, but I often don't understand the meaning, and I have been programming for about 7 months. ――I wanted to study computer science, and I was studying for the Basic Information Technology Engineer Examination about 10 days before I started LPIC study. --Basic information learning materials -Kitami-style Illustration IT School Basic Information Engineer Reiwa 2002 -~ Learn efficiently from the beginning ~ The fastest passing course for the Basic Information Technology Engineer Examination
-Linux textbook LPIC Level 1 Speed Master Problem Collection Version 5.0 compatible (commonly known as white book) -Ping-t's strongest WEB problem collection --Google search for timely terms
In a narrow sense, it is a kernel, and in a broader sense, it is an OS.
OS is an abbreviation for operating system, which is like a computer brain in a nutshell. Without it, the computer won't work. The kernel is the core software of the OS.
** Strictly speaking, Linux refers only to this kernel. ** So why is the OS also called Linux? First, let me explain what the kernel is.
** The kernel is software that plays a very important role in the OS. ** But the computer can't do anything with just the kernel. (In the image, it feels like working alone with a person who can lead the team with 100 subordinates)
Therefore, you need excellent subordinates (software with computing functions) around you. The team (software group) that can run its subordinates as an OS to some extent is collectively called a Linux distribution or simply Linux, including the Linux kernel, ** In other words, this is Linux in a broad sense. ** **
The Japanese translation of the distribution is distributed as a unit for each OS in the sense of distribution and distribution.
There are many Linux distributions. Some are distributed free of charge, while others are paid.
Typical distribution
There are still more, but I will omit them.
First of all, from the role of the OS
--Start your computer --Various operations --Character input / output --Installation of various software --Manipulate software, middleware, and applications --Connecting external devices --Internet communication --Ensuring communication security
Etc., ** Everything that a computer can do involves the OS. ** **
How do you play that role? First, I will explain what a computer can do.
In the end, it interprets, processes, and outputs things digitally by combining a huge number of ** 0 or 1 or switch combinations **.
The letters and colors you are looking at are assigned 01, that is, numbers in binary, and the computer interprets the letters and colors by looking at them.
If you look closely, a color code, for example #FFFFFF
, is a code that means white (color code is in hexadecimal notation, but hexadecimal is easy to convert to binary, it's just a very long expression. .)
Hexagon FFFFFF
= Binary 111111111111111111111111
It seems that words and commands expressed only in binary numbers of 01 are called machine language.
Computers can't understand English or Japanese, they can only understand machine language, so you need to give instructions in machine language to get something done.
However, there is no one who keeps typing numbers like 01011100000 ... to operate the computer.
--Interpreters and compilers that translate programming languages written in human-friendly language into machine language --CUI shell that spawns a process using the corresponding file by command and processes it --System calls, applications, packages ...
And so on, ** Various tools, packages, applications, etc. act as an intermediary between the OS and the computer **, so the computer can run.
Thanks to the Linux kernel and my funny friends doing this kind of thing, various processes have been realized.
The important thing here is the idea of files.
As you all know, there are various file formats such as text files and image files.
Some files are directly expressed in machine language and some can be converted to machine language representation.
And the ** interpreters, compilers, and applications mentioned above all work using the settings and algorithms (calculation procedures) described in the corresponding files. ** **
In other words, Linux runs a computer by combining files with various instructions and files with information. ** At the extreme, software and system calls are all files. ** **
But files are abstract, how do you understand and save them on a computer that can only do 01?
The file system determines the format in which files are managed in a storage area such as an HDD (hard disk drive).
In other words, ** If you arrange the files from the computer, it's just a list of numbers such as 0101000… .. **, so if you don't decide how to separate the files, what is the file from where to where? I can't recognize that, so it's like ** let's decide how to separate it firmly **.
Various methods have been developed for the file system, and it seems that Linux has XFS, ext4, etc.
Thanks to this file system, computers can understand the existence of abstract files.
By setting the file system, you can now save files to a storage area such as an HDD! !! It does not mean that ... ** Actually, before setting up the file system, you need to divide the storage area into large groups. ** That is a partition.
A partition is like dividing a huge house called HDD into several rooms, giving each room a role (kitchen, living room) and putting the necessary files (furniture, table) in it. is not it.
By the way, setting the file system on the partition is called ** mount **.
FHS
In Linux, important files (files, tools, etc. required to start a computer) are decided to some extent in which directory to put which file, ** This is called FHS (File System Hierarchy Standard). ** **
For example, the log is saved in/var/log, and the configuration file is saved in/etc. It is decided to make it easy to understand by naming. After studying Rails, I felt something similar to RESTfull, which is often said (although it may be different).
By deciding this, compatibility with different distributions and a directory structure that is easy for users to understand are realized.
** The kernel uses these well-managed files (software) to achieve human instructions! ** **
So how do humans give instructions to the kernel? , It will be realized in the next section.
As the name implies, the shell is the "shell", which is the shell of the kernel. I imagined a Pokemon shellder. The face inside is the kernel.
Like this, the shell wraps around the kernel
** The shell provides omnidirectional mediation between humans and the kernel. ** The reason why we bother to mediate is that the kernel is very important, and it is difficult to handle it poorly and break it, so the kernel and humans communicate with each other using a cushion called a shell.
The shell has a CUI and GUI
I think many people know this,
--CUI is an abbreviation for character user interface. Character means character ** As the name implies, it is a character that the user and the computer interact with (user interface). ** ** For example, in the CUI shell called bash, users enter commands in the command prompt (terminal on Mac) to communicate with the kernel.
――The GUI is the one that operates graphically using the familiar mouse pointer.
When a command is typed into the command prompt and executed, the shell formats the command and passes it to the kernel as a system call to spawn a "process", and then returns the processing result to the command prompt again. Humans and the kernel communicate in this way.
For example, execute the ls command (command to display the subdirectory name and file name under the directory) as shown below.
$ ls
fileA fileB
The process looks like this (the characters are ridiculously dirty ...)
There is a command executable file (shell script) in the image. A shell script is a file that describes the processing of commands, ** yes, everything is a file. (Maybe)** So ** shell and shell script are similar terms, but they have completely different meanings, so be careful. ** **
The ls command also has a shell script, and when the command is executed, it will search for the corresponding shell script by referring to the path in the environment variable $ PATH.
You can use which command to find the location of the shell script for the command specified by the argument (the one that attaches to the command).
$ which ls
/bin/ls
A variable is a box that holds values in a programming language, and it often comes up when you study programming.
--Environment variables can be used throughout the computer.
--Shell variables can only be used by that process. (Cannot be used in child processes)
A process is a process executed by the shell or kernel. In fact, the shell itself is also a process. Yes, ** everything is a process. (Maybe)** ** Executing a command means spawning a child process from a parent process called the shell. ** **
It's a little confusing, but ** environment variables are like computer settings. ** It may be a little different.
The environment variable $ PATH is a variable that contains the place to look for commands!
A package is a collection of various programs and files required for a certain operation. Libraries are similar, programs and files. ** Yes, everything is a file. (I just want to say) ** There are also packages for package management (installed and updated externally).
For example, the APT tool can install packages in an "official repository" that has all the packages officially supported by Linux distributions.
When you want to install hogehoge
$ apt-get install hogehoge
I use it like this.
I wrote it for a long time, but in other words, how Linux works
** The kernel receives the instructions that mediate the shell, and the kernel leverages applications, software, files named shell scripts, etc., and returns the results. ** **
Roughly this is how it works! If you somehow grasp this concept, it will be easier to understand whether you are programming or studying for the LPIC exam. I think.
I hope it helps someone even a little. Thank you for reading to the end m (_ _) m
Recommended Posts