The zero-based Linux 13th chapter

Source: Internet
Author: User
Tags touch command

The zero-based Linux 13th chapter


(Small to push the door into) students early ~ ~ is a happy day ~ ~

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/A7/26/wKioL1nhytPRD63bAAAln3e-i_I462.jpg "title="- 5759326e8704bfea.jpg "width=" "height=" 268 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:220PX;HEIGHT:268PX; "alt = "Wkiol1nhytprd63baaaln3e-i_i462.jpg"/>

(↑ the eyes of the students see the Little PostScript)

Alas?? What's wrong with the students? Why do you look at the small series with this kind of eyes?

Passers-by B: "Early your head Ah!" It's almost night!! You're a day late!! A day late!! ”

Oops ~ ~ ~ The bed is too warm, and the world is too cold (thinking of the empty pocket purse, resist tears down), this materialistic society, only the quilt can give a small part of the warmth ~(spit groove: Mutant painting Wind)

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/A7/27/wKioL1nh0SPzWtHHAABGMO1pW_4933.jpg "title="- 3c450a0d765ae52.jpg "width=" "height=" 161 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:220px;height:161px; "alt= "Wkiol1nh0spzwthhaabgmo1pw_4933.jpg"/>

(↑ passers-by B): "Ah ~ ~ has our company's holiday unhappy?" ”

(a face) your face is a little bit more evil. May be happy ....

Passerby a: "Alas?" Small series ... Not happy ... "

No Ah, small series is very happy ~ Thank passers-by to let the students accompany the teacher for the holidays ~ ~

Passerby B: "Hey!! This is not the same treatment! Teachers should not be the same!! ”

OK, no kidding ~ ~ Back to the seat, a small series to lecture ~ ~ Happy Holiday has ended one weeks, the small part of the front of the content, students have not forgotten it? Well, forget it, forget the small part can be liberated no longer talk (spit groove: Are you really our teacher!? )


Joking Jokes ~ ~ A chapter on the use of font change color ,date system clock command,clock,hwclock hardware Clock command,Cal calendar The detailed usage of these commands. Although the small part of each chapter will say the command is more messy, but in fact, it is not a mess ~ ~ But this time, small series or to say ~ This chapter content, may be more chaotic oh ~ ~


In the third chapter of the students already know the Linux file system, and know the file type, and Linux must exist in the directory (FHS), in the second chapter in the last mention of the philosophy of Linux, as well as to the students to tell the file command to view file types and so on some file system related theories, then, for some simple operation how to see the contents of a file, how to create a common file and how to create a directory of small series so far has not told everyone ~ ~ So this chapter, small series to introduce in detail how to create a file, Directory and view the contents of a file.


Small series before the Nano Editor , the small series did not introduce you to view the command, I believe the students to view the file with the editor to view, but also can be modified. Although has the modification function, but if only uses to view the file content, is very inconvenient ~ so, small to introduce you to the common tool:

Cat: Text Viewing tool

Widget now create a regular file and enter some content, using cat to view the content:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/A7/27/wKioL1nh1hax0-K1AAAKzSOAtGU075.png "title=" Qq20171014172908.png "width=" 550 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:550px;height:130px; "alt = "Wkiol1nh1hax0-k1aaakzsoatgu075.png"/>

You can view the contents of a file by entering the file you want to view directly behind the Cat command, and note that if the file you are viewing is not under the current path, write the path.

Also, what are the options for this command? Small series now look at the man document, students to form the encounter command to see the man document ~ ~

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/08/72/wKiom1nh2ebjgBaTAAAq0QM8Evw004.png "title=" Qq20171014173352.png "width=" 550 "height=" 239 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:239PX; "alt = "Wkiom1nh2ebjgbataaaq0qm8evw004.png"/>

Although the Cat command is simple, but its options are many, small part of the students here to introduce the ~ ~ Other options, interested in the words can try it yourself ~ ~


- N: Numbering all output lines (Displays the line number of each line)

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/A7/27/wKioL1nh2NfQqnkeAAALjllUbLc899.png "title=" Qq20171014174018.png "width=" 550 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:132PX; "alt = "Wkiol1nh2nfqqnkeaaaljllublc899.png"/>

Cat-n plus the specified file can be the displayed content plus the line number, um. What's the use of this?? 23333 I know when I use it.


-e: Show $ symbol at end of each line

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/08/72/wKiom1nh3NmQUddcAAAMDFvLX3s518.png "title=" Qq20171014174628.png "width=" 550 "height=" 103 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:103PX; "alt = "Wkiom1nh3nmquddcaaamdfvlx3s518.png"/>

This option will add $ at the end of each line, indicating that the line is over (note that the file content is changed Oh ~ Do not care why the content will not be the same), the file content is not really used, but if a content more than one file:

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/A7/27/wKioL1nh2qSQF3-JAACQ8rUUx8k279.png "title=" Qq20171014174836.png "width=" 550 "height=" 169 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:169PX; "alt = "Wkiol1nh2qsqf3-jaacq8ruux8k279.png"/>

To distinguish exactly where the end of a line is a bit of trouble ~ ~ So this time this command still useful place ~ ~


Cat command basically just to view the contents of a file, do not do anything complicated, so basically the options need not remember much, such as the-e option, in the man document mentioned a-a option, can replace-vet three options

-A: the equivalent of-vet three options (-V: Display tab symbol in file,-T: Show tab ^I)

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/08/73/wKiom1nh3rPw-bkcAAAMMu9kmbw212.png "title=" Qq20171014175419.png "width=" 550 "height=" 109 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:109PX; "alt = "Wkiom1nh3rpw-bkcaaammu9kmbw212.png"/>

Call ~ ~ is better than not add ~ ~ seems more disorderly provoke ~ ~


Because the command is too simple, so for the cat to view the file contents of the command, the small part of the introduction of so many ~ ~ There are also some of the same commands to view the contents of the file, some scenes more practical than the cat command a lot more ~ ~ Those commands and other students skilled cat Command Small series to introduce you ~ ~

Passers-by: "Little Master, why do I use the cat command to view the content, but there is an error?" ”

Nani!? You put the execution of the command and the error let's look at the small series ....

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/08/74/wKiom1nh7xygEeJLAAAKlxHXs5U338.png "title=" Qq20171014190159.png "width=" 550 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:550px;height:78px; "alt=" Wkiom1nh7xygeejlaaaklxhxs5u338.png "/>

(↑ The operation of the pedestrian c)

(↓ Xiao-bian looked at the operator after the operation of the expression)

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/08/74/wKiom1nh8GzgSJ_FAABC0f9Sf8Y669.jpg "title=" 1d6904b3882c4eb7.jpg "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:200px;height:200px; "alt = "Wkiom1nh8gzgsj_faabc0f9sf8y669.jpg"/>

How can there be such a student in small series ... Endure... Endure.. Be sure to resist. Keep smiling, pay attention to the image ... 650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/A7/28/wKioL1nh7uCzXYGpAAAJtZyxpAY795.jpg "title=" 3362b5020d8a7665.jpg "width=" height= "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:40px;height:44px; "alt=" Wkiol1nh7uczxygpaaajtzyxpay795.jpg "/>

Passers-by a cross-examine: "Small series of adults, my machine is not broken off ~"

No way... Small series can't help it ...

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/08/74/wKiom1nh86nyiQDxAAA1Bj_ZNVk220.jpg "title=" 2c04e53667c0292d1.jpg "width=" "height=" 129 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:150PX;HEIGHT:129PX; " alt= "Wkiom1nh86nyiqdxaaa1bj_znvk220.jpg"/>

Watch out for the wrong tips!! Error prompt!!! This is a directory! The cat command is used to look at ordinary files!


OK ~ ~ for the cat Command, the small part is introduced here. Everyone should be careful not to make the same mistakes as the passers-by


View ordinary files Everyone knows how to check, then, how to create ordinary files?

Touch: Create an empty file

So, how do you use this command? Small series still go to look at the man document:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/08/74/wKiom1nh9_3TiUUpAABBfidq8do376.png "title=" Qq20171014194203.png "width=" 550 "height=" 301 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:301PX; "alt = "Wkiom1nh9_3tiuupaabbfidq8do376.png"/>

From the man document, you can see the use of the Touch command:

Touch [OPTION] ... FILE:

option means that the options for this command, the ellipsis means that the option can be added at the same time, file is the name of the filename that specifies the file to be created, such as a file created under the/app/directory:

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A7/28/wKioL1nh9qHT72RrAAAJ2r6YKJk902.png "title=" Qq20171014194718.png "width=" 550 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:550px;height:110px; "alt = "Wkiol1nh9qht72rraaaj2r6ykjk902.png"/>

Small series with the Touch command to create a file named text, followed by the LS command to confirm the existence of the file, existence, the creation of a successful ~ ~

The option of the Touch command involves the concept of "timestamp", what is a timestamp? Small series here to the students briefly explain:

Time stamp:

Files have two types of data: data and metadata

Metadata: Metadata, all properties of the file

Data: information, file contents

(↑ The understanding of both, as long as the content of the file is not related to the metadata, that is, file attributes, including permissions, size and other information)

Timestamp Status:

Files are logged: Last access time. Access times (CTime)

Last changed. Moduft Time (Mtime)

Last modified. Change Time (CTime)

↑ "Last Change" refers to changes in the data in the file, i.e. the contents of the file have changed; "Last Modified" refers to changes in the metadata of the file (such as permissions, size, etc.)

For the above introduction, it is not difficult to find that as long as the data of the file has changed, then the metadata will inevitably change, because the file's "metadata" also contains the size of the file, and change the data in the file, the file size will inevitably change.


So, how do you see the timestamp of the file?

Stat: Displays the status of a file or file system

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/08/75/wKiom1nh_4fQalMKAAAykny4fF8020.png "title=" Qq20171014201426.png "width=" 550 "height=" 159 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:159PX; "alt = "Wkiom1nh_4fqalmkaaaykny4ff8020.png"/>

This command displays all the state of a file or file system, so it's not just a timestamp, including the permissions of the file, the inode number, the size, and more. The bottom access is the last time you visited,Modify is the last time you changed, and the change is the last time you modified it.

When we use the Nano editor to modify the contents of a file:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/A7/29/wKioL1nh_aviYq67AAAHmHU8x4E572.png "title=" Qq20171014201803.png "width=" 550 "height=" 109 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:109PX; "alt = "Wkiol1nh_aviyq67aaahmhu8x4e572.png"/>

Make a few additions to the file, and then look at the timestamp of the file:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/08/75/wKiom1niAJ-Q6bznAAAT_XyHJzc931.png "title=" Qq20171014201906.png "width=" 550 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:550px;height:105px; "alt = "Wkiom1niaj-q6bznaaat_xyhjzc931.png"/>

As you can see,Atime (Access Time), Mtime (change time), Ctime (modification time) have changed, and Atime changes because the small series with the Nano editor opened it, Mtime and Ctime because the data and size changed, When the small series Save the moment, the time will change, so, Atime and the other two time will not be inconsistent .


The change in timestamp is not only changed when the file is modified or accessed, but theTouch command itself has the ability to modify the timestamp, in fact, the file specified later in theTouch command is not just a nonexistent file, it can be a file that already exists.

If the file exists, use the Touch command to modify the file's timestamp, for example:

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/A7/29/wKioL1nh_8bz4rgFAAAxN-Vgocg335.png "title=" Qq20171014202703.png "width=" 550 "height=" 185 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:550px;height:185px; "alt = "Wkiol1nh_8bz4rgfaaaxn-vgocg335.png"/>

It can be found that the timestamp of the file has changed after the small touch of an existing file. If we want to just change a certain time, not change all the time. Touch also has some commands for modifying the timestamp:

-A: Modify only the file's Atime (Access time)

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/08/75/wKiom1niA2Wwz-LBAAAqGxF7rz8082.png "title=" Qq20171014203021.png "width=" 550 "height=" 199 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:199PX; "alt = "Wkiom1nia2wwz-lbaaaqgxf7rz8082.png"/>

What the hell?? How did the Ctime change?? Oh, don't care about these details. ~~man document is said to modify the access time, it is clear that the command also changed the CTime of the file, so ~~man document is not all letter ~ ~ Letter who?? Hum ~ ~ Of course is small make up ~ ~ That, small series above for the explanation of-a will change:

-A: Modify the file's Atime and CTime


-M: Modify only the file's Mtime

Will this make a mistake?

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/08/75/wKiom1niBiLTlUiiAAAy7Zxc7O8643.png "title=" Qq20171014203908.png "width=" 550 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:550px;height:180px; "alt = "Wkiom1nibiltluiiaaay7zxc7o8643.png"/>

Wow ~ and wrong to provoke ~~man document is really not all letter Oh ~ ~ is clearly modified mtime, but together with the CTime also changed, or believe that small series reliable, man document also unreliable provoke ~ ~ so:

-M: Modify the file's Mtime and CTime

What the? You ask a picture and the picture in the middle of the picture how long apart? Hem, the middle of the time, small series to the other students to talk about ~ ~ So a little time to delay ~ ~ Then, the next option:

-T: Modify the file's Atime and mtime to a specified time

The format is "Month day time. Seconds", i.e.: -T "Month day time". Seconds "

The small series is specified here: 201710142000.00

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/08/75/wKiom1niCA6Bi0FyAAArYWINkUE237.png "title=" Qq20171014204750.png "width=" 550 "height=" 193 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:550PX;HEIGHT:193PX; "alt = "Wkiom1nica6bi0fyaaarywinkue237.png"/>

Hum, we can now arbitrarily set access time and change time ~ ~ can do whatever you like ~ ~ But, what is the use of it?? For example, you set some of the relative importance of the file timestamp to the future time ~ ~ There may be a lot of problems oh ~ ~ ~


Good ~ ~ ~ because of the time relationship ~ Small series This time to come here ~ Alas. There are a lot of things not to tell the students, so look forward to the next small series to tell you ~ ~

Well, the time is not early ~ again should sleep to provoke ~ ~ (Spit Groove: You just woke up!) )



The END

This article is from the "13125850" blog, please be sure to keep this source http://13135850.blog.51cto.com/13125850/1972410

Zero-based Linux 13th chapter

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.