Hacker
Professional
- Messages
- 1,044
- Reaction score
- 828
- Points
- 113
If you want to fake a creation date of a file, you need to fake your session date.
In Linux we can change the date from a file and the current date (date command).
To get the current date we use date:
We can change this by installing faketime:
After faketime has been successfully installed we use -nd for specifying the days n = number d = days, you can also use y for years m for minutes etc.
Well now we're back in 2006. If we try to create a file with touch it should be 2006 shouldn't it ?
No it is the real date. Well we need to use a touch parameter for that.
A second option without installing a package would be date itself:
First need root permissions for that, then create a file and view it with ls -l, and second, this will set the time permanently to this value so it is recommendable to use faketime because faketime is only for the current command / session.
It is not recommendable to change the date into future date, websites couldn't work and as well for past time.
We can change on files two types of times:
atime (access time)
mtime (modify time)
Access Time
To change the access time for example to the past:
We use here the -a for access. Probably you wouldn't see the changed date, because ls -l only shows the modify date which we change by using -m.
Modify Time
You can use -ma aswell:
In Linux we can change the date from a file and the current date (date command).
To get the current date we use date:
Code:
┌──(mrblackx㉿viperzcrew)-[~]
└─$ date
Sat 24 Apr 2021 09:38:41 PM CEST
We can change this by installing faketime:
Code:
sudo apt install faketime
After faketime has been successfully installed we use -nd for specifying the days n = number d = days, you can also use y for years m for minutes etc.
Code:
┌──(mrblackx㉿viperzcrew)-[~]
└─$ faketime -f "-15y" bash
┌──(mrblackx㉿viperzcrew)-[~]
└─$ date
Fri 28 Apr 2006 09:41:41 PM CEST
Well now we're back in 2006. If we try to create a file with touch it should be 2006 shouldn't it ?
No it is the real date. Well we need to use a touch parameter for that.
Code:
date
Fri 28 Apr 2006 09:42:33 PM CEST
touch today.txt
ls -l today.txt
-rw-r--r-- 1 mrblackx mrblackx 0 Apr 24 2021 today.txt
A second option without installing a package would be date itself:
Code:
NOW=$(date)
sudo date --set "2030-08-15 21:30:11"
sudo date --set $NOW
First need root permissions for that, then create a file and view it with ls -l, and second, this will set the time permanently to this value so it is recommendable to use faketime because faketime is only for the current command / session.

We can change on files two types of times:


Access Time
To change the access time for example to the past:
Code:
touch -a --date="1999-02-15 01:23" file.txt
We use here the -a for access. Probably you wouldn't see the changed date, because ls -l only shows the modify date which we change by using -m.
Modify Time
Code:
touch -m --date="1999-02-15 01:23" file.txt
You can use -ma aswell:
Code:
touch -ma --date="1999-02-15 01:23" file.txt