View new files in linux

Posted by johnpdmccall on Fri, 17 Dec 2021 10:14:07 +0100

Query and edit the content within the current [1:00, 2:00] interval
find /etc -mmin 2 / / Note: it refers to the minutes from [n-1, n]
Query and edit the content within the current [0:00, 2:00] interval
find /etc -mmin -2
Query and edit the content within the interval of [2:00, positive infinity] from now on
find /etc -mmin +2

Query and edit the content within the current [1day, 2day] interval
find /etc -mtime 2 / / Note: it refers to the number of days from [n-1, n]
Query and edit the content within the current [0day, 2day] interval
find /etc -mtime -2
#Query and edit the content within the [2day, positive infinity] interval from now on
find /etc -mtime +2

For example, recursively find the modified and newly added files in / directory in the last 120 minutes find / -mmin -120
Find the file sudo find / -mmin -120 | grep lightdm with lightdm keyword

ubuntu:~/desktop $ sudo find / -mmin -120 | grep lightdm
[sudo] sz Password for:
/usr/share/lightdm/lightdm.conf.d
/usr/share/lightdm/lightdm.conf.d/50-slscreenagrentsvr.conf
find: "/run/user/1000/gvfs": insufficient privilege
/sys/fs/cgroup/devices/system.slice/lightdm.service
/sys/fs/cgroup/devices/system.slice/lightdm.service/tasks
/sys/fs/cgroup/devices/system.slice/lightdm.service/devices.allow
/sys/fs/cgroup/devices/system.slice/lightdm.service/cgroup.clone_children
/sys/fs/cgroup/devices/system.slice/lightdm.service/notify_on_release
/sys/fs/cgroup/devices/system.slice/lightdm.service/devices.deny
/sys/fs/cgroup/devices/system.slice/lightdm.service/devices.list
/sys/fs/cgroup/systemd/system.slice/lightdm.service
/sys/fs/cgroup/systemd/system.slice/lightdm.service/tasks
/sys/fs/cgroup/systemd/system.slice/lightdm.service/cgroup.clone_children
/sys/fs/cgroup/systemd/system.slice/lightdm.service/notify_on_release
find: "/proc/3482/task/3482/fd/5": There is no such file or directory
find: "/proc/3482/task/3482/fdinfo/5": There is no such file or directory
find: "/proc/3482/fd/6": There is no such file or directory
find: "/proc/3482/fdinfo/6": There is no such file or directory

Once the file is found, you can use the stat file path to view the file time details
For example, stat 123 sh

ubuntu:~/desktop $ stat 123.sh
  File:'123.sh'
  Size: 23              Block: 8          IO Block: 4096 normal files
 Equipment: 805 h/2053d        Inode: 1323641     Hard link: 1
 jurisdiction:(0777/-rwxrwxrwx)  Uid: ( 1000/      sz)   Gid: ( 1000/      sz)
Recent visit: 2021-12-17 14:01:09.341976146 +0800
 Recent changes: 2021-12-17 13:56:47.099678815 +0800
 Recent changes: 2021-12-17 13:59:17.445146247 +0800
 Created on:-

Under windows, a file has three time attributes:

1> Creation time

2> Modification time

3> Access time

Similarly, under Linux, the next file has three time attributes:
(different from windows, linux has no creation time, but multiple access times)

1> access time (atime for short)
For example, SH 123 When sh executes the script, the time changes
2> modify time (mtime for short)
This time changes when vim modifies the content
3> change time (abbreviated as ctime)
chmod modify permission, mv move / modify name, vim modify content, the time will change

A brief introduction to the following three kinds of time in Linux:

atime: (access time) shows the time when the data in the file was last accessed. For example, the system process uses it directly or indirectly through some commands and scripts. (execute some executable files or scripts)

mtime: (modify time) displays the last time when the file content is modified. For example, it will be changed when editing with vi. (that is, the content of Block)

ctime: (change time) shows the time when the permissions, owners, groups and links of the file change. Of course, when the content changes, it will also change (that is, when the inode content changes and the Block content changes)

Topics: Linux Operation & Maintenance Ubuntu server redhat