The Linux system information is stored in the file, and the file is similar to the ordinary official document. Each file has its own name, content, storage address, and some other management information, such as the user, the size of the file, etc. The file can be a letter, a address book, or a source statement of the program, the data of the program, can even include executable programs and other non-text content. The Linux file system has a good structure, and the system provides a lot of file handler. Here mainly introduces the commonly used file processing commands. File 1. The role of the file is determined by the probe file content, using the right to use all users. 2. Format File [Options] file name 3. [options] Main parameters - V: Display version information after the standard output, and exit. -z: Detect the compressed file type. -L: Allows connection. -f name: Read the list of files to be analyzed from the file namefile. 4. Brief Description Use the file command to know that a file is the executable of binary (ELF format), or the shell script file, or other format. FILE can identify file types with directory, shell scripts, English text, binary executables, C language source files, text files, DOS executables. 5. Application example If we see a file GRAP with a suffix, you can use the following command: $ file grap grap: english text At this time, this is an English text file. It should be noted that the file command cannot detect multimedia file types such as graphics, audio, and video. MKDIR 1. The role of the mkdir command is to establish a subdirectory named DIRNAME, similar to the MD command under MS DOS, which is all users. 2. Format MKDIR [Options] Directory Name 3. [Options] Main parameters - M, --Mode = mode: Set permissions
$: Match the end line of the regular expression. / <: From the row of matching regular expressions. />: The row of the matching regular expression is over. []: Single character, such as [a], is a conformity. [-]: Range, such as [A-Z], that is, A, B, and C, until Z is compliant. . : All single characters. *: There is a character, the length can be 0. Regular expressions are very important concepts in the Linux / UNIX system. Regular expression (also known as "regex" or "regexp") is a pattern that can describe a class of strings (Pattern). If a string can be described in a regular expression, we say this character and the regular expression match (Match). This and DOS users can use wildcard "*" to represent any character. On Linux systems, regular expressions are often used to find text mode, and the text execute "Search-Replace" operation and other functions. 4. Application instance query DNS service is one of the daily work, which means maintaining a large number of IP addresses overwriting different networks. Sometimes IP address will exceed 2,000. If you want to view the Nnn.nnn network address, but I forgot the rest of the second part, I only know that there are two periods, such as NNN NN ... To extract all NNN.NNN IP addresses, use [0-9] / {3 / }/ .[0-0/ }/. The meaning is that any number appears 3 times, then follow the sentence, then the arbitrary number appears 3 times, then follow the sentence. $ GREP '[0-9] / {3 / }/.[0-0/ {3/On }/' ipfile supplementary description, the GREP family also includes FGREP and EGREP. FGREP is FIX GREP, allowing a string instead of a mode; EGREP is extended GREP, supports basic and extended regular expressions, but does not support / Q mode scope and some more specifications corresponding to it. DD 1. The action DD command is used to copy the file and convert the data and format data according to the parameters. 2. Format DD [options] 3. [OPitions] Main parameters BS = byte: Forced IBS =
Find 1. The role of the role of the Find command is to search for files in the directory, and its usage rights are all users. 2. Format Find [PATH] [Options] [Expression] Path Specifies the directory path, and the system starts along the directory tree down here. It is a path list, separated by spaces, if you don't write PATH, then default is the current directory. 3. Main parameters [options] Parameters: -Depth: Use the depth level lookup process, you can give priority to the file content in a specified directory. -MaxDepth levels: Represents the last directory of the start directory. Level is a non-negative number, if Level is 0, it means to find only in the current directory. -Mindepth levels: indicates at least the colordeling of the first directory. -Mount: Find in directory and files in other file systems such as MSDOS, VFAT, etc.). -Version: Print version. [Expression] is a matching expression, which is an expression acceptable, and all operations of the Find command are for expressions. Its parameters are very many, and only some common parameters are introduced here. -Name: Support unmanagers * and? -Time N: Search for files read in the past N days. -Ctime N: Search for files modified in the past N days. -Group GrPoupName: Search all groups of files for GrPoupName. -User Username: Search all file owners for the user name (ID or name). -Size N: Searching the file size is the file of n block. -Print: Output search results, and print. 4. Apply Skills Finding Documents: (1) Find, for example, file name, for example, we want to find a file name that is lilo.conf, you can use the following command: Find / -Name Lilo.conf Find Command The "/" indicates the search throughout the hard disk. (2) Quick Find Files Find files according to file names will encounter a practical problem, which is a long period of time, especially the large Linux file system and massive hard drive files are placed in a deep subdirectory. If we know that this file is stored in a certain directory, you can save a lot of time as long as you find it under this directory. For example, the SMB.conf file, from its file suffix ".conf" can determine that this is a configuration file, then it should be in the / etc directory, you can use the following command: find / etc -name smb.conf, use "Quick Find File" mode can shorten the time. (3) Finding method according to some file name Sometimes we know that only files contain 4 words, then find all files containing these 4 characters in the system, you can enter the following command: Find / -Name '* Abvd * 'Enter this command, the Linux system will find all files containing 4 characters contained in the / directory (where * are wildcards), such as AbvDrmyz, etc., can be displayed.
(4) Use the mixed lookup method to find the file Find command to use a mixed lookup method, for example, we want to find more than 50,000 bytes in the / etc directory, and a file modified within 24 hours, you can use -and ( And) link two lookup parameters together into a mixed lookup method. Find / etc -Size 1 500000c -and -mtime 1 mv 1. The action mv command is used to change the file or directory, or transfer the file from a directory into another directory, its usage authority is all users. This command is like a combination of REN and MOVE in the DOS command. 2. Format MV [Options] Source file or directory target file or directory 3. [Options] Main parameters -i: interactive operation. If the MV operation will result in overwrite the existing target file, the system is inquiry to override, requiring the user to answer "Y" or "n", which avoids erroneous overwriting files. -F: interactive operation is prohibited. The MV operation does not give any indication when an existing target file is covered, and the i parameter will no longer work after specifying this parameter. 4. Application example (1) Move all files in / usr / cbu to the current directory (use ": $ mv / usr / cbu / *. (2) Rename the file CJH.txt Rename WJZ .txt: $ mv cjh.txt wjz.txt ls 1. The role ls command is used to display the directory content, similar to the DIR command under DOS, and its use right is all users. 2. Format ls [options] [filename] 3.Options Main parameters -a, --all: Do not hide any items starting with "." Characters. -A, - Almost-all: Any item other than "." And ".." is listed. --Author: Prints each document authority. -B, -, --escape: The unprintable character is represented by an octa binary overflow sequence. - Block-size = Size: Blocks in bytes specified