V. Accumulated Linux/UNIX operation commands (cp, mv, cat, grep, and ps]

Source: Internet
Author: User

V. Accumulated Linux/UNIX operation commands (cp, mv, cat, grep, and ps]

In Linux/UNIX, users often use the text interface to set the system or operating system. The author is constantly in touch with this command during his work, therefore, this article has been specially developed, prepared, and started. This article mainly records some of the operating commands you encounter in Linux/UNIX at ordinary times, record and sort them out, one can deepen your impression, and the other can be recorded and shared. We hope that you will give instructions and explanations on inappropriate or ambiguous aspects so that you can learn and improve them together.
[For more information, see http://blog.csdn.net/mahoking]

017 Linux cp command


1 Command Format
Cp [option] [file or directory] format cp [option] [file or dir]
2. command functions
The cp command is used to copy files or directories. For example, if you specify more than two files or directories at the same time, and the final destination is an existing Directory, then it copies all the previously specified files or directories to this directory.
3 common examples
Example 01

Command: cp fileName dirName
Input: [root @ localhost root] # cp file.txt./fileDir
Note: copy the file.txt file under the current directory to the fileDir directory under the current directory.
Example 02
Command: cp fileName1 fileName2 dirName
Input: [root @ localhost root] # cp file1.txt file2.txt./fileDir
Note: copy the two file1.txt1_file2.txt files in the current directory to the fileDir directory.
Example 03
Command: cp fileNames dirName
Input: [root @ localhost root] # cp *. txt./fileDir
Note: copy the full. txt file under the current directory to the fileDir directory under the current directory.


018 Linux mv command


1 Command Format
Mv [option] [file or directory] format mv [option] [file or dir]
2. command functions
The mv command is used to move files or rename files. It is a common command in Linux and is often used to back up files or directories.
3 common examples
Example 01

Command: mv fileName newFileName
Input: [root @ localhost root] # mv file.txt file. log
Note: change the name of the file.txt file in the current directory to file. log.
Example 02
Command: mv fileName dirName
Input: [root @ localhost root] # mv file. log./fileDir
Note: Move the file. log file in the current directory to the fileDir directory in the current directory.

019 Linux cat command


1 Command Format
Cat [option] [file or directory] format cat [option] [file or dir]
2. command functions
Cat command
(1) display the entire file at a time. $ Cat filename
(2) create a file from the keyboard. $ Cat> filename can only create new files and cannot edit existing files.
(3) Merge several files into one file: $ cat file1 file2> file
3 common examples
Example 01

Command: cat fileName
Input: [root @ localhost root] # cat file.txt
Description: displays all the contents of the file.txt file in the current directory.
Example 02
Command: cat fileName1 fileName2> fileName3
Input: [root @ localhost root] # cat file. log file.txt file.all.txt
Note: Merge the file.logand file.txt files in the current directory into the file.all.txt file.

020 Linux grep command


1 Command Format
Grep [option] format grep [option]
2. command functions
The grep command is a powerful text search tool that uses regular expressions to search for text and print Matching lines. Grep stands for Global Regular Expression Print, which indicates the Global Regular Expression version. Its permission is granted to all users.

3 common examples
Example 01

Command: grep string fileName
Input: [root @ localhost root] # grep 'test' file. log
Note:
The row that contains the test text in the file. log file.
Example 02
Command: grep-n string fileName
Input: [root @ localhost root] # grep-n 'test' file. log
Note:
The row that contains the test text in the file. log file.
-N: displays the row number of the text information to be searched.

021 Linux ps command


1 Command Format
Ps [option] format ps [option]
2. command functions
Ps command is one of the most basic commands used to view processes running on the system. It provides the current process, such as user ID, CPU usage, memory usage, and command name. It does not display real-time data, such as the top or htop command details. However, even if the functions and outputs are simple, it is still a mandatory process management/monitoring tool.

3 common examples
Example 01

Command: ps-ef
Input:
[Root @ localhost root] # ps-ef
Note:
List all processes.
-E: display all processes
-F full-format display

[For more information, see http://blog.csdn.net/mahoking]

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.