Typically, for each file or a directory, the Linux/Unix system maintains three time stamps: “Access”, “Modify” and “Change”. The command “stat” can be used to get the information as shown below.

[neo@techpulp ~]# stat face.jpg
File: `face.jpg'
Size: 3689673         Blocks: 7216       IO Block: 4096   regular file
Device: 823h/2083d      Inode: 812120      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (  500/     neo)   Gid: (  500/     neo)
Access: 2009-01-23 01:15:31.000000000 +0530
Modify: 2009-01-23 01:15:29.000000000 +0530
Change: 2009-01-23 01:15:29.000000000 +0530
[neo@techpulp ~]#

A Linux command-line utility “touch” can be used to modify the time stamps of a file. By default, this command typically changes the file’s access and modification time to the current time. However you can specify custom date and time to set as Modify and Access time stamps.

[neo@techpulp ~]# touch face.jpg
[neo@techpulp ~]# stat face.jpg
File: `face.jpg'
Size: 3689673         Blocks: 7216       IO Block: 4096   regular file
Device: 823h/2083d      Inode: 812120      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (  500/     neo)   Gid: (  500/     neo)
Access: 2009-01-23 01:19:58.000000000 +0530
Modify: 2009-01-23 01:19:58.000000000 +0530
Change: 2009-01-23 01:19:58.000000000 +0530
[neo@techpulp ~]#

You can see the time stamps being changed to the current time in the above example. The following example shows how to set custom time stamp:

[neo@techpulp ~]# touch -d '1 Jan 2000 00:01' face.jpg
[neo@techpulp ~]# stat face.jpg
File: `face.jpg'
Size: 3689673         Blocks: 7216       IO Block: 4096   regular file
Device: 823h/2083d      Inode: 812120      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (  500/     neo)   Gid: (  500/     neo)
Access: 2000-01-01 00:01:00.000000000 +0530
Modify: 2000-01-01 00:01:00.000000000 +0530
Change: 2009-01-23 01:22:23.000000000 +0530
[neo@techpulp ~]#

It is not mandatory that you should provide date and time always. You can also specify just date or time as shown below.

[neo@techpulp ~]# touch -d '31 Dec 2001' face.jpg
[neo@techpulp ~]# stat face.jpg
File: `face.jpg'
Size: 3689673         Blocks: 7216       IO Block: 4096   regular file
Device: 823h/2083d      Inode: 812120      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (  500/     neo)   Gid: (  500/     neo)
Access: 2001-12-31 00:00:00.000000000 +0530
Modify: 2001-12-31 00:00:00.000000000 +0530
Change: 2009-01-23 01:24:38.000000000 +0530
[neo@techpulp ~]#
[neo@techpulp ~]# touch -d '11:59:59' face.jpg
[neo@techpulp ~]# stat face.jpg
File: `face.jpg'
Size: 3689673         Blocks: 7216       IO Block: 4096   regular file
Device: 823h/2083d      Inode: 812120      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (  500/     neo)   Gid: (  500/     neo)
Access: 2009-01-23 11:59:59.000000000 +0530
Modify: 2009-01-23 11:59:59.000000000 +0530
Change: 2009-01-23 01:25:15.000000000 +0530
[neo@techpulp ~]#