< -- BuySellAds Ad Code ALLEN -->
  • Home
  • Linux
  • Changing the Date or Time on a Linux File

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

create a file in linux

We now use the ls -l command to see the details of this file.

modify the date of a file in linux

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.

change the date or time on a linux file

To see this has actually worked we use the “ls -l” command again to list the file information:

change date on linux file

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

Allen White

Allen is an IT Consultant and holds the following accreditations. MCSA, MCSE, MCTS, MCITP, CCA, CCSP, VCP 4,5, 6 and HP ASE, AIS - Network Infrastructure.

Leave a comment

Categories

Vote!

What Web Browser Do You Use?

View Results

Loading ... Loading ...

Vote!

What do you prefer..VMware or Hyper-V?

View Results

Loading ... Loading ...