![]() Step3: Create a mount point (i.e., a directory where you want to mount the pendrive) $mkdir mount1 It will be with the name sdb1 or sdc1 or something like that (the name is not fixed. ![]() So, I will do it my mounting a pendrive to my system and during mounting will change allow updating the Access Time after each access using strictatime option. To do this you need to use strictatime during mount. The way around is to change this default behaviour. So, even if you access the file to read using cat or head command, it won’t update the Access Time. Now to update the access time after each access will take those many disk access operations which will lead to low system performance. For example, on a server a particular file may be accessed by many people. This is because by default the system does not update the Access Time after every access to the file because of performance reasons. (Don’t say $touch -a because here you did not actually accessed the file, just fooled the system that you did). This one is most tricky and I am pretty sure you will not find an example of it easily on the net. Next, use chmod command to change the permissionsįinally, use stat again and you will see the Change time is updated The steps are:įirst, check the original Change time using stat command. To update just the Change Time of a file a simple method is just to change the file permissions. How to update the Change Time of a File in Linux? Use stat again and we can see that the modification time is changed to 00:20:43 which is the current system time. Hence, we have modified the existing content with the new one. Next, we use the cat command to redirect some new content into file access. Below is shown the modification time of file access which is 22:24 Now let’s try to change the modification time of a file. How to update the Modification Time of a File in Linux? For example, by changing permissions, ownership, file name, number of hard links. For example, you used an editor to add new content or delete some existing content.Ĭhange Time: is the time when the file’s inode has been changed. Modification Time: is the time when the contents of the file was last modified. But remember you did not modify the contents. For example, using the cat, head or an editor. $ touch a.txt -r tgs.Have you ever used the stat command? If yes, then a common question asked is what is the difference between access, modification and change time?Īccess Time: is the time when the file was last accessed or read. The following touch command example will update the time-stamp of file a.txt with the time-stamp of tgs.txt file. You can also take a file as a reference, and update the time for other files, so that both file will hold the same time. Copy the Time-stamp from Another File using -r You can also use a string to change the timeĪnother example: $ touch -d " 12:12:12.000000000 +0530" tgs.txtįor developers, touch command will be really helpful when you are working with Makefiles 5. Size: 3 Blocks: 8 IO Block: 4096 regular file Verify the above change using stat command: $ stat tgs.txt It is not possible to set the date beyond January 18, 2038.įor example: $ touch -a -m -t 203801181205.09 tgs.txt ![]() If the value of the YY is between 00 and 37, the value of the CC digits is assumed to be 20. If the value of the YY is between 70 and 99, the value of the CC digits is assumed to be 19. YY – Specifies the last two digits of the year.CC – Specifies the first two digits of the year.The format for specifying -t is YY]MMDDhhmm Instead of taking the current time-stamp, you can explicitly specify the time using -t and -d options. Explicitly Setting Access and Modification time using -t and -d ![]() NOTE: It is not possible to change the ctime using touch command 4. The above method can be used to change the mtime of all obj files, when using make utility. You can change the modification time of a file using -m option. By default it will take the current system time and update the atime field.īefore touch command is executed: $ stat tgs.txt We can change the access time of a file using -a option. ![]()
0 Comments
Leave a Reply. |