silikoncz.blogg.se

Set file modifcation time to oldest file time
Set file modifcation time to oldest file time










set file modifcation time to oldest file time

#Set file modifcation time to oldest file time full

The output with the sort is shown below, now we have the files in the same order as the output of the full command string shown previously after sorting by column 1, the epoch time. The -k flag specifies a start position which in this case is 1, the first column being the epoch time. Now with this output you may have noticed that there is no order applied, this is taken care of with the sort command. We can see the output displayed as expected, the files epoch time followed by the last modification date and time, followed by the file name. index.htmlĪt this stage the output does not display in any sort of chronological order. The output of this find command alone looks like this. This should show things such as permission changes which don’t actually modify the contents file but change the metadata. It is worth noting that you could also replace %t with %c, which will instead use the files last status change time rather than the modification time. The % displays the epoch time, that is the amount of seconds since the 1st of January 1970, the %t shows the files last modification time, the %p displays the files name while \n is simply a new line so that each result in our output shows up on a new line which makes it easier to read and work with. The “-printf” flag is used to print the output in the format specified, in this case this is ‘% %t %p\n’. You can change the “.” to a full directory path instead to list all files and subdirectories in there instead if required, this way you don’t have to be in the directory. To confirm your current working directory you can run the “pwd” command. Findįirst off the find command is run which finds us the list of all files and subdirectories recursively within the current working directory, as specified by the “.” after the find command. Now let’s break down what each part is actually doing for us.

set file modifcation time to oldest file time

index.htmlĪs shown we can see the files sorted from oldest date and time modified to newest. printf '% %t %p\n' | sort -k 1 -n | cut -d' ' -f2-īelow is an example output from running this full command. If you have a lot of output piping the whole lot into ‘less’ may be a good idea so that you can easily scroll through. The most recently changed contents will be at the bottom of the list, so after running it you’ll see the most recent changes with the older changes as you scroll up. So here are the simple commands piped together, run this within a directory and you will be provided with a list of all files and subdirectories along with the date they were last modified.

set file modifcation time to oldest file time

By seeing other files that were modified around the same time you can get a better idea of what took place and when, allowing you to correlate these events with your logs. This is one of my favourite commands to use when trying to build a timeline of events, for instance if a server or website has been compromised and you want to see when files have been modified with malicious content. Have you ever wanted to view a list of all files or subdirectories within a directory in Linux and order them by when they were last changed or modified? Then you have come to the right place! Here we are going to provide and explain some useful commands that when piped together will give us this result, allowing us to recursively list files and directories by date.












Set file modifcation time to oldest file time