Linux Learning Notes (10)--Command Learning (file creation)

Source: Internet
Author: User

Linux File Creation command

We often have to create some documents to add content or to create a file directory to organize the file collation, so we need to get familiar with the command created, the Linux file Creation command basically has the following:


mkdir rmdir touch rm CP Move command:

Note: Before we learn to use the Create command, the first thing to know is that the file naming requirements in Linux

1, the file name is similar to the length of windows, up to 256 characters (it is recommended to be as short as possible)

2, in addition to the \ symbol, everything else can be used as a file name, which is more than the width of Windows (we recommend that you do not use special characters to do file names)

3, the case is extremely sensitive.

4, avoid using-+ and so on as the first character of the file name, causing unnecessary trouble (such as. is to indicate hidden files)

Lab Environment: Create several folders and files first (same as previous chapter structure)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/29/wKioL1Q3dHaQQgpvAADZIv5nfLY233.jpg "title=" Qq20141010134914.png "alt=" Wkiol1q3dhaqqgpvaadziv5nfly233.jpg "/>

Command mkdir (make directory abbreviation for English)
Function Create a Directory
Grammar mkdir Directory Name
Extended

mkdir filename >> Creating a directory

mkdir filename1 filename >> connection Create two directories in one place

Mkdir-p filename/filename/filename >> Creating a tree Directory

Mkdir-m file permissions filename >> can set arbitrary file permissions

Instance

1, mkdir Blog (create a folder named blog , the default permissions)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/29/wKioL1Q3dkCjrAyrAALihzIEUew325.jpg "title=" 2.png " alt= "Wkiol1q3dkcjrayraalihzieuew325.jpg"/>

2. mkdir Hz NET Home (create Hz Net home three folders)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/27/wKiom1Q3egyTirP4AAEh5FiN4V8933.jpg "title=" 3.png " alt= "Wkiom1q3egytirp4aaeh5fin4v8933.jpg"/>

3, Mkdir-p hznethome/hz/net/home (Create Tree folder, Hznethome contains Hz,hz contains home in net,net)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/29/wKioL1Q3ezaBDsaEAAIsIPabE2A128.jpg "title=" 4.png " alt= "Wkiol1q3ezabdsaeaaisipabe2a128.jpg"/>

4. MKDIR-M 777 Test

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/28/wKiom1Q3e9nyz7UzAANb4AUYdq8091.jpg "title=" 5.png " alt= "Wkiom1q3e9nyz7uzaanb4auydq8091.jpg"/>

Command RmDir (remove directory abbreviation)
Function Delete a folder
Grammar RmDir Directory name (note: blank)
extension

rmdir filename   >>> delete filename directory

rmdir-p filename/filename/filename >>> Delete nested folders (empty)

rmdir filenam filename filename    >>>> Delete several same-location folders

instance

1, rmdir Test (delete folder named Test)

650) this.width=650; "src=" http:/ S3.51cto.com/wyfs02/m01/4c/28/wkiom1q3gzeg_lsbaafilcjclpy156.jpg "title=" 6.png "alt=" Wkiom1q3gzeg_ Lsbaafilcjclpy156.jpg "/>

650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/4C/28/ Wkiom1q3gwfslw16aagifjflgy4949.jpg "title=" 7.png "alt=" wkiom1q3gwfslw16aagifjflgy4949.jpg "/>

Span style= "font-size:20px;" >2, rmdir-p hznethome/hz/net/home (delete hznethome, Hz, NET, home several folders, but only if: these folders are empty)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/29/wKiom1Q3ivOymAgVAAGQuVTKfhc840.jpg "title=" 8.png "alt=" wkiom1q3ivoymagvaagquvtkfhc840.jpg "/>

Command Touch
Function Create Document & Modify document display time
Grammar Touch filename. suffix name
Extended

Touch filename

touch filename filename filename >> Create several documents at the same time

touch-d "date" filename >> updated document modification date

Touch-t "Time" filename >> updated document modification time

Instance

1. Touch Test.txt (Test create Test.txt document)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/2A/wKiom1Q3nITTor4ZAADOPqVX7vY707.jpg "title=" 9.png " alt= "Wkiom1q3nittor4zaadopqvx7vy707.jpg"/>

2. Touch Hz.txt net.txt home.jpg (create several documents at the same time)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2C/wKioL1Q3nRuTIN2JAAENnHdjAR4991.jpg "title=" 10.png "alt=" Wkiol1q3nrutin2jaaennhdjar4991.jpg "/>

3, tuocn-d "2 days Ago" Hz.txt (modified two day ago)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2A/wKiom1Q3ndrD0fx4AAGLNTJRb3k038.jpg "title=" 11.png "alt=" Wkiom1q3ndrd0fx4aaglntjrb3k038.jpg "/>

Note: Two days ago the second to use Arabic numerals, English is not possible, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2A/wKiom1Q3n2TAoR68AAG1Dw4YZwI966.jpg "title=" 12.png "alt=" Wkiom1q3n2taor68aag1dw4yzwi966.jpg "/>

4, touch-t "YYMMDDHHMM" Net.txt (Modified time)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2A/wKiom1Q3oMHx9UrBAAMrf9uljtA519.jpg "title=" 13.png "alt=" Wkiom1q3omhx9urbaamrf9uljta519.jpg "/>


Command RM (remove abbreviation for English)
Function Delete Directory
Grammar RM Directory Name
Extended

rm-f filename >>f (force) Mandatory Delete, no hint (same as shift+delete in Windows

Rm-i file >> Interactive Delete, will ask you if you really want to delete

Rm-r file >> Recursive Delete, will be a series of direct deletion

Instance

1, rm-f hz.txt >> Direct Delete, do not need prompt

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2A/wKiom1Q3pALQr-3wAAEHZ18xyr8828.jpg "title=" 14.png "alt=" Wkiom1q3palqr-3waaehz18xyr8828.jpg "/>

2. rm-i net.txt >> Delete net.txt files, but there will be hints

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/2A/wKiom1Q3pRugOjsLAAJVqB2fapE973.jpg "title=" 15.png "alt=" Wkiom1q3prugojslaajvqb2fape973.jpg "/>

3. RM filename filename filename To delete the listed file or document directly.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/2B/wKiom1Q3pk3yitALAADhYPpAYe0017.jpg "title=" 16.png "alt=" Wkiom1q3pk3yitalaadhyppaye0017.jpg "/>

4, rm-r hznethome/hz/net/home >> Delete a bunch of files, and the folder contains other files. (as in the home above contains hz.txt documents)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2C/wKioL1Q3qxyBr5hSAAHm0J9VGDc475.jpg "title=" 17.png "alt=" Wkiol1q3qxybr5hsaahm0j9vgdc475.jpg "/>


Command CP (copy in English abbreviation)
Function Copy a directory or document
Grammar CP [Options] [source file] [destination file]
Extended

-D: If the source file is the attribute of the link file, the link file property is copied instead of the file itself;

-F: For force, if the target file already exists and cannot be opened, then try again after removing it;

-I: If the target file (destination) is already present, it will be asked to make the action (common)-l: Create the link file of the hard link, rather than copying the file itself;

-P: Copy the past along with the properties of the file, rather than using the default properties (backup is often used);

-R: Recursive continuous replication, used for the replication behavior of the directory; (Common)

-S: Copy becomes the symbolic link file (symbolic link), i.e. "shortcut" files;
-U: Upgrade destination If destination is older than source!
Finally, note that if the source file has more than two, then the last destination file must be "directory"!

Instance

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2D/wKiom1Q331LA52RqAADiTvtg9o0232.jpg "title=" 18.png "Width=" 622 "height=" 221 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:622px;height:221px; "alt=" Wkiom1q331la52rqaaditvtg9o0232.jpg "/>

1, CP hznethome.txt./hz >> Copy the Hznethome.txt file into the Hz folder

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/2E/wKioL1Q34FOBbQUQAAGpP-A7l-s334.jpg "title=" 19.png "Width=" 622 "height=" 147 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:622PX;HEIGHT:147PX; "alt=" Wkiol1q34fobbquqaagpp-a7l-s334.jpg "/>

Duplicate Cp-i hznethome.txt./hz (Note: It will be prompted to ask for your comments, whether to overwrite)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/2D/wKiom1Q34KPjcmKyAAC76gMYqGE347.jpg "title=" 20.png "Width=" 622 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:622px;height:43px; "alt=" Wkiom1q34kpjcmkyaac76gmyqge347.jpg "/>

2, CP hznethome.txt./net >> Copy hznethome.txt document to Net Folder (note the permissions inside)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2E/wKioL1Q34nWCFVGrAAR9V3_ZwD4130.jpg "title=" 21.png "Width=" 622 "height=" 253 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:622px;height:253px; "alt=" Wkiol1q34nwcfvgraar9v3_zwd4130.jpg "/>

3, CP Hznethome.txt./hz

CP Hznethome.txt./hz

>>> Repeat the copy once, if there is any change will be copied, if none, it will be unchanged.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2D/wKiom1Q37WmBjOOPAAEWT27dbzU406.jpg "title=" 22.png "Width=" 622 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:622px;height:83px; "alt=" Wkiom1q37wmbjoopaaewt27dbzu406.jpg "/>

The above is not updated when the hint, below we write some text in the Hznethome.txt, and then to test the action just now.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/2D/wKiom1Q37keDviyFAADuT42MIds218.jpg "title=" 23.png "Width=" 622 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:622px;height:68px; "alt=" Wkiom1q37kedviyfaadut42mids218.jpg "/>

There is no hint of what was said above.

4. cp-r./net./hz

cp-r./net./hz

>>> copy folders to use with parameter R combined.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2D/wKiom1Q38DqQUhnwAAMmxIYP_y0003.jpg "title=" 24.png "Width=" 622 "height=" 409 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:622PX;HEIGHT:409PX; "alt=" Wkiom1q38dqquhnwaammxiyp_y0003.jpg "/>

Command MV (move in English abbreviation)
Function Move File & Change file name (rename)
Grammar MV [options] [source file] [target file]
Extended

While copying the source file is still in, but moving (MV) session, the source file does not exist, this is consistent with Windows.


Instance

1, we first to test under the renamed, to change the name of Hznethome.txt

Test.txt

MV Hznethome.txt Test.txt

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/2F/wKioL1Q399WgwIF9AAGy9WclnxE513.jpg "title=" 26.png "Width=" 622 "height=" 119 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:622PX;HEIGHT:119PX; "alt=" Wkiol1q399wgwif9aagy9wclnxe513.jpg "/>

2. Move the folder (to move the home folder to the Hz folder)

MV Home Hz

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/2D/wKiom1Q3-SvgN11-AAKV8Jj-ths366.jpg "title=" 27.png "Width=" 622 "height=" 317 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:622PX;HEIGHT:317PX; "alt=" Wkiom1q3-svgn11-aakv8jj-ths366.jpg "/>

3. When the target folder is present, move directly to the inside.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/2F/wKioL1Q3-y6i4h1wAAGS330EtrA712.jpg "title=" 28.png "Width=" 622 "height=" 409 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:622PX;HEIGHT:409PX; "alt=" Wkiol1q3-y6i4h1waags330etra712.jpg "/>

4, when the target folder is not present, the direct re-command operation.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/2F/wKioL1Q3_BnxE2fNAAF9Eod4uQg885.jpg "title=" 29.png "Width=" 622 "height=" 327 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:622PX;HEIGHT:327PX; "alt=" wkiol1q3_ Bnxe2fnaaf9eod4uqg885.jpg "/>




This article is from the "Last Bus" blog, so be sure to keep this source http://hznethome.blog.51cto.com/722914/1562367

Linux Learning Notes (10)--Command Learning (file creation)

Related Article

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.