Linux re-added

view file command

cat : used to view the complete file content

-n : Display the line number of each line, including blank lines

-b : Display the line number of each line, excluding blank lines

tac : look upside down

 

more : Use more or less to paginate the file when viewing more than one page of content.

Press space to display the next page of the file, and press enter to display the next line. In the lower left corner there is a percentage of what has been displayed

+num Display content starting at line num

-num specifies num lines to display per screen

-s compress repeated spaces into a single blank line

 

less : Similar to more, the knowledge effect is higher and the function is more. . For example, display the number of lines.

-N : show line number

 

head : used to view the contents of the header of the file

-num Display starting num lines. If not specified, 10 lines will be displayed by default

tail : used to view the content at the end of the file

-num Display starting num lines. If not specified, 10 lines will be displayed by default

tr : Used to replace characters in text files. The format is "tr [original character] [target character]"

cat lovedoggood.html | tr a-z

 

hard and soft links

ln link (soft link, hard link)

The file storage structure is divided into three parts: file name, file node, file content

The default is a hard link:

Added a file name to the file node

When the file is deleted, the file first deletes the file name, and then continues to delete the file node (it will detect whether the node has other file names, if there is, delete the end, if not, it will continue to delete)

 

soft connection

-s

A soft link is a complete file, and the content of the soft link points to another file (file name, path + full path of the name)

Delete the original file, there is no change in the soft connection, but the link becomes an invalid connection (empty connection)

When you recreate the data corresponding to the soft link, it will be automatically associated (it is still the path, name.. not related to the content stored in you). Deleting the soft link has no effect.

The most used place is to create shortcuts.

 

linux query command

which : Finds where the command (executable) is located, finds and displays the absolute path of the given command. Use which to see if a system command exists.

 

type : Where to look for commands (executables), including command aliases.

alias command is used for aliasing

unalias unalias

For example, the default ls command of the system is not actually a real ls command, but an alias ls --color=auto.

This alias is set by the system for us by default.

-a : the type command can find all, including aliases

The difference between type and which is that type lists all commands, while which just lists all real commands. There is only one real ls command, which is /bin/ls

 

whereis : The command is used to search for program names, only binary files (parameter -b) and man description files (parameter -m). If the parameter is omitted, all information is returned

It can be seen that whereis is mainly aimed at the executable files under bin and sbin, as well as the man files under /usr/share/man. So fast. .

 

locate : Simple to use, just enter the file name directly behind, and you can get the result

-i : ignore case

-c : do not output the search results, only count the number of files found

-l : Only output the specified lines, eg: -l 5, that is to output five lines

-r : can be followed by a regular

The data that locate is looking for is found by the data in the established database /var/lib/locatedb, so it will be faster without going directly to the hard disk to check the data. The limitation of locate is that the query results are searched by the database, and the database is executed once a day by default, so when you create a new file, search for the file before the database is updated, then you can't find it. At this time, the database needs to be updated.

sudo updatedb

 

find : Used to find files according to specified conditions. Format: "find [Search path] [Search method] [Search condition]"

-name match name, default is exact match

-size matches file size

-mtime -n +n : The time to match the modified content, (-n means within n days, +n means before n days)

-atime -n +n : The time to match the access content, (-n refers to within n days, +n refers to n days ago)

-ctime -n +n : Match the time to modify file attributes, (-n means within n days, +n means before n days)

 

grep : Used to perform keyword searches in text. and display matching results. Format: grep [options] [files]

-c : show only the number of lines found

-i : ignore case

-n : display line numbers

-v : Inverse selection. . ---- list lines without, "keyword"

 

pipeline

Vertical bar instruction: Convert the output of one command into the input of another command.

 

echo : Used to output the value of a string or variable at the terminal. .

 

wc : used to count the number of lines, words, and bytes of the specified text. Format "wc [parameter] text"

-l : only display the number of lines

-w : only display word count

-c : only display the number of bytes

 

redirect

Standard input redirection: input from the keyboard by default, can also be input from other files or commands

Standard output redirection: default output to screen

Error output redirection: default output to screen

Input redirection:

command < file takes a file as standard input to the command

output redirection

Command > file redirects standard output to a file (clears the data from the original file)

Command 2> file redirects the error output to a file (clears the data of the original file)

command >> file redirects standard output to a file (appends the original content)

Command 2 >> file redirects error output to a file (appends the original content)

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325682925&siteId=291194637