[Linux] Common instructions (2)

Table of contents

1.man command (important)

2.cp command (important)

3.mv command (important)

4.cat command

5.more command

6.less directive (important)


1.man command (important)

Linux commands have many parameters, and it is impossible for us to remember them all. We can get help by checking the online manual. The command to access the Linux man page is man

grammar:man [options] command

Common options:

  • -k Search online help based on keywords
  • num is only found in chapter num
  • -a displays all chapters, such as man printf. By default, it starts searching from the first chapter and stops when it is known. Use the a option. When pressing q to exit, it will continue to search until all chapters are searched. .

To explain, the man manual is divided into 8 chapters.
1) Executable program or shell command.
2) System calls (functions provided by the kernel).
3) Library functions (functions in the program library).
4) Special files (usually found in /dev).
5) File format and convention, such as /etc/passwd.
6) Games.
7) Miscellaneous.
8) System management commands (usually limited to root users).


2.cp command (important)

In Windows, we can use Ctrl+C and Ctrl+V to copy a file or directory from one place to another. If we want to complete this operation in Linux, we must use the cp command.

grammar:cp [option] source file or directory target file or directory
Function:Copy a file or directory
illustrate:The cp command is used to copy files or directories. If two or more files or directories are specified at the same time, and the final destination is an existing directory, it will copy all previously specified files or directories to this directory. If multiple files or directories are specified at the same time, and the final destination is not an existing directory, an error message will appear.

 

 

Common options:

1) -f or –force forcefully copies a file or directory, regardless of whether the destination file or directory already exists.


2) -i or –interactive asks the user before overwriting the file


3) -r or -R recursively processes files and subdirectories in the specified directory together. If the form of the source file or directory does not belong to a directory or symbolic link, it will be treated as an ordinary file.

 Tips:When you need to copy all the contents of the current directory, you can use wildcards to copy.

 


3.mv command (important)

The mv command is the abbreviation of move. It can be used to move files or rename files (move (rename) files). It is a commonly used command in Linux systems and is often used to back up files or directories.


grammar:mv [options] source file or directory target file or directory

 Function:
1.) Depending on the type of the second parameter in the mv command (whether it is a target file or a target directory), the mv command renames the file or moves it to a new directory.

2.) When the second parameter type is a file, the mv command completes the file renaming. At this time, there can only be one source file (it can also be the source directory name). It will rename the given source file or directory as The given destination file name.


3.) When the second parameter is an existing directory name, the source file or directory parameterThere can be multiple, the mv command moves all the source files specified by each parameter to the target directory.

Common options:

1.) -f: force means force. If the target file already exists, it will be overwritten directly without asking.


2.) -i: If the destination file (destination) already exists, it will ask whether to overwrite it!

 

 


4.cat command

In Linux, you cannot use the mouse to click on a file to read like Windows. If you want to read the file, you can use the cat command.

grammar:cat [options][file]
Function:View the contents of the target file

Common options:

1.) -b numbers non-empty output lines
2.) -n numbers all lines of output
3.) -s does not output multiple blank lines

Notice:The cat command will print all the contents of the target file to the screen. If the content of the target file is too large, it will cause the screen to refresh (until the entire file content is printed on the screen). Therefore, the cat command is generally only suitable for viewing files with small content.


5.more command

If you want to view a large number of information files, you can use the more command.

grammar:more [options][file]
Function:more command, function is similar to cat

 

 Notice:The more command can only scroll down by pressing the Enter key, but cannot scroll up. The more command will load the entire file before viewing.


6.less directive (important)

The less tool is also a tool for paging display of files or other output. It should be said that it is an orthodox tool for viewing file contents in Linux and is extremely powerful.
The usage of less is more flexible than that of more. When using more, we have no way to turn forward and can only look back. But when using less, we can use the [pageup][pagedown] and other key functions to flip back and forth through the file, which is easier to use for viewing. The contents of a file!
In addition, you can have more search functions in less, not only you can search down, but you can also search up.

grammar:less options file
Function:It has both the function of viewing the contents of the target file and the search function.

 

 

Notice:The less command can turn up and down by pressing the up and down keys, and the less command will not load the entire file before viewing.

Common options:
1) -i ignores case when searching.
2) -N displays the line number of each line.
3)/String function to search down “string”.
4)?String function to search upward for “string”.
5) n Repeat the previous search (related to/or ?).
6) N Repeat the previous search in reverse (related to/or ?).

Related Posts

69.Qt implements two-way authentication between Https ssl certificate and intranet server IP

POST and GET request methods for Postman interface testing

Docker learning: start the container and mount the directory

Step-by-step tutorial on writing automated installation scripts for Oracle11g under Linux

VMware virtual machine installs the original MAC OS system and easily experiences the Apple operating system

Detailed explanation of HAProxy restart mechanism

gateway solves cross-domain problems, and has been solved by personal testing

Metasploitable-linux-2.0.0 target machine download and configuration tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*