More
Cat-like, but more than the entire file content from top to bottom display on the screen, but a page by page to facilitate users to read pages. The most basic instruction is space to go down a page, b that is to turn back a page display, but also the function of the search string
+n: Starting from Nth line
-N: Defines the screen size as n rows
+/pattern: Searches for the string patern before each file is displayed and then displays it from the first two lines of the string
-P: Pages are changed by clearing windows instead of scrolling, similar to the-C option
-S: Displays a contiguous number of empty rows as a row
-U: Remove the underline from the contents of the file
Common Operation Commands:
Enter: down n rows, need to be defined, default to 1 rows
SPACEBAR: Scroll down one screen
B: Scroll up one screen
=: Output Current line number
V: Call VI Editor
Q: Quit more
For example:
More +3 Log1.log: Show the contents of Log1.log from line 3rd
More +/day3 Log1.log: Finds the first line of a string that appears ' Day3 ' from a file and displays the output from the first two lines of the line
More-5 Log1.log: Sets the number of rows per screen displayed
Ls-l | More-5:more often used with other commands, generally because some commands output too much content, so use more to page out
which
In the path specified by the path variable, search for the location of a system command and return the first search result. That is, the which command can see the existence of a system command and the command that executes exactly which location.
Find
Used to find files in the file tree and handle them accordingly
-name: Find files by file name
-perm: Find files by file permissions
-user: Find files According to the owner of the file
-group: Find files according to the group to which the files belong
-mtime<-n><+n>: Find files According to file change time,-n means n days, +n means n days ago
-newer file1 file2: Find files that change time between File1 and File2
For example:
Find-mtime-2: Find files that have been modified for 48 hours
Find-name "*.log": Finds files with the current directory ending with "*.log"
Find/opt/soft/test-perm 777: Find a file with permission 777 under the specified directory
Find-type f-name "*.log": Find common Files in the current directory ending with ". Log"
Find-type D | Sort: Finds all current target directories and sorts
chmod
Used to change access rights for Linux system files or directories
-F: Error message not output
-C: Report processing information when a change occurs
-r: Handles all files in the execution directory and its subdirectories
-V: Detailed processing information is displayed at run time
< permission scope >+< permission settings;: Make the directory or file within a permission scope have the specified permission
< permission range >-< permission settings;: Delete specified permissions for a directory or file within a permission range
< permission range >=< permission settings;: Set permissions for a directory or file within a permission range to a specified value
Permission Range |
Permission Code |
U: Current user of directory or file |
R: Read, code 4 |
G: Current group of directories or files |
W: Write, code 2 |
O: Other users or groups |
X: Execute, Code 1 |
A: All Users and Groups |
-: Delete, code 0 |
|
S: Privileged Permissions |
For example:
chmod a+x log1.log: Settings file Log1.log All users or groups have Execute permissions
chmod ug+x,o-x Log1.log: Set different user rights at the same time
chmod u=x log1.log: Revoke user's original permission to Log1.log and set to X
Chmod-r u+x test4: Recursively assign execute permissions to all files and subdirectories under Test4
chmod 751 File: Assign read, write, execute permissions to the file, master, assign read, execute permissions to the group, and other users to assign Execute permissions
Tar
Used to compress and decompress the file, tar itself does not have the compression function, it is called the compression function implementation
-C: Create a new compressed file
-D: Record file differences
-R: Add files to a compressed file
-X: Extracting files from compressed files
-T: Displaying compressed file contents
-Z: Support gzip unzip files
-V: Show Operation procedure
-F: Specifying Compressed Files
For example:
TAR-CVF Log.tar Log1.log: Package Log1.log only into Log.tar, not compressed
TAR-ZCVF log.tar.gz Log1.log: Pack log1.log into log.tar.gz and point to gzip compression
TAR-ZTVF log.tar.gz: Check the contents of the log.tar.gz, because log.tar.gz is compressed with gzip, so add Z
TAR-ZCVF log30.tar.gz log1.log Log2.log: Package multiple files into one file
TAR-ZXVF log30.tar.gz Log2015.log: Extract the Log2015.log from the log30.tar.gz
Diff
Compares a single file or directory content, and if you specify that the comparison is a file, it is only valid if the input is a text file. Compare the similarities and differences of text files in a row-by-line manner. If you specify a directory, the diff command compares a text file with the same name in two directories, listing different binaries, common subdirectories, and files that appear only in one directory.
-B: Do not check for differences in whitespace characters
-B: Do not check for blank lines
-I: Do not check for different case
-Q: Show only any differences, unrealistic details
-Y: The similarities and differences between the explicit files in side way
-W: Specifies the column width when using the parameter-y
For example:
Diff Log1.log Log2.log: compare two files, output results such as "3C3" and "8c8" indicate that two files differ in the third and 8th lines, "11,12D10" means that the first file is more than the second file in line 11th and 12th. The normal format mode of the diff command displays three hints, A-add, C-change, D-delete
Diff test3 Test4: compare Test3 and test4 two folders differently
Diff Log1.log Log2.log-y-w 50: Output side-by, and make column widths of 50
Grep
Used to filter/search for a specified string. You can use regular expressions, which can be used with multiple commands
-A: Displays the line that matches and what follows
-B: Displays the line that matches and the previous content
-C: Display line and before and after content
-C: Calculate the number of rows that match
-I: Ignore case
Rule expressions
^: ' ^grep ' means matching all lines beginning with grep
$: ' grep$ ' means matching all lines ending with grep
.: ' gr.p ' means match ' gr ' followed by any character and then ' P '
*: ' *grep ' indicates a line that follows grep after matching one or more spaces
[]:[gg]rep means matching grep with grep
[^]:[^a-fh-z]rep matches lines that do not start with a-f, H-z, and follow the rep
For example (the grep command is most often used with other commands to make sense):
Ps-ef | Grep-c SVN: Find the number of processes specified
Cat Test.txt | Grep-f test2.txt: Search in Test.txt after keywords are read from text2.txt
Cat Test.txt | grep NF Text2.txt: Search for and display line numbers in Text.txt after reading the keywords from the Text2.txt
grep ' Linux ' text.txt test2.txt: Search for keywords ' linux ' from multiple files
Cat Test.txt | Grep-e ' ed|at ': Displays lines containing ed or at
Ps
Used to list those processes running in the system
The process states in Linux are:
State |
Meaning |
R |
Running: Running or waiting in the running queue |
S |
Interrupt: In hibernation, blocked |
D |
Non-interruptible: The received signal does not wake up and is not operational, the process must wait until there is an interrupt |
Z |
Zombie: Process Terminated |
T |
STOP: Process stops running after receiving Sigstop, SIGSTP, Sigsin, Sigsou signals |
-A: Show All processes
-e: equivalent to-a
-C: Displays the real name of the process
-F: Show relationships between programs
For example:
Ps-u root: Show root process information
PS-EF: Displays all process information along with its command line
Ps-ef | grep ssh:ps often wins with grep to show specific processes
Ps-l: List the PID and related information that is currently your own login
PS aux: List all currently in-memory processes
Netstat
Used to display various network related information, such as network connection, routing table, interface status, multicast members, etc.
Netstat output:
Proto |
Recv-q |
Send-q |
Local Address |
Foreign Address |
State |
Protocol, TCP, UDP, UNIX, etc. |
Receive Queue |
Send Queue |
Native Address |
Remote Address |
State |
-A: Show all options
-T: Show only TCP options
-U: Show only UDP options
-N: Does not display the host alias, can display the number all displays the number
-R: Show routing information, routing table
-S: Statistics according to various protocols
-L: List only the service status of listen
For example:
Netstat-at: List all TCP ports
NETSTAT-LT: List only all ports listening on TCP
Netstat-s: Displays statistics for all ports
Netstat-p: Show PID and process name in output
Uname
Get operating system-related information
-A: List details, followed by kernel name, hostname, kernel version number, kernel version, hardware name, processor type, hardware platform type, operating system name
-M: Display host CPU name
-N: Displays the node or network name of the host on the network
-r: Display Linux OS kernel version number
-S: Displays the Linux kernel name
-V: Shows the version of the operating system
-P: Display processor type
-I: Display hardware platform type
-O: Displays the operating system name
Linux3:more, which, find, chmod, Tar, diff, grep, PS, netstat, uname