Linux command--2

Source: Internet
Author: User

1 mkdir Command

The mkdir command is used to create a directory of the specified name, requiring the user who created the directory to have write permissions in the current directory, and the specified directory name cannot be a directory that is already in the current directory.

(1) command format

mkdir [Options] Directory

(2) Common parameters

Parameters Description
-M--mode= mode Set Permissions < modes >
-P--parents Can be a path name. If some directories in the path do not already exist, and with this option, the system will automatically set up those directories that do not yet exist, that is, multiple directories can be established at one time
-V--verbose Displays information each time a new catalog is created
2 RM Command

The function of this command is to delete one or more files or directories in a directory, and it can delete all files and subdirectories under a directory. For linked files, only the links are deleted and the original files remain unchanged.

RM is a dangerous command, especially when used, especially for novices, or the entire system will be destroyed in this command (e.g., RM *-rf under/(root directory)). So, before we execute RM, it's a good idea to check in which directory, exactly what to delete, and keep a high level of sanity in the operation.

(1) command format

RM [Options] File or directory

(2) Common parameters

Parameters Description
-F--force Ignore non-existent files, never give hints
-I.--interactive For interactive deletion
-R--recursive Instructs RM to recursively delete all directories and subdirectories listed in the parameter
-V--verbose Detailed display of the steps performed
3 MV Command

The MV command function is used to move files or change filenames, often used to back up files or directories.

The MV command determines whether to rename the file or move it to a new directory, depending on the second parameter type, which is the target file or the destination directory. When the second parameter type is a file, the MV command completes the file rename, at which point the source file can only have one (or the source directory name), which renames the given source file or directory to the specified destination file name. When the second parameter is a directory name that already exists, the source file or directory parameter can have more than one, and the MV command moves the source files specified by each parameter to the destination directory.

(1) command format

MV [option] source file or directory destination file or directory

(2) Common parameters

Parameters Description
-B--back Overwrite pre-backup if file overwrite is required
-F--force If the destination file already exists, it will not be queried and overwritten directly
-I.--interactive If the target file already exists, you will be asked if you want to overwrite
-U--update Update if the destination file already exists and the source file is newer
-T--target

This option is useful when moving multiple source files to a directory, where the destination directory is before the source file

4 CP Command

The CP command is used to copy files or directories. In general, the shell sets an alias, and when the file is copied at the command line, if the destination file already exists, it asks whether to overwrite it, regardless of whether you use the-i parameter. However, if you execute the CP in a shell script, you do not ask for overrides if you do not have the-i parameter. This means that the command line and shell scripts perform somewhat differently.

(1) command format

CP [Options] source file directory

CP [option]-T directory source file

(2) Common parameters

Parameters Description
-T--target-directory Specify Destination Directory
-I.--interactive Ask before overwriting (invalidates the previous-n option)
-N--no-clobber Do not overwrite existing files (invalidate the previous-i option)
-S--symbolic-link Create a symbolic link to a source file, not a copy of a file
-F--force Forcibly copying a file or directory, regardless of whether the destination file or directory already exists
-U--update After using this parameter, the file will only be copied if the source file is modified at a later time than the destination file, or if the corresponding destination file does not exist.
5 Cat Commands

The function of the cat command is to output a file or standard input combination to the standard output. This command is commonly used to display the contents of a file, or to connect several files to display, or to read from a standard input and display it, often in conjunction with redirection symbols.

(1) command format

Cat [Options] [file]

(2) Common parameters

Parameters Description
-A--show-all Equivalent to-vet
-B--number-nonblank Number of non-null output lines
-E Equivalent to-ve
-E--show-ends Show $ at end of each line
-N--number Numbering all the lines of the output, numbering the number of rows for all outputs starting from 1
-S--squeeze-blank Blank line with more than two lines in a row
-T Equivalent to-VT
-T--show-tabs Display the ^i character as a
-U (ignored)
-V--show-nonprinting Use ^ and M-references, except LFD and TAB
6 NL command

The NL command is used in a Linux system to calculate the line number of a file. NL can automatically add a line number to the output file content. The default result is a bit different from Cat-n, NL can make the line number more display design, including the number of digits and whether auto-completion 0 and so on.

(1) command format

NL [Options] [file]

(2) Common parameters

Parameters Description
-B There are two main ways to specify the line number:
-B A Indicates that the line number (similar to cat-n) is also listed, whether or not it is a blank line
-B T If there is a blank line, do not list the line number in the empty row (default value)
-N There are three main ways to represent a travel number:
-N Ln The line number is displayed on the left side of the screen
-N RN The line number is displayed on the very right of its own field and does not add 0
-N RZ The line number is displayed on the very right of its own field, plus 0
-W Number of digits occupied by the line number field

Finally there is a command that is not in Linux----tree

Feature Description: Lists the contents of the catalog in a tree view.

installation command:

sudo apt-get update

sudo apt-get install tree

So install the tree command, and let's see how to use it.

First create a folder recursively

MKDIR-VP Shi/{bin/,lib/,doc/{inf,pro}}

This creates three subordinate folder Bin,lib,doc, where the doc folder is also recursively created by the INF and Pro

And then enter

Tree shi/

Linux command--2

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.