LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-16-2017, 02:27 AM   #1
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Rep: Reputation: 11
Post Recent files in Linux.


Hello.
Has Linux any recent files? I like to know when I'm not at the desk then which files viewed by others.


Thank you.
 
Old 07-16-2017, 03:08 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,286

Rep: Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165Reputation: 4165
If you are not at your machine, no-one should be able to access anything.
What did you web search return ?.
 
1 members found this post helpful.
Old 07-16-2017, 04:42 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,280

Rep: Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696Reputation: 7696
at first you can lock your computer, so noone can use it without your password.
Next, nowadays the PCs connected to the network, so one can reach your PC without sitting at your desk.
finally the system (running programs) may write files anywhere (like logs or anything else) without a keypress, without logged in users (human beings).
 
Old 07-16-2017, 04:52 AM   #4
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
You can find recently accessed files with, what a surprise, find command. For example:

Code:
find . -user username -type f -amin -60
will show you all files, but not directories, owned by username that were accessed in the last 60 min in working directory. Instead of that . use path to directory that you wish to examine. For some more insight of how find command works, you can read man page, or/and visit this page: https://www.tecmint.com/35-practical...-find-command/.

Last edited by dejank; 07-16-2017 at 04:54 AM.
 
2 members found this post helpful.
Old 07-17-2017, 02:17 AM   #5
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Yup, you can do this easily with the find command. There are a few flavours for the access times and modified times:
Code:
find $HOME -type f TIME_ARG

###  TIME_ARG can be (for example):

-amin -120
  file was last accessed less than 120 minutes ago. The "less than" is indicated by the minus sign in front of the number.
-atime -1
  file was last accessed less than 1 day ago.
-mmin -45
  file was last modified less than 45 minutes ago.
-mtime -0.5
  file was last modified less than half a day ago (less than 12 hours).
But as syg00 said, no one should be accessing your files when you're not there. Create separate user profiles for every user, set password and encrypt your home directory.
 
Old 07-18-2017, 02:11 AM   #6
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Distribution: Mint/MATE
Posts: 2,988

Rep: Reputation: 1276Reputation: 1276Reputation: 1276Reputation: 1276Reputation: 1276Reputation: 1276Reputation: 1276Reputation: 1276Reputation: 1276
The atime works in Unix only.
In Linux since kernel 2.6.30 the default mount option is relatime, so find -amin and ls -lu are not reliable.
The atime is updated if it were off by more than 1 day, so frequent access can still be seen with -atime -1.
If you want to use reliable atime in Linux you need to explicitly mount with option strictatime.

Last edited by MadeInGermany; 07-24-2017 at 12:50 PM. Reason: spelling
 
Old 07-23-2017, 02:05 AM   #7
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
I opened a file but "find $HOME -type f -amin 1" not show it !!!
Code:
$ find $HOME -type f -amin 1
/home/mohsen/.config/google-chrome/Default/Preferences
/home/mohsen/.config/google-chrome/Local State
/home/mohsen/.config/dconf/user
 
Old 07-23-2017, 03:31 AM   #8
dejank
Member
 
Registered: May 2016
Location: Belgrade, Serbia
Distribution: Debian
Posts: 229

Rep: Reputation: Disabled
Quote:
Originally Posted by hack3rcon View Post
I opened a file but "find $HOME -type f -amin 1" not show it !!!
Code:
$ find $HOME -type f -amin 1
/home/mohsen/.config/google-chrome/Default/Preferences
/home/mohsen/.config/google-chrome/Local State
/home/mohsen/.config/dconf/user
You want -amin -1, not -amin 1. Read man page of find, please. There is explanation there for time units and difference between +n, -n and n.
 
Old 07-24-2017, 05:21 AM   #9
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,283

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
check out this link you might get some idea:

https://askubuntu.com/questions/4700...rough-terminal
 
1 members found this post helpful.
Old 07-26-2017, 03:35 AM   #10
hack3rcon
Senior Member
 
Registered: Jan 2015
Posts: 1,432

Original Poster
Rep: Reputation: 11
Quote:
Originally Posted by JJJCR View Post
check out this link you might get some idea:

https://askubuntu.com/questions/4700...rough-terminal
Thank you. Below command shows me the result that I wanted.
Code:
$ sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete all .log files and .bat files except the most recent? alancampbell6 Linux - Newbie 3 12-15-2011 10:17 AM
keeping only the most recent 10 files Cerephim Linux - Server 1 12-13-2010 01:45 PM
Recent files in XFCE niels.horn Slackware 12 05-04-2009 03:27 PM
find and move most recent files in dir backnine_99 Linux - Software 2 06-14-2005 01:03 PM
deleting recent files Santas Linux - General 2 01-19-2004 07:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration