Reputation: 29
I want to know exactly what happen when you create file on linux, for example with touch file.txt. What happen when you execute this ? is there any link to this file which are created ?
Thanks.
kafson.
Upvotes: 1
Views: 686
Reputation: 23
As $ man touch
shows, $ touch FILE
does not create FILE; $ touch FILE
is used to "Update the access and modification times of each FILE to the current time." So basically it changes the timestamps.
However, you can use the command to create an empty file of the name FILE because, as the man page says, "A FILE argument that does not exist is created empty, unless -c or -h is supplied."
So what happens when this new file is created?
The touch
command communicates with the file system to create the pointer to an area on the disk that will be allocated to this file. However, since the file is created empty nothing will actually be written to that area on the disk.
With this file system pointer in place, $ ls
or your file browser will now show FILE in whatever your PWD was.
I'm not sure exactly what you mean by "is there any link to this file which are created ?"
If you mean a symlink or hardlink, then not that I know of.
Upvotes: 1