Help - Search - Members - Calendar
Full Version: Listing Files
Linuxhelp > Support > Technical Support
axero
How can you list all the files under the /home directory that have been created or modified since the last system boot?

I checked the man pages for find but cant seem to find a way to do it, any ideas?

Thanks.
hughesjr
The first thing you need to do is find a file that is created at startup, so you can compare files to that file and list any files that are newer than that file. There are any number of files that probably meet that condition. I use RedHat and when things in the /etc/init.d directory are started they write files in a directory called:

/var/lock/subsys

Right now, I have 26 files in that directory that were created on Oct 20 20:07. I would pick a file that I know I never restart, but that will run everytime the machine is started. One such file (on my system) is /var/lock/subsys/atd. atd is used to run files at a given time ... it starts on bootup and I never restart it during normal operations ... so that is the file I will use to test all the files in home against...

That file {/var/lock/subsys/atd} is very distro {RedHat} and machine {I use atd, other may not} dependant, but the concept is find a file that is created (or changed) at boot up and doesn't normally change until the next boot up. Another file (on a RedHat machine) that you can use is /var/log/boot.log...it is a log of bootup output, and is rewritten every machine start. In fact, I like it better, so I've talked myself into using /var/log/boot.log.

The command would be:

find /home * -newer /var/log/boot.log

That would show all files and directories ... if you only wanted files, the command would be:

find /home * -type f -newer /var/log/boot.log

If you wanted to write the results to a file for viewing ... it would be like this (to write to the user's home directory in a file named files_changed.txt:

find /home * -type f -newer /var/log/boot.log > $HOME/files_changed.txt

(putting the * in means that only files that start with something other than . will be shown .... if you also want to see the . files (like .bashrc or .bash_profile) then just use the command like this:

find /home -type f -newer /var/log/boot.log > $HOME/files_changed.txt
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.