Changing the Date or Time on a Linux File
Another quick Linux how to today, here we learn how to change the date on a file in Linux. To do so we will use the command “touch“, this command can also be used to create empty files in Linux also. If you want a full txt editor you can use nano, this guide is here.
First ill create the file and list its details below, we create the file with the following syntax.
touch testfile.txt
We now use the ls -l command to see the details of this file.
We can see that the file was create june 26 at 09:12, we can modify the date stamp of a Linux file with the Touch command with the “-t” flag like so:
touch -t 09091020 testfile.txt
In the above we change the testfile.txt to have a date of the 9th of september at 10:20 am.
To see this has actually worked we use the “ls -l” command again to list the file information:
If like me you are interested in learning Linux then consider a VPS so if you break anything you have nothing to lose, check out this link – 25% OFF VPS Hosting.
Tags: learn linux