Article directory
1. Log
One picture to understand the log :
date command - view date
Directly enter the date command
Illustration:
- This is different from what we usually see. Can it be output in the format we want?
Basic grammar 1
- date + (cannot be omitted) FORMATE
- Common options:
- %H : hours (00…23)
- %M: Minutes (00…59)
- %S: seconds (00…61)
- %X: equivalent to %H:%M:%S
- %d: day(01…31)
- %m: month (01…12)
- %Y: Complete year (0000…9999)
- %F: equivalent to %Y-%m-%d
Options can be used contiguously
. So: can be used like this.
Because %F is equivalent to %Y-%m-%d, of course it can also be used in this way.
Special attention is that - the + sign needs to be added after the date command.
Basic Grammar 2
- Timestamp - A verifiable piece of data that exists at a specific point in time (the number of seconds from 0:00:00 a.m. on January 1, 1970 Green Time to the present )
- date +%s - View the current timestamp
- It can be seen that the values here show an increasing relationship.
- How to convert timestamp to current time?
- Instruction: date -d @timestamp
So how to convert it to the time we want to see? - Command: date format you want to convert -d @timestamp
What about the timestamp at 0?
Why not 0 o'clock? Because this is Chinese time, it takes 8 hours to convert from Green Time to Chinese time , so it is naturally 8 o'clock here.
cal command - view calendar
- Calendar - The cal command can be used to display the Gregorian (Gregorian) calendar. The Gregorian calendar is the calendar currently used internationally, also known as the Gregorian calendar and commonly known as the Gregorian calendar. The "Gregorian calendar", also known as the "solar calendar", is based on the earth's orbit around the sun as one year. It is common in Western countries, so it is also called the "Western calendar".
- Use cal instruction directly:
It will print out the calendar of the current month and display the date of today (I am blogging) - the 17th
Common options
- Supplement: cal + specific year - displays the calendar for the specified year.
- Shown here is the calendar for 2022.
2.find - find files
- Syntax find [directory] [options] [file to find]
Common options
-name
Show all files
Display files of specified type
Example one:
Example two:
- Here is the file to find test.c
- illustrate:
-
- find actually searches for files on the disk .
-
- Which searches for instructions under the instruction file (/usr/bin).
-
- Whereis searches for files under a specific path . This specific path generally refers to - /usr/, looking for source files, compressed packages, binary files, installation packages and other files.
3. grep - line text filtering tool
grammar
- grep [options] [content] [specified file]
Common usage
-
In order to better understand the following content, we first give the content of the specified file:
-
Find the contents of a specified file
-
Find contents except the specified file
-
Options: -v
-
Print the line number of the specified file content
-
Options: -n
-
Filter by ignoring case
-
Options: -i
Supplementary knowledge - the connection between APP and server
4. Packaging, compression and decompression
In order to better understand the following concepts, we can think of the process of your mother helping you pack your luggage.
Suppose your father helps you pack your things into the suitcase, and your mother helps you organize and arrange them - making reasonable use of space. At this time, the things are the same but smaller in size. When you get to school, they are smaller again. You need to open the suitcase again and put the things in their proper places. Such a process embodies packaging, compression, decompression and unpacking.
- Packing – putting things into one piece.
- Compression - rational use of space, putting things together, reducing space - the original 1M compression may become hundreds of KB.
- Unpack – unpack your luggage.
- Unpack – Put the items in your luggage where they belong.
- illustrate:
- The essence of packaging and compression is to turn multiple files into one file, which will not easily cause the loss of files. At the same time, the reduction of storage space will also improve the efficiency of downloading, thereby reducing time.
zip and unzip
- Note: Some LInux may not have these two instructions, so you need to switch to the root user and use yum to download.
- Command: yum install -y zip unzip
zip
In order to use zip we first create some files:
at this point we pack and compress dir1
- Operation: zip [file.zip] [specified file]
We see that there is an additional file ending with .zip.
Move into another directory we create and move into this file:
unzip
At this point we decompress and unpack the compressed package
- Operation: unzip [compressed package]
- It's strange that there is no compression at this time!
- why is that?
- The reason is simple - this is because the default packaging will only be packaged as files, and files in directories will not be packaged.
- So what to do?
- Action: -r option
Since it is the same as the previous zip operation, the zip operation here is omitted.
Here we still move the compressed package to this directory.
Now decompress dir.zip:
Create a directory and decompress it to the specified directory.
- Options: -d
tar
basic grammar
- tar [options] [file] [file]
Common options
- -z: Use .tar.tgz mode for compression
- -f: Specify the name of the newly formed document.
- -c: Pack and compress files
- -x: Decompress and unpack files
- -t: View compressed package file information
- -C: Extract to the specified directory
- uncommonly used:
- -j: Does it also have the attributes of bzip2? That is, do I need to use bzip2 compression?
- -v: Display files during compression! This is commonly used, but it is not recommended to be used in background execution processes!
Basic use
In order to better understand the instructions, we will give the operation file:
-czf - Pack and compress files
-tzf——View compressed package file information
-xzf - decompress and unpack files
5.bc - Linux calculator
- Usage: Just enter bc directly
- Exit: Just enter quit
六.uname
- Options: -a - show detailed information
- Option -r - show version kernel
7. Commonly used hot keys
1.Tab——Complete the command
-
illustrate:
-
1. If you directly press the Tab key twice, a line may appear here - whether to display all file commands. Enter y to print out all available commands.
-
2. If the possibility of the command is not unique, all possible commands will be listed here.
- 3. If the possibility of a command is unique, the missing command letters will be added here.
2.ctrl + r - search historical commands
- Note: The latest 1000 instructions are saved by default (can be modified) .