A brief introduction to Linux novice commands

A brief summary of common Linux commands

Here are some of the more commonly used commands

1. ls lists the files under the current directory

This should be the most commonly used command
How to use: Enter in the current directory ls, and then click Enter to display the files in the current directory.

2. pwd View the full path of the current directory

This is also a common
method of use: enter in the current directory pwd, and then click Enter to display the full path of the current directory.

3. cd changes the current directory

This is also a very commonly used command, mainly in the following ways

3.1 cd relative directory

How to use: Enter the relative directory of cd in the current directory, and then click Enter to enter the relative directory.
For example, assume that the precondition is: input pwd, the path of the current directory is displayed as /root, and the input lsshows that there is a folder home, then, input cd home, and then press Enter, you can reach the directory /root/home.

3.2 cd … Return to the previous directory

How to use: Enter in the current directory cd .., and then click Enter to return to the previous directory.

3.3 cd absolute path

How to use: Regardless of the current directory, enter the absolute path of cd to jump to this path.
For example, suppose I am in the /user directory now, enter cd /root, and press Enter, I can jump to the /root directory.

4. man provides help and explanations for commands you are familiar with or unfamiliar with

How to use: Enter the command that needs help in man in the current directory, and press Enter to display the detailed usage of the command.
For example, enter in the current directory man lsand press Enter to view the usage of ls

5. Touch to create a new file

How to use: Enter the touch file name in the current directory, and press Enter to create a file in the current directory.
For example, if I enter touch file.txtand press Enter, a file named file.txt will be created in the current directory, and the content of the file is empty.

6. cp copy files

How to use: Enter cp file name 1 file name 2 in the current directory, and press Enter to copy file 1 to file 2. (The premise is that file 1 is in the current directory.)
For example, suppose I have a file named file.txt in my current directory, enter it cp file.txt file2.txt, and then press Enter, and a file named file2.txt will appear in the current directory. File The content is the same as file.txt.

7. mkdir creates a folder

How to use: Enter in the current directory mkdir home, then press Enter, and a new folder named home will be created in the current directory.

8. find find files

There are many usages of this command. You can go to Baidu for detailed usage. I only select a few of the most commonly used usages to introduce to you.
Example:

  • List all files with extension c in the current directory and its subdirectories
find . -name "*.c"

If it is executed in the root directory, the function is to find out all the files with the .c suffix in the machine

  • Global fuzzy search for files with aaa in the file name
find / -name *aaa*
  • List all files updated in the last 20 days under the current directory and its subdirectories
 find . -ctime -20

9. Clean up memory

How to use: enter the command

echo 1 > /proc/sys/vm/drop_caches

You can clean up the memory.

Example:

  • First check the current system memory usage
free -m

before cleaning

  • Then execute the clear memory command
echo 1 > /proc/sys/vm/drop_caches

cleaning up

  • Then check the memory usage after cleaning
free -m

after cleaning

So much for the time being, if there are other commonly used basic commands, welcome to summarize in the comment area below

Guess you like

Origin blog.csdn.net/qq_43287658/article/details/103743985