I'm trying to track down why and when a particular directory is created in my home folder.
I've learned I can utilize lsof | grep /home/**myusername**/**mysteriousfolder**
to discover the file or process responsible for creating the folder.
Unfortunately, if the responsible process/file is no longer running, the suggested command gives no output. As of yet, I have been unable to catch it 'in the act.'
I'm looking for a log I can parse to discover when exactly this folder is getting created.
So I'm realizing I can at least do ls -ld
and view the 'last modified' date but I'm still curious if any log file exists.
There is no general log for the home folder that details when files and folders were created; the system logs record a number of things, including when software is installed, and often a hidden folder is created in the home folder when you add software, so you might be able to infer when that was created and where it came from by looking at the system logs.
On your system, files and folders are not marked with the time they were created; as you can see below with the
stat
command only the access (atime
), modify (mtime
) and inode change times (ctime
) are listed.Full output from
stat ~/Downloads
:You can use
fuser
to see what processes are accessing which folders; for example, to view those processes related to your overall home folder, enter:If you are concerned that something unauthorised is accessing your home folder I should take a look at the suggestions I made here in this article about searching for files having been modified by a person who is not your user.
Some programs create logs and these might log their activities, but they can be difficult to search as a whole without going through your entire home folder. If you want to monitor yourself you could install some software that logs and monitors everything you do.
If you want to monitor and record to file everything typed into your interactive bash terminal (including
mkdir
commands), you could put this clever use of the trap command into your .bashrc.