Linux file Management related commands detailed

Source: Internet
Author: User
Tags touch command uppercase letter

1, file wildcard character, can refer to "Man 7 glob" content;

(1) Common wildcard characters:

*: Indicates a match of 0 or more characters

?: Represents any single character

~: Indicates the current user home directory

~username: Represents a user's home directory

^: means to take the reverse

[]: Represents any single character within the specified range

[0-9]: Indicates matching a range of numbers

[A-Z]: matches all letters that do not contain Z

[A-z]: matches all letters that do not contain a

[:d igit:]: Indicates any number

[: Lower:]: denotes any lowercase letter

[: Upper:]: denotes any uppercase letter

[: Alpha:]: denotes any uppercase or lowercase letter

[: Alnum:]: Denotes any number or letter

[: Space:]: Indicates a space

[: Blank:]: Indicates a blank line

[:p UNCT:]: Denotes any punctuation

(2) Examples of use:

A. Show all files or directories with the L-letter beginning with a lowercase letter and at least one digit in the middle of the/var directory

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/85/21/wKiom1eas23ANc9-AAAWQSB0yDE479.png "title=" 1.png " alt= "Wkiom1eas23anc9-aaawqsb0yde479.png"/>

B. Displays files or directories that start with any digit in the/etc directory and end with a non-numeric

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/85/21/wKioL1eat3Tw66WEAAA7CimuvTs844.png "title=" 2.png " alt= "Wkiol1eat3tw66weaaa7cimuvts844.png"/>

C, display all the. conf in the/etc directory, and the file or directory beginning with m,n,r,p

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/85/22/wKiom1eayKqC4F6eAAAXcfm4BkA847.png "title=" 3.png " alt= "Wkiom1eaykqc4f6eaaaxcfm4bka847.png"/>


2. Stat command

This command can view the meta-attributes of a file

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/85/23/wKioL1ea03Cz-jhhAABBk-WtpCk750.png "title=" 4.png " alt= "Wkiol1ea03cz-jhhaabbk-wtpck750.png"/>

which

Access: Time, also known as Atime, when reading the contents of a file

Modify: Modify time, also known as Mtime, modify the file data content time

Change: Changing the time, also known as CTime, to modify the file attribute information time


3. Touch command

Usage: Touch [options] ... File...

Common options:

-A: If the file exists, change the atime time and the CTime time will change.

-C: Do not create any files, update all time if the file exists

-M: If the file exists, change the mtime time, and the CTime time will change.

-T: Specifies the time attribute to create the file, specifying the time format: [[[CC]YY]MMDDHHMM[.SS]


4. mkdir command

Usage: mkdir [options] ... Directory...

Common options:

-V: Displays information each time a new directory is created

-P: Creates the upper-level directory of the target directory when needed, but is not treated as an error treatment even if these directories exist (equivalent to recursive creation)


Practice:

(1) How to create dir1/x, dir1/y,/dir1/x/a,/dir1/x/b,/dir1/y/a,/dir1/y/b directory

# MKDIR-PV Dir1/{x/{a,b},y/{a,b}} or # MKDIR-PV dir1/{x/{a,b},y/{a,b}}

(2) How to create/dir2/x,/dir2/y,/dir2/x/a,/dir2/x/b directory

# MKDIR-PV Dir2/{x{a,b},y}

(3) How to create/DIR3,/DIR4,/DIR5,/DIR5/DIR6,/dir5/dir7 directory

# MKDIR-PV dir{3,4,5/dir{6,7}}


5. RmDir command

Only empty directories can be deleted

Usage: rmdir [options] ... Directory...

Common options:

-V: Output processing directory details

-P: Delete the specified directory and its parent folder (equivalent to recursive delete)


6. CP Command

Usage: CP [options] ... [-t] source file destination file
OR: CP [options] ... Source file ... Directory
OR: CP [options] ...-t directory source files ...

(1) If the copied source is a file, the target is also a file, and the destination file does not exist, then create a file named after the target file, and the contents of the original file is populated into the new file (equivalent to copy and rename)

(2) If the source of the copy is a file, the target is also a file, and the destination file already exists, overwrite the target file (equivalent to overwrite)

(3) If you copy a single file to a directory, and the target directory exists in the same directory as the source file name, it will be copied directly to the same name as the same directory

(4) If you copy multiple files to a nonexistent file, you will get an error (the target must be a directory when the source is multiple files)

(5) If you copy a directory to a nonexistent file, it will create a directory with a nonexistent file name, and copy the contents of the source directory to the new destination directory (also the equivalent of copy and rename, copy the directory must be followed by the-R option)

(6) If you copy a directory to another directory and there is a file in the destination directory with the same name as the source directory, an error will be

Common Options Description:

-A: Archive, equivalent to-dr--preserve=all, which preserves all the properties of the source file

-D: Equals--no-dereference--preserve=links, does not copy source files, copy only linked files

-F: If the destination file already exists, remove it and try again

-I: Ask before overwriting

-N: Do not overwrite existing files

If I,-n are set at the same time, only the last one takes effect.

-P: equivalent to--preserve=mode,ownership,timestamps

--preserve[=attr_list]

MORE: Permissions

Ownership: Belong to the main group

Timestamps: Time stamp

Context: Environment

Links: Link

All: Above all properties

-r-r: Recursively copy all content within a directory and its subdirectories

-V: Display procedure

Practice:

(1) Define alias command baketc, the implementation of the/etc/directory to backup all files to/testdir separate subdirectories, and requires a subdirectory format of BACKUPYYYY-MM-DD, the backup process is required to be visible

# alias baketc= ' cp-va/etc/testdir/backup ' date +%f '

(2) Create/testdir/rootdir directory and copy all files under/root to this directory, and ask to retain the original permissions

# cp-r--preserve=mode/root//testdir/rootdir


7. MV Command

Rename the source file to the destination file, or move the source file to the specified directory.

Usage: MV [options] ... [-t] source file destination file
Or: MV [options] ... Source file ... Directory
Or: MV [options] ...-t directory source files ...

Common options:

-F: Force move

-I: Ask before overwriting

-N: Do not overwrite existing files

If multiple in-I,-F,-n is specified, only the last one takes effect.

-V: Detailed display of the steps performed


8. RM command

Usage: RM [options] ... File...

Common options:

-F: Force delete. Ignore files that do not exist, do not prompt for confirmation

-I: Need to confirm before deleting

-r-r: Recursively delete a directory and its contents

-V: Detailed display of the steps performed


9. Tree command

-D: Show only directories

-L Level: Specifies the number of levels to display

-P Pattern: Displays only paths that are matched by the specified pattern

This article is from the "Linux Operational Learning path" blog, please be sure to keep this source http://fengliang.blog.51cto.com/3453935/1831773

Linux file Management related commands detailed

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.