This is the fourth day of my participation in the November Gwen Challenge. See details: The last Gwen Challenge 2021.

👨🎓 author: Java Academic Conference

🏦 Storage: Github, Gitee

✏️ blogs: CSDN, Nuggets, InfoQ, Cloud + Community

💌 public account: Java Academic Party

🚫 special statement: the original is not easy, shall not be reproduced or copied without authorization, if you need to reproduce can contact xiaobian authorization.

🙏 Copyright notice: part of the text or pictures in the article come from the Internet and Baidu Encyclopedia, if there is infringement, please contact xiaobian as soon as possible. Wechat search public Java academic party contact xiaobian.

☠️ Daily toxic chicken Soup: Nothing to say, read the article.

👋 Hello! I’m your old friend Java Academic Party. When we play Windows is very skilled, so xiaobian today to take you to make a Linux system, xiaobian with a week to give you the whole of some Linux dry goods, because the content is too much, xiaobian sub development. Without further ado, let’s jump right into today’s topic: Linux. Linux, full name GNU/Linux, is a free to use and freely distributed Unix-like operating system. Its kernel was first released by Linus Benadicte Torvalds on October 5, 1991. It is mainly inspired by the ideas of Minix and UNIX. POSIX is a multiuser, multitask, multithreaded and multi-CPU operating system based on POSIX. It can run major Unix tools, applications, and network protocols. It supports both 32-bit and 64-bit hardware. Linux inherits the design idea of Unix taking network as the core, and is a stable multi-user network operating system. There are hundreds of different distributions of Linux, such as community-based debian and ArchLinux, and commercially based Red Hat Enterprise Linux, SUSE, Oracle Linux, and more.

15. Find a file or directory in Linux

Find [search criteria] keyword **

Search criteria:

  • Name: Search by name by default. The name can be omitted or searched by name.
  • Size: Search by file size.
  • User: Search by file owner. By default, whoever created the file is the owner of the file. It can be changed later)

15.1 Searching for Files or Directories By Name

  • Find *. TXT (relative path): searches the current directory. All of the.txt files.
  • Find * e * (relative path) : Searches for all files and directories in the current directory whose name contains e.
  • Find /etc/* / TXT: searches for all. TXT files in the /etc/directory.

15.2 Search by File Size

In Linux, the + sign means greater than and the – sign means less than.

  • Find /etc/size-5k (5M) : searches for all files smaller than 5K /5M in the /etc/directory.
  • Find /etc/size +5k(5M) : searches for all files larger than 5K /5M in the /etc/directory.

15.3 Search by file owner

  • Find /etc/user zhangsan: searches for files and directories in /etc/directory whose owner is zhangsan.

15. The command to locate a file or directory in Linux

Syntax format: locate Specifies the name of the file to search for

  • Locate is a more efficient search than find. The Locate directive can quickly locate file paths throughout the system. The Locate directive quickly locates a given file using the LOCATE database of all file names and paths established in the system. The Locate command eliminates the need to traverse the entire file system, resulting in faster queries. To ensure the accuracy of query results, administrators must periodically update locate time.
  • Locate searches for all files in the entire Liunx directory tree, while find searches for all files in a specified directory.

On Linux, files are not deleted or added in a timely manner. Linux periodically modifies files based on its entire deletion and addition system, and errors occur when using locate to manipulate files.

  • Before using locate to view the command, we need to useupdatedbCommand to synchronize the database, and then use **locate.txt* command to view the Linux system in this directory tree all TXT files.

16. Search filter command (grep)

Search filter command. Further filter by name in the results of the previous search command:

Syntax format:

  • Search command | grep [option] filter conditions
  • Check the command | grep [option] filter conditions

Search command

  • Find * TXT | grep new: search the current directory, all package of new name. TXT file.

  • The find/etc – size – 5 k | grep firefox: all etc directory file less than 5 k, and contains firefox’s file name.

To find the command

  • Cat t1. TXT | grep Beijing: look for t1. The content of the TXT file contains the content of Beijing. (This default is case sensitive)

  • Cat t1. TXT | grep – ni Beijing: look for t1. The content of the TXT file contains the content of Beijing. (The -ni attribute is case-insensitive.)

Linux about compression and decompression commands

Note:

  • Compression includes: packaging (multiple files packaged together) and compression (a large compressed file into a small compressed file).

  • There are two types of compressed packages in Linux:.gz and. Zip.

17.1 Compressing or Decompressing a File (gzip/gunzip)

Compress or decompress a single file. This command does not have the function of packaging, because this command can only operate on a single file, compress a file into a file, and decompress a file into a file, but cannot operate on multiple files or directories. The compressed package generated from a single file must be in. Gz format because it is automatically generated.

Syntax format

  • Gzip file name: Compress a single file, automatically generate a. Gz compressed package, and delete the original file.

Note: t.txt will be compressed into t.txt.gz.

  • Gunzip. G File name: Decompress the. Gz package and delete the original.

Note: t.txt.gz will be decompressed into a t.txt file.

17.2 Compressing (Packaging) or Decompressing Multiple Files and Directories (zip/unzip)

This can compress (package) or uncompress multiple files or directories, and this compression can generate a. Zip or. Gz compressed package, because using this command we can specify the name and type of the compressed file. The compressed package is usually in ZIP format.

Syntax format

  • Zip Target file name (usually using a. Zip package) List of files or directories: compressed (packaged) files without deleting previous files.

TXT t1. TXT test2: test.zip is the target compressed file. This file can be a path or a relative path.

  • Unzip Package name (. Zip) : Decompresses the specified. Zip package to the current directory.
  • ** Unzip package name (. Zip) -d Directory name: ** Decompresses the specified. Zip package to the specified directory.

Zip -d test3: Decompress the test.zip file to the test3 directory.

17.3 Decompressing (Packaging) or Decompressing Multiple Files and Directories (tar)

Compressed syntactic format

  • Tar -c Name of the target package (xxx.tar.gz) List of files or directories:. Tar can be omitted to tell others that the package is compressed using the tar command. The location of the target package can be changed arbitrarily using the absolute path. Here is the relative path of the package. The compressed file is in the same directory as the command.

Unzip syntax format

  • Tar -x Name of the package (xxx.tar.gz) : Decompresses the.tar.gz package to the current directory.
  • Tar -x Name of the compressed package (xxx.tar.gz) -c (uppercase C) Name of the decompressed directory: Decompresses the specified.tar.

Option to show

  • -c: generates a.tar.gz package file.
  • -v: Displays detailed information.
  • -f: specifies the compressed file name.
  • -z: package and compress.
  • -x: Decompress the.tar.gz file.
  • -c: specifies the file to compress.

The actual development

  • Gz file or directory list
  • Decompress the package: tar -zxvf XXX.tar. gz -c Name of the directory to which the package is decompressed

Gz rest. TXT t1. TXT: Compress the rest. TXT and t1. TXT files to the mytar.tar.gz package in the current directory.

Gz -c /opt/testDir/test5: Decompress the compressed package to a specified directory.

18. Groups and Files (Directories) in Linux

18.1 User Classification

In Linux, each user belongs to at least one group. A user cannot exist independently of a group. A user can belong to multiple groups.

In Linux, every file must belong to a group, and a file can only belong to one group.

  • Groups can be used to assign different permissions to files.

In terms of files or directories, all users on a Linu system fall into three categories:

  • Owner: By default, the owner of a file or directory is the creator and can be modified.
  • Group user: users whose root files or directories belong to the same group.
  • Other group users: are neither the owners of files or directories nor users in the same group.

18.2 Viewing the File Owner and Group

Syntax: ls-L

18.3 Changing the Owner of a File or directory

Syntax format:

  • Chown New owner file name (directory) : Changes the new owner without changing the group.
  • Chown New owner: new group File name (directory) : changes the new owner and the group.

Change the file

TXT: Changes the owner of t1. TXT.

Chown Zhangsan :dev t4. TXT: Changes the owner and group of t4. TXT.

Change the directory

Chown Zhangsan :dev test3: Changes the owner and group of the test3 directory. It only changes the group and owner of the directory, not the owner and group of the files in the directory

Chown -r zhangsan test3: changes the owners of all files in the test3 directory recursively. The R argument changes both the owner of the directory and the owner of all files in the directory.

Chown -r zhangsan:dev test: changes the owner and group of the directory and all files in the directory recursively.

18.4 Modifying the Group where a File or directory Resides

Syntax format

  • CHGRP new group file name (directory)

Change the file

CHGRP dev t2. TXT: changes the group where the current file resides.

Change the directory

CHGRP -r dev test3: Modifies the current folder and recursively modifies the group where the directory and all files in the directory reside.

19. Permission management for files or directories in Linux

Set the permissions

  • A user belongs to at least one group and can belong to multiple groups.
  • A file or directory must also belong to one and only one group.

In terms of a file or directory, all users on a Linux system can be divided into three categories

  • The owner of the
  • When the user
  • Love other group users

In Linux, any file or directory has three permissions: Read, write, and Execute. Users with different permissions have different permissions on files or directories.

19.1 Three Permissions for files

  • Read: You can read and view the contents of a file. For example, cat, more, less, head, tail, etc.
  • Write: You can modify the content of a file, such as vi or vim
  • Execute: If the file is an executable (.sh), you can run it directly, for example:./ XXXSH.

19.3 Three Permissions for directories

  • Read: You can read and view the contents in a directory. For example, the ls
  • Write: You can modify the contents of a directory, create subdirectories, create files, delete files, and duplicate files or directories.
  • Run: You can access the directory. For example: CD, etc

20. Permission control for files or directories

In Linux, any file or directory has three permissions: owner permissions, group permissions, and other group permissions.

  • Part 1 Permissions: Owner permissions. The permissions that the owner of a file or directory has on the file. In the owner permission, r, W, and x represent read, write, and execute permissions respectively. For example, RWX: has read and write permissions, r-x: has read and execute permissions, r– : only has read permissions, — : has no permissions.
  • Part 2: Group user permissions: Group user permissions on a file or directory. R, W, and x indicate the read, write, and execute permissions respectively.
  • Part 3: Other group user permissions: the permissions of users in the same group for a file or directory. R, W, and x indicate the read, write, and execute permissions respectively.

The permission to view files or directories is ls-aul

21. Change the permission of a file or directory using letters

Use the keyword: chmod

R, w, and x indicate the read, write, and execute permissions respectively.

U, G, O, and A indicate the modification permissions of the owner, group users, other group users, and all users respectively.

Use +, -, and = to add, subtract, and set permissions for a specified user.

Chmod g-w,o+w t5. TXT // Reduce the write permission for t5. TXT users and increase the write permission for other users. Chmod g= RWX t5. TXT // Add read, write, and execute permissions to the same user group. Chmod a-r t5. TXT // Reduce the read permission for all users.Copy the code

22. Modify file or directory permissions numerically

  • On Linux, the numbers 4(2^2), 2(2^1), and 1(2^0) can be used to represent r, w, and x read and write execution
  • In Linux, each file or directory has three types of permissions: owner permissions, group permissions, and other group permissions. A permission corresponds to a set of numbers, that is, a file or directory has three sets of numbers.

For example, the file permission corresponds to letters: RW-r-x And the file permission corresponds to numbers: 6 5 5. rwx r-x -wx : 753

Modify file permissions

  • chmod 777 t5.txt

23.Linux network management

  • In Linux, all configuration files are stored in the etc directory.
  • Run the vi command to modify the network IP address configuration file: vi /etc/syscongig/network-scripts/ifcfg-ens33

Modify the corresponding information in this configuration file

  • BOOTPROTO = “static”
  • ONBOOT= “yes”
  • IPADDR=192.168.11.128 (IP address)
  • GATEWAY=192.168.11.2 (GATEWAY address)
  • DNS=192.16.11.2 (Domain Name Resolution System)

Just change the configuration file to static, yes. The IP address, gateway protocol, and domain name resolution system are given by the company.

24. Process management in Linux

  • Thread concept: the execution line of a program, a program can have more than one thread.
  • The concept of a process: the execution of a program, a process will occupy a port.

Note: A process can have multiple threads. Any executable file (.exe) or command is a process and occupies a port.

In Windows, the SYSTEM process corresponds to SYSTEM and the user process corresponds to Admin.

View the process information in Linux

  • Ps: This command can only view the processes applied by users in Liunx system.
  • Ps -e: Displays information about all processes (user processes and system processes) in Linux.
  • Ps -ef: Displays all processes in Liunx in full format.
  • Ps – ef | grep mysql: view the process of execution of the specified file format information. (Check whether the program starts normally and the corresponding port number of the program.)

Shut down processes in Linux

  • Run the ps command to check the PID of a process.
  • Run the kill -9 PID command to stop the process.

Today first share here, tomorrow will continue to share with you Linux system about the management of services, like the big guys, attention not lost yo

Above project source code,Click planet to get it for freeplanet(making address)If I didn’t have my Github buddies. You can follow my wechat official account:Java academic lie prone, send Linux, free to everyone project source code, the code is personally tested by small make up, absolutely reliable. It’s free to use.