How to use Touch command effectively in Kali Linux

As you all knows Touch command is used to create a quick file of any extension. Touch command can be used to modify the access/modification timestamps of files. You can even create a simple blank file with the help of Touch command.

For Example, if you want to create a totally blank file in your Kali Linux machine, then just type “touch file.txt” And in case, if that “file.txt” already exists, then it will update the access time automatically.

You can also create multiple files in same location by typing “touch file1.txt file2.txt file3.txt“. You just need to add a space in between the file names.

With the help of touch command, you can even create a lots of file like “touch {A..Z}“, “touch {1..20}” and “touch {1..1000}.txt“. Be careful when you are testing with above commands because it will create alot of files within a span of 1 second.

If you want to just update the access time of existing file, without creating it, you can “touch -c file.txt“.

And to change only access time, you can use “touch -a file.txt“.

The best thing about Linux machine is, you can easily check the access time of any file with the help of stat command as per below screenshot.

Furthermore, -m attribute is used to change the modified time of any file like “touch -m file.txt” and for multiple files, you can try “touch -m *.txt“.

You can change both access time and modified time together by typing “touch -am file.txt“.

To set the access/modify time to a specific date time, you can use -t option and specify the date time in format [[CC]YY]MMDDhhmm[.ss] like “touch -c -t 1603051015 file.txt“.

You can even use the timestamp of another file as a reference by typing “touch -r reference.txt file.txt“.

With -d option, you can also define the date time as a string by typing “touch -c -d ’15 Aug’ file.txt

You may also like:

Sarcastic Writer

Step by step hacking tutorials about wireless cracking, kali linux, metasploit, ethical hacking, seo tips and tricks, malware analysis and scanning.

Related Posts