Linux Learning notes four ———— Common Linux commands (to be added)

Source: Internet
Author: User

I. Linux commands--file, Disk Management

1. File Management

<1> view file information: ls

LS is the abbreviation of the English word list, its function is to list the contents of the directory, is one of the most commonly used commands, it is similar to the dir command under DOS.

Linux文件或者目录名称最长可以有265个字符,“.”代表当前目录,“..”代表上一级目录,以“.”开头的文件为隐藏文件,需要用 -a 参数才能显示。

LS Common parameters:

Parameters meaning
-A Displays all subdirectories and files in the specified directory, including hidden files
-L Display file details in a list
-H Display file size in a humane way with-l

The information listed in the figure has the following meanings:

Similar to file operations under DOS, in the Unix/linux system, it is also possible to use special characters to refer to multiple filenames simultaneously, which are called wildcards.

wildcard characters meaning
* File represents all characters in the file name
LS te* Find files that start with Te
LS *html Finding files that end in HTML
Represents any character in a file name
Ls?. C Find only the first character, any file with a. c suffix
LS A.? Only 3 characters are found, the first 2 characters are a., the last character arbitrary file
[] [and] Enclose character groups to indicate that any of the character groups can be matched. "-" is used to represent the range of characters.
[ABC] Match any of A, B, c
[A-f] Match any one of the characters from a to F range
LS [a-f]* Find files that begin with any one of the characters from a to F range
LS a-f Find files with file name a-f when "-" loses wildcard characters outside square brackets
\ If you want to use wildcards as normal characters, you can precede them with escape characters. “?” and "*" in square brackets without the use of escape characters to lose the role of a wildcard character.
LS \*a Find files with file name *a

<2> Output Redirection Command:>

Linux allows the command execution results to be redirected to a file that should be displayed on the terminal and saved to the specified file.

such as: ls > test.txt (test.txt If not present, created, existing overwrite its contents)

Attention:>输出重定向会覆盖原来的内容,>>输出重定向则会追加到文件的尾部。

<3> split screen display: more

When viewing content, when the information is too long can not be displayed on a screen, the rapid scrolling screen, so that users cannot see the contents of the file, you can use the more command, only one page at a time, press the SPACEBAR to display the next page, press the Q key to exit the display, press the H key to get help.

<4> Pipeline: |

Pipe: The output of one command can be piped as input to another command.

Pipeline we can understand the real life of the pipe, the pipe of a plug into the other side, take out, here "| "The left and right are divided into two ends, and at the end of the thing (write), and take something (read).

<5> Clear Screen: Clear

The clear function is to clear the display on the terminal (similar to the DOS CLS Clear screen feature), or you can use the shortcut key: Ctrl + L ("L" for the letter).

<6> Switch working directory: CD

When using Unix/linux, it is often necessary to change the working directory. The CD command helps the user to switch the working directory.Linux所有的目录和文件名大小写敏感

The CD can be followed by an absolute path, or with a relative path. If you omit the directory, the default is to switch to the current user's home directory.

Command meaning
Cd Switch to the current user's home directory (/home/user directory), when the user logs in, the default directory is the user's home directory.
CD ~ Switch to the current user's home directory (/home/user directory)
Cd. Switch to current directory
Cd.. Switch to Parent directory
CD- Access to the directory where you last came

Attention:

    • If the path starts from the root path, the path is preceded by a "/", such as "/mnt", which usually goes to a folder in a directory that is not preceded by "/".

Linux Learning notes four ———— Common Linux commands (to be added)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.