ls command
-Function: Display directory content, similar to the DOS dir
-Format: LS "Options" "FileName"
-Common parameters:
>-a:all, do not hide anything with "." A file that starts with a character
>-l: Listing information in a longer format
>-r: Print output in reverse order of filename
>-F: Plus indicator of file type
LS-LF | grep/Filter
Man ls query ls's help file
Cat command
-Function: Displays file contents, concatenate abbreviations, DOS-like type commands.
-Format: Cat "Options" "Fielname"
-Common parameters:
>-n: Displays the line number of the file's contents.
>-b: is similar to-n but does not number blank lines.
>-s: When you encounter a blank row with two consecutive lines, replace it with a line of blank lines.
MV Command
-Function: Change the name of the file or directory.
-Format: Mv[options]source destination
-Common parameters:
>-f: Forced mode, overwrite file not prompt.
>-i: Interactive mode, which prompts you when you want to overwrite the file.
RM command
-Function: Delete File command, DOS-like del command
-Format: RM "Options" filenames
-Common parameters:
>-F: Force mode, do not give prompt.
>-r,-r: Delete directory, recursive
mkdir command
-Function: Create directory, DOS-like MD command
-Format: mkdir "Options" directory
-Common parameters:
>-p: Creates a directory and its parent directory.
>-M: Specifies the pattern, similar to chmod.
More command
-Function: Screen display output results, with DOS under the more command.
-Format: More "Options" "FileName"
-Common parameters:
>-p: Display information by clearing the screen rather than scrolling
>-+num: Display from Num line
>-s: Compress consecutive lines of blank lines into one line
Cat Aa.txt | More connects two commands through the function of a pipe
grep command
-Function: Searches for a specific string in a file.
Global Regular Expression Print
-Format: grep "options" pattern "filename"
-Common parameters:
>-i: Case-insensitive
>-n: Display serial number
>-V: Show unmatched content
-Multi-Criteria Query
Grep-e "Exe|dll" Aa.txt
Find command
-function: Search for files in the specified directory
-Format: Find "path" "Options" "expression"
-Common parameters:
>-name: Searches for files with specified file names and supports wildcard characters
>-atime N: Search for files accessed in the past n days
>-ctime N: Search for files modified in the past n days
>-group gname: Search for files of a specified group
File command
-function: Determine the type of file
-Format: File "Options" filename
-Common parameters:
>-Z: Detecting Compressed file types
Description
The file command can detect whether a document is a directory, Shell script, English text,
Binary executables, C language source files, text files, DOS executable files.
chmod command
-Function: Change file access permissions.
-Format: chmod "Options" mode filename
-Common parameters:
>-r: Recursively manipulate files in a directory
>+r: Increasing Read permissions
>-w: Delete Write permission
>-x: Increasing execution permissions
Compress a folder:
TAR-CZVF up.tar.gz/updates
up.tar.gz target file
/updates folders that need to be compressed
/********************************************************** Split Line ************************************************* **************/
L Cat
1. Role
The Cat ("concatenate" abbreviation) command is used to connect and display information about one or more specified files, and it has permission to use for all users.
2. Format
Cat [Options] file 1 file 2 ...
3.[options] Main parameters
-N: Number of rows for all outputs starting with the first line.
-B: Similar to-N, but not numbered for blank lines.
-S: When a blank row with two consecutive lines is encountered, it is substituted to a row of blank lines.
4. Application examples
(1) The simplest use of CAT commands is to display the contents of a text file. For example, if we want to look at the contents of the Readme file at the command line, we can use the command:
$ cat README
(2) Sometimes several files need to be processed into a single file, and the results of this processing are saved to a separate output file. The cat command accepts one or more files on its input and prints them as a separate file to its output. For example, after adding the file contents of the Readme and install to the line number (blank line not added), append the content to a new text file File1:
$ cat README INSTALL File1
Numbering a row has-B (can only be numbered for nonblank lines) and-n (can be numbered for all rows) two parameters:
$ cat-b/etc/named.conf
L grep
1. Role
The grep command can specify the search for specific content in a file and the standard output of rows that contain those contents. The grep full name is Globalregular Expression Print, which represents the global regular expression version, and its use permissions are all users.
2. Format
grep [Options]
3. Main parameters
[Options] Main parameters:
-C: Only the count of matching rows is output.
-I: case-insensitive (applies to given only).
-H: Do not display file names when querying multiple files.
-L: Only file names that contain matching characters are output when querying multiple files.
-N: Displays matching rows and line numbers.
-S: Do not display error messages that do not exist or do not match text.
-V: Displays all rows that do not contain matching text.
Pattern Regular Expression main parameter:
\: Ignores the original meaning of special characters in regular expressions.
^: matches the start line of the regular expression.
$: Matches the end line of a regular expression.
\<: Starts with the line that matches the regular expression.
\>: To the end of the line that matches the regular expression.
[]: A single character, such as [a], that is, a meets the requirements.
[-]: range, such as [A-z], that is, a, B, C until Z all meet the requirements.
。 : all the individual characters.
*: There are characters, the length can be 0.
Regular expressions are very important concepts in Linux/unix systems. A regular expression (also known as "regex" or "regexp") is a pattern that can describe a type of string. If a string can be described with a regular expression, we say that the character matches the regular expression (match). This and DOS users can use the wildcard "*" to represent any character similar. On Linux systems, regular expressions are often used to find patterns of text and perform "search-replace" operations and other functions on text.
4. Application examples
Querying the DNS service is one of the daily tasks, which means maintaining a large number of IP addresses that overwrite different networks. There are sometimes more than 2000 IP addresses. If you want to see the NNN.NNN network address, but you forget the rest of the second part, you only know that there are two periods, such as nnnnn ... To extract all of the Nnn.nnnip addresses, use [0-9]\{3\}\. [0-0\{3\}\. The implication is that any number appears 3 times, followed by a period, followed by any number 3 times, followed by a period.
$grep ' [0-9]\{3 \}\. [0-0\{3\}\ ' Ipfile
In addition, the grep family also includes Fgrep and Egrep. Fgrep is fix grep, which allows you to find strings rather than a pattern; Egrep is an extended grep that supports basic and extended regular expressions, but does not support the application of \q pattern scopes and some of the more canonical patterns that correspond to them.
L Find
1. Role
The Find command is used to search for files in the directory, and it has access to all users.
2. Format
Find [Path][options][expression]
path Specifies the directory path from which the system looks down the directory tree to find files. It is a list of paths that are separated from each other by a space, and if you do not write path, the current directory is assumed.
3. Main parameters
[Options] Parameter:
-depth: Use a depth-level lookup process to find the contents of a file in a specified directory in a layer.
-maxdepthlevels: Represents the top level subdirectory that finds up to the start directory. Level is a non-negative number, and if level is 0, it is only found in the current directory.
-mindepthlevels: Represents the first level subdirectory that finds at least the start directory.
-mount: Not found in directories and files in other file systems (such as MSDOS, VFAT, etc.).
-version: Print version.
[Expression] is a matching expression, an expression that is accepted by the Find command, and all operations of the Find command are for an expression. It has a lot of parameters, but here are just a few common parameters.
-name: Support wildcard * and?.
-atimen: Searches for files that have been read in the last n days.
-ctimen: Search for files that have been modified in the last n days.
-groupgrpoupname: Searches for all files that have groups of grpoupname.
-user Username: Searches all files that have the owner's user name (ID or name).
-sizen: Search file size is n block file.
-print: Output search results, and print.
4. Application Skills
Find command to locate files in several ways:
(1) Search by filename
For example, if we want to find a file with a filename that is lilo.conf, you can use the following command:
Find/-namelilo.conf
The "/" after the Find command searches the entire hard drive.
(2) Quick Find files
Finding a file from a filename can be a real problem, and it takes a long time, especially when large Linux filesystems and large-capacity hard disk files are placed in a very deep subdirectory. If we know that this file is stored in a directory, it can save a lot of time by looking down in the directory. For example, smb.conf file, from its file suffix ". conf" can be judged that this is a configuration file, then it should be in the/ETC directory, you can use the following command:
Find/etc-namesmb.conf
This way, you can shorten the time by using the Quick Find files method.
(3) Search method according to partial filename
Sometimes we know that only a single file contains the ABVD 4 words, then to find all the system contains the 4 characters of the file can enter the following command:
Find/-name ' *abvd* '
When you enter this command, the Linux system will find all files containing the ABVD 4 characters in the/directory (where * is a wildcard), such as abvdrmyz files, etc.
(4) Find a file using a mixed lookup method
The find command can use a mixed lookup method, for example, if we want to find a file in the/etc directory that is larger than 500000 bytes and modified within 24 hours, you can use-and (and) to link two lookup parameters together into a mixed lookup.
Find/etc-size +500000c-and-mtime +1
L mkdir
1. Role
The role of the mkdir command is to establish a subdirectory called dirname, similar to the MD command under MS DOS, which uses permissions for all users.
2. Format
mkdir [Options] Directory name
3.[options] Main parameters
-m,--mode= mode: Set permissions < mode, similar to chmod.
-p,--parents: Create an upper-level directory when needed, not as an error if the directory already exists.
-v,--verbose: Displays information each time a new directory is created.
--version: Leave after displaying version information.
4. Application examples
You can set permissions on the directory when you create the directory, with the parameter "-M" used. Assuming that the directory name you want to create is "tsk", so that all users have rwx (that is, read, write, and Execute permissions), you can use the following command:
$ mkdir-m777 tsk
l file
1.
File determines the file type by probing the contents of the file and uses permissions for all users. &NBSP;&NBSP
2. Format
file [options] filename
3.[ Options] The main parameter
-V: Displays version information after standard output and exits. &NBSP;&NBSP
-Z: Probing for compressed file types. &NBSP;&NBSP
-L: Allows connections to be met. &NBSP;&NBSP
-F Name: Reads the list of file names to parse from the file NameFile. &NBSP;&NBSP
4.
Use the file command to know whether a file is a binary (elf-formatted) executable file, a shellscript file, or whatever format it is. File types that can be identified are directories, shell scripts, English text, binary executables, C-language source files, text files, and DOS executable files. &NBSP;&NBSP
5. Application instance
If we see a file grap without a suffix, you can use the following command: &NBSP;&NBSP;
$ file grap
Grap:english text
The system now shows that this is an English text file. It is necessary to note that the file command does not detect multimedia file types including graphics, audio, video, and so on.
l
dd
1. The effect
DD command is used to copy files and convert and format data based on parameters. &NBSP;&NBSP
2. Format
DD [options]
3.[ Opitions] Main parameter
bs= byte: Force ibs=< byte > and obs=< byte >. &NBSP;&NBSP
cbs= byte: The specified < byte > per conversion.
conv= Keyword: Converts a file based on a comma-separated keyword representation. &NBSP;&NBSP
count= block number: Only the input data of the specified < block number > is copied.
ibs= Bytes: reads the specified < byte > each time. &NBSP;&NBSP
if= File: Read < file > content, not standard input data.
obs= Bytes: Writes the specified < byte > each time. &NBSP;&NBSP
of= File: Writes data to < file instead of standard output. &NBSP;&NBSP
seek= block number: First skip the output data of the specified < block number in OBS units >. &NBSP;&NBSP
skip= block number: First skip the input data in the number of specified < blocks in IBS, >. &NBSP;&NBSP
4. Application instance
DD commands are often used to make Linux boot disks. Find a bootable kernel so that its root device points to the correct root partition, and then write it to the floppy disk using the DD command: &NBSP;&NBSP
$ rdev vmlinuz/dev/hda
$dd if=vmlinuzof=/ DEV/FD0&NBSP;&NBSP
The code above shows that using the Rdev command to point the root device in the bootable kernel vmlinuz to/dev/hda, replace "HDA" with its own root partition, and then write the kernel to a floppy disk using the DD command. &NBSP;&NBSP
l ls
1. the
ls command is used to display directory content, similar to the DOS dir command, which uses permissions for all users. &NBSP;&NBSP
2. Format
ls [options][filename]
3.options primary parameter
-A, --all: Do not hide any items that start with the "." Character. &NBSP;&NBSP
-a,--almost-