[Linux Development Notes] "Linux Embedded Development from 0 to 1" (1): A Preliminary Exploration of Linux——The First Encounter with Linux

1. What is Linux

Linux is an operating system, an open source and free operating system, a UNIX-like operating system that is free to use and spread freely, and a POSIX-based multi-user, multi-tasking, multi-thread and multi-CPU operating system.

Simply put, Linux is just an operating system...

When you first explore Linux, you only need to know that Linux is an open source operating system, and don't be bound by other concepts.

Linux

2. Differences and connections between Linux and Windows

What is the difference and connection between Linux and Windows?

First of all, we need to know that both Linux and Windows are operating systems. As for the differences and connections, I will use a hot pot restaurant as an example here.

  • "Hot Pot Restaurant" Named Windows

You go to a hot pot restaurant called Windows (operating system), and the boss brings you the hot pot (system kernel). Which spices (functional modules), if you ask the boss how the hot pot base (system kernel) is made (source code), he will not tell you because this is his secret recipe, and it is charged, you just order it on the menu Just cook the dish (app) in it.

  • A "Hot Pot Restaurant" Named Linux

Then, you found a hot pot restaurant (operating system) called Linux. In this hot pot restaurant, all the raw materials (functional modules) for making hot pot base (system kernel) are neatly placed in front of you, and you can add them arbitrarily. Use your favorite raw materials (functional modules) to fry a pot of your own hot pot base (system kernel). Of course, if you don’t know how to flip the spoon, the boss will provide you with a complete pot of hot pot base (system kernel) that has already been fried. Customers in this store have their own tastes, so the base ingredients in each pot are different, and they are all fried according to their own needs and tastes. The owner of this Linux hot pot shop not only does not charge, he also allows anyone to use his raw materials to open a shop (distribution), and hot pot shops (Linux distributions) such as Ubuntu, Fedora, openSUSE, and CentOS have won well in the market. word of mouth.

Here is just an analogy based on the different characteristics of Windows and Linux. In fact, the differences between them are far more than these. For example, the file system mentioned in Section 5 will be discussed later. Take it alone for comparison.

3. Linux environment installation

As one of the many distributions of Linux, Ubuntu has a very good desktop system. The usage habits of the desktop system are similar to those of the Windows desktop system, which greatly reduces some learning thresholds. Therefore, we generally use Ubuntu to learn when learning Linux.

Ubuntu

Generally, there are three common methods for Ubuntu environment installation:

  1. Installing Ubuntu on a virtual machine Of course, few of us have the conditions to have two computers, one Windows and one Ubuntu. Installing Ubuntu on a virtual machine is a relatively common method, using VMware or VirtualBox for installation. This method is equivalent to installing an Ubuntu system in a virtual environment on the basis of Windows as the physical machine. There are a lot of installation methods on the Internet, so I won’t go into details here.

VMware

  1. There are many online searches for making Windows and Ubuntu dual systems, but compared to the virtual machine method, it is quite troublesome if you need to switch back and forth between Windows and Ubuntu. After all, the computer needs to be restarted. This method is not recommended. , the efficiency is very low.
  1. WSL installs Ubuntu This method is that Windows itself provides a virtual subsystem for Ubuntu. The installation method is described in detail in another article. [Linux Development Notes] VSCode+WSL——Windows builds the most lightweight and convenient Ubuntu/Linux development environment

WSL

4. Linux commands

At this point, you should have a working Ubuntu on your computer.

If you have an Ubuntu desktop system, use the shortcut key "Crtl+Alt+T" to open a terminal.

If Ubuntu is installed in WSL mode, you can directly run Ubuntu in Windows to get a terminal.
WSL+Free

After opening the terminal, you can see that there is a highlighted text in the format of "username@linuxpc:~$" at the top of the line in the terminal. This is the command line prompt of Linux, and the part on the left of "@" is the current The user name of the login terminal, the part on the right is the current computer name, the character behind ":" represents the current path, the command line prompt of ordinary users ends with the "$" symbol, and the super user root ends with "#". If the current path displays "~", it means the current main directory; if the current path displays "/", it means the current system root directory.

Many commands provided by the system can be executed in the Linux terminal. Linux commands generally consist of three parts, separated by spaces:

  1. command command
  2. options option
  3. parameter parameter

The general execution format is as follows:

command [options] [parameter]

You can view the help manual of this command through "command -h" or "command --help". Here we view a manual of the "cd" command and execute the following command to view:

cd --help

The display of the "cd" command help manual is shown in the figure below. If the input item of the command has square brackets "[ ]", it means that the item is optional, and if it is in angle brackets "< >", it means that the item is required. , cannot be omitted:

cd command help manual

Enter the following command in the terminal and press Enter:

cd /

In this command, "cd" is the command to be executed. The format of the command is "cd path", which means to jump to the specified path. When the "/" character is used as the path, it means the root directory of the system, so the "cd /" The meaning of the command is to jump to the root directory of the system.

After jumping to the root directory, execute the following command and press Enter:

ls -l

In this command, "ls" is a command, which means to list the content under the specified path, and "-l" is an option, which means to display detailed information. In fact, we can also enter the specified path after this command, which is omitted here It means that the detailed information listed by "ls" defaults to the current path.

Use the "ls --help" command to view the help manual for the command "ls". Commonly used ls commands are as follows:

  1. ls: List the files and directories visible under the current path;
  2. ls -l: List the details of files and directories visible under the current path;
  3. ls -a: List all files and directories in the current path, including hidden files and directories.

After the "ls -l" command is successfully executed, the terminal will display the detailed content of the current root directory, as shown in the following figure:

ls -l result display

5. File system

In the previous section, we listed the visible files and directories under the root directory of the system through "ls -l" in the "/" root directory. Here we can see the difference from the Windows file system. In Windows, open "My Computer ", what we see is each drive letter, there are disk partitions such as C drive and D drive, but the rules in the Linux file system are very different from those in Windows. As for how to define these rules in the Linux file system, We will introduce this point in a later chapter.

Each directory in the root file system in Linux has its own different meanings. The specific meanings of each directory are as follows:

/bin: bin is the abbreviation of Binaries (binary files), this directory stores the most frequently used commands;

/boot: Here are some core files used when starting Linux, including some link files and mirror files;

/dev: dev is the abbreviation of Device (device), and the external devices of Linux are stored in this directory. The way of accessing devices in Linux is the same as the way of accessing files;

/etc: etc is the abbreviation of Etcetera (etc.), this directory is used to store all configuration files and subdirectories required for system management;

/home: The user's home directory. In Linux, each user has its own directory. Generally, the directory name is named after the user's account;

/lib: lib is the abbreviation of Library (library). This directory stores the most basic dynamic link shared libraries of the system. Almost all applications need to use these shared libraries;

/lost+found: This directory is usually empty. When the system is shut down illegally, some files are stored here;

/media: The Linux system will automatically recognize some devices, such as U disk, CD-ROM, etc. After recognition, Linux will mount the recognized devices to this directory;

/mnt: The system provides this directory to allow users to temporarily mount other file systems. We can mount the CD-ROM on /mnt, and then enter this directory to view the contents of the CD-ROM;

/opt: opt is the abbreviation of Optional (optional), which is the directory for installing additional software on the host. For example, if you install an ORACLE database, you can put it in this directory, which is empty by default;

/proc: proc is the abbreviation of Processes (process), /proc is a pseudo file system (that is, virtual file system), which stores a series of special files of the current kernel running state, this directory is a virtual directory, it It is the mapping of system memory, we can get system information by directly accessing this directory;

/root: This directory is the system administrator, also known as the user's home directory of the super authority;

/sbin: s is the meaning of Super User, which is the abbreviation of Superuser Binaries (binary files of super users), and the system management program used by super users is stored here;

/srv: This directory stores some data that needs to be extracted after the service is started;

/sys: This is a big change in the Linux2.6 kernel. A new file system sysfs in the 2.6 kernel is installed in this directory. The sysfs file system integrates the information of the following three file systems: the proc file system for process information, the devfs file system for devices, and the devpts file for pseudo-terminals system, the file system is an intuitive reflection of the kernel device tree, when a kernel object is created, the corresponding files and directories are also created in the kernel object subsystem.

/tmp: tmp is the abbreviation of temporary (temporary). This directory is used to store some temporary files;

/usr: usr is the abbreviation of unix shared resources (shared resources) (not the English abbreviation of the user, this point needs to be noted, it is helpful for understanding), this is a very important directory, many applications and files of the user are placed under this directory;

/usr/bin: applications used by system users;

/usr/sbin: A more advanced management program and system daemon used by super users;

/usr/src: The default placement directory of the kernel source code;

/var: var is the abbreviation of variable (variable). This directory stores things that are constantly expanding. We are used to putting those frequently modified directories in this directory, including various log files;

/run: It is a temporary file system that stores information since the system was started. When the system is restarted, the files in this directory should be deleted or cleared.

Guess you like

Origin blog.csdn.net/qq_37354286/article/details/129371239