Linux [Linux from scratch to learn the basic commands common && file wildcard]

Operating environment:

Linux distributions: ubuntu-18.04.4-desktop-amd64
virtual machine software: VirtualBox-6.1.4-136177-Win

Linux commonly used basic commands

The following commands are run efficiently on a Linux terminal (terminal).

pwd Displays the current path

cd nameEnters from the current path to the directory name
cd /name1/name2/name3into the current path from the name1 / name2 / name3 directory (hereinafter, may continue to write, with / division continues into subdirectories, of course, provided that the directory exists)
cd ..to return to the top-level directory
cd /returns to the root directory

lsA list of all files (not including hidden files that do not include at all. Files that begin with)
ls -aa list of all files, hidden files and displays the
ls -ldetailed list (default lexicographical sorted by file name)

ls -FDisplay a list of file names at the end of mark (Flag)
If the directory is listed, decorated with a slash on the back of name /
If the executable file is listed, it is decorated with an asterisk after their name *
If the list is symbolic link file, just behind the name decorated with the symbol @
is a regular file if listed, the name behind without any mark

ls -l -r(Or short ls -lr) detailed list, -r represents reverse sequence
ls -l -t(short or ls -ltdetailed list), expressed as a time-ordered -t (forward late time)
ls -l -t -r(or short ls -ltr) detailed list, in reverse time-ordered outputs (time As early as the front).
Command options written in a different order, it does not matter, the function is the same, for example, -ltr -lrt -trlare inverted output (earlier the front) after sorting by time.

treeTree list, to reflect the hierarchical relationship (if not, then follow the prompts to install a prompt should be sudo apt install tree, this can be installed using the input)

cat 1.txtShows the contents of a text file 1.txt the terminal.
cat -n 1.txt1.txt shows the contents of the text file in the terminal, -n denotes a display number of each row.
cat > 1.txtAcquiring data from the standard input (keyboard), until the key press ctrl + d flag input end. Enter the contents into 1.txt. Note that this will overwrite the original written content.
cat >> 1.txt Add content 1.txt, will retain the original content.
cat 1.txt 2.txtThe two files sequentially output
cat 1.txt 2.txt > 3.txtthe contents of two files redirected to 3.txt so that the contents of the first two 3.txt contents of files and

> nameCreate a file name for the name, you can suffix, such as name.txt (here is greater than the number> is represented create)
mkdir nameCreate a directory called name of

rm nameDelete the name of the file name
rm -r nameto delete the name of the directory name (be sure to add -r, otherwise it can not be deleted)
rmdir namedelete the name of the directory name (the same effect rm -r name)

Then some useless commands
hostnameto view linux computer name
whoamito view the current user
dfhardware information View System

Dubbing with the shortcut key to paste the terminal to add the Shift:
Ctrl + the Shift + c to copy to the clipboard
Ctrl + Shift + v to paste the clipboard contents

File wildcard

Wildcards for pattern matching, such as file names match, passing the name of the search, string search and so on. There are common wildcard *, ?, [].
The user may be included in a file name as a command parameter of these wildcard, constitute a so-called "pattern string", pattern matching in the implementation process.

An asterisk *
match the file name string of any length (including the empty string).

Question mark?
Matches any single character.

Square brackets []
characters representative of the specified range, as long as the file name [] within the character at the position specified in [] in the range, then the file name string matches the pattern.
Character range in square brackets can be given directly by the character of the composition, it may be represented by a starting character defined range, and the intermediate termination character hyphen (-) Composition.
For example, [AD] the same effect [ABCD], have expressed match a, b, c, d of any one character.

Non-wildcard special characters:

The dot character.
When the first character as a file name or path name of the component, must be explicitly matched.

Backslash \
is a special character. It shields the special meaning of the subsequent special letters (turn back), whichever is the only character that the literal meaning of the symbol represents.

How to match? What is explicit match? A few examples:

*fileExpressed in any string ending the file, and can match the file makefile, but does not match .profile file (file names. Begin with, you need to. Play out, explicit match)

f*Matches any string that begins with f. It should be noted that the dot (.) And slashes in the path name (/) before the file name must be explicitly match. For example, *can not match .file, .*you can match .file.

t*cMatching try1.c try.c try.basic. Description *can match the middle .of the file, but *can not match is the beginning .of the file.

Published 100 original articles · won praise 131 · views 50000 +

Guess you like

Origin blog.csdn.net/ljw_study_in_CSDN/article/details/104741798