Introductory knowledge for backend Linux

Why use Linux

The article comes from https://librehunt.org/, in this website, you can choose the Linux version that suits you according to the options it provides

  1. It’s safe and private. No tracking.
    No company watching over you, no “big brother is watching you” nonsense. Just your desktop and you, with no big scary corporation stealing all your data.
  2. It’s fast. Lightning Fast.
    It’s super fast. So fast, that 100% of super computers use it. All Android phones use it too, and most servers keeping your websites, apps, and cat videos online are as well.
  3. It’s Open Source. Open Source?
    Fancy term time! Open Source means anyone is free to do whatever they want with Linux. You can copy and make your own version, change a few things and help out Linux, or really anything! It gives more power to you!
  4. It’s got many flavours! Awesome!
    The actual term is “distro”, as in your own distribution of Linux, but it just means that anyone can make their own Linux flavour by say, changing the theme, and putting different apps.
    Some distros make it friendly for beginners, or something ultra-powerful, but scary looking, for super computers.
    Just like Windows and Mac have a different desktop, or interface, Linux has many different ones too! Some distros have a desktop that’s unique to the distro while others use ones that are common across multiple distributions.

To sum up: 1) Security and high privacy (unlike Windows and Mac, your data may be collected by them); 2) Super fast speed; 3) Open source, free to use, and can be developed according to your own needs; 4 ) versions are rich, you can choose according to your needs.

Different versions of Linux

The "different versions" here refer to distribution versions, such as the more commonly used CentOS and Ubuntu, which are all based on the Linux kernel. (The package manager in the figure can be simply the command set provided by each version for users)
insert image description here
What is the difference between each and each?
For example, support for some old hardware, update frequency, support for games, interface style (some have no interface at all and can only use commands), support for touch screens, and support for some special things, etc., Each has its own characteristics. For details, you can go to the website I mentioned above to have a look, and choose the version that suits you.

Directory Structure

insert image description here

The boot system must:

  • /boot: stores the kernel files used when starting Linux, including connection files and image files.

  • /etc: stores all the configuration files and subdirectory lists required by the system, and changing the files in the directory may cause the system to fail to start.

  • /lib: store the basic code library (such as c++ library), its function is similar to the DLL file in Windows. Almost all applications need to use these shared libraries.

  • /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 system for pseudo-terminals. The file system is a visual reflection of the kernel device tree. When a kernel object is created, the corresponding files and directories are also in the kernel object subsystem.

Command set:

  • /bin: Stores the most commonly used programs and instructions.

  • /sbin: Programs and commands that only system administrators can use.

External file management:

  • /dev: The abbreviation of Device (device), which stores the external devices of Linux. Note: Accessing devices and accessing files is the same in Linux.

  • /media: Other Windows-like devices, such as U disk, CD-ROM, etc., after recognition, Linux will put the device in this directory.

  • /mnt: 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.

Temporary Files:

  • /run: It is a temporary file system that stores information since the system was started. When the system restarts, the files in this directory should be deleted or cleared. If you have a /var/run directory on your system, it should point to run.

  • /lost+found: Generally, it is empty. After the system is shut down illegally, some files are stored here.

  • /tmp: This directory is used to store some temporary files.

account:

  • /root: The user's home directory of the system administrator.

  • /home: The user's home directory, named after the user's account.

  • /usr: Many applications and files of the user are placed in this directory, which is similar to the program files directory under Windows.

  • /usr/bin: Applications and commands used by system users.

  • /usr/sbin: More advanced management programs and system daemons used by superusers.

  • /usr/src: The default placement directory for the kernel source code.

During operation, use:

  • /var: store frequently modified data, such as log files of program operation (under the /var/log directory).

  • /proc: Manage memory space! The virtual directory is the mapping of system memory, we can directly access this directory to obtain system information. The content of this directory is not on the hard disk but in memory, and we can also directly modify some files in it to make changes.

For extension:

  • /opt: It is empty by default, and we can install additional software in it.

  • /srv: stores the data that needs to be extracted after the service is started (empty if no server is used).


Although there are so many, the ones I usually use are the following:

  • /bin: For example, after installing a software, you can enter its bin directory to see what commands it has.
  • /opt: opt is completely empty. Generally, I put some software configuration files here. If it is docker, I may map the configuration file directory in docker to this for easy operation.
  • /home: is also empty, sometimes things in opt will also be put here
  • /var: The log files of the software are here, you need to go here to read.
  • /usr: Some software may be installed here, but I basically use Docker, so it is not very useful.

In short, where the general things are placed, they are all based on the referenced tutorials to reduce unnecessary troubles.

file attributes

Briefly, it is not necessary for ordinary back-end personnel.
insert image description here
first field:

  • [ d ] represents the directory;
  • [-] stands for file;
  • [ l ] represents a link document (similar to a shortcut key);
  • [ b ] represents the interface device (random access device) available for storage in the device file;
  • [ c ] represents the serial port device in the device file, such as keyboard, mouse (one-time read device).

The following characters, in groups of three:
insert image description here

Next is the number of files or other things in this file or folder.

Next is the owner and the group:
the first one is to indicate who they belong to (specifically to each person), and the second group means that as long as everyone in this group has this authority (in the Linux system, users are assigned by group) categorical, a user belongs to one or more groups).

Next comes size, time, name.

How to change permissions?

Simply write and write, and it chmod 770can be used by individuals.
1) chgrp: Change file ownership group (not commonly used).

chgrp [-R] 属组名 文件名

2) chown: Change the owner of the file, and you can also change the group at the same time (not commonly used).

chown [-R] 属组名 文件名
chown [-R] 属主名:属组名 文件名

3) chmod: Change 9 attributes of the file.

There are nine basic permissions for Linux files, namely owner/group/others, each with its own read/write/execute permissions.

chmod [-R] xyz 文件或目录

Change the case.

chmod 770 filename

Here you need to know that r=4, w=2, x=1, 7 will kill all three permissions (4+2+1), and 6 is the read and write permission (4+2). Then the "person" represented by the number corresponds to the above picture, the first is the master, the second is the group, and the third is other users.

Commonly used commands in actual combat

  1. cd switch (cd /)
  2. mkdir Create a new folder (generally add a back -p, for example, if you want to create /opt/es/logs, if you don't add -p, there will be an error without es; if you add it, it will create one for you without es)
  3. pwd path at this time
  4. rm -f filename
  5. rm -rf foldername
  6. touch file (create file)
  7. ls (-a shows hidden, -l directory information)
  8. ./run file
  9. cat only reads

Guess you like

Origin blog.csdn.net/Fishermen_sail/article/details/130936989