Find deleted files in Linux easily!
Have you ever accidentally deleted an important file or directory in your Linux system and didn't know how to restore it? This may be a problem that many Linux users have encountered. But now, you don't need to worry about this problem anymore. This article will introduce a simple and effective method to help you retrieve deleted files and directories in Linux systems.
1. Use the ls command to list only today’s files in your home folder
# ls -al --time-style=+%D | grep 'date +%D'
in:
-a- List all files, including hidden files
-l- Enable long list format
>–time-style=FORMAT- Display the time of the specified FORMAT
%D - Display or use dates in >%m/%d/%y (month/day/year) format

Find recent files in Linux
Additionally, you can use the -X flag to sort the results alphabetically:
# ls -alX --time-style=+%D | grep 'date +%D'
You can also use the -S flag to sort based on size (largest to smallest):
# ls -alS --time-style=+%D | grep 'date +%D'
2. In addition, using the find command will be more flexible and provide more options than ls, which can achieve the same purpose
- The -maxdepth level is used to specify the search level (number of subdirectory levels) under the starting point of the search operation (in this case, the current directory).
-
newerXY is used to find files whose timestamp X is newer than the timestamp Y of the reference file. X and Y represent any of the following letters:
-a- Reference file access time
-B- Reference file creation time
-c- Reference file’s inode status change time
-m- Reference file modification time
-t- Directly specify an absolute time
The following command means to find only the files modified on 2016-12-06:
# find . -maxdepth 1 -newermt "2016-12-06"

Find today’s files in Linux
Important: Use the correct date format as the reference time in the above find command, once you use the wrong format, you will get the following error:
# find . -maxdepth 1 -newermt "12-06-2016" #find: I cannot figure out how to interpret '12-06-2016' as a date or time
Alternatively, use the following correct format:
# find . -maxdepth 1 -newermt "12/06/2016" 或者 # find . -maxdepth 1 -newermt "12/06/16"

In this article, we explained how to use ls and find command help to list only today’s files. Please use the feedback box below to send us any questions or comments about this topic. You can also remind us of other commands that can be used for this purpose. ,
By reading this article, you have learned how to use the find command to find and restore deleted files and directories in Linux systems. At the same time, we also cover some other tips and suggestions to help you better protect your data and prevent accidental deletion. I hope this article is helpful to you and provides you with some guidance and assistance for file management in your Linux system.
The above is the detailed content of Find deleted files in Linux easily!. For more information, please follow other related articles on the PHP Chinese website!

The main difference between Linux and Windows in user account management is the permission model and management tools. Linux uses Unix-based permissions models and command-line tools (such as useradd, usermod, userdel), while Windows uses its own security model and graphical user interface (GUI) management tools.

Linux'scommandlinecanbemoresecurethanWindowsifmanagedcorrectly,butrequiresmoreuserknowledge.1)Linux'sopen-sourcenatureallowsforquicksecurityupdates.2)Misconfigurationcanleadtovulnerabilities.Windows'commandlineismorecontrolledbutlesscustomizable,with

This guide explains how to automatically mount a USB drive on boot in Linux, saving you time and effort. Step 1: Identify Your USB Drive Use the lsblk command to list all block devices. Your USB drive will likely be labeled /dev/sdb1, /dev/sdc1, etc

Cross-platform applications have revolutionized software development, enabling seamless functionality across operating systems like Linux, Windows, and macOS. This eliminates the need to switch apps based on your device, offering consistent experien

Artificial Intelligence (AI) is rapidly transforming numerous sectors, from healthcare and finance to creative fields like art and music. Linux, with its open-source nature, adaptability, and performance capabilities, has emerged as a premier platfo

Looking for a fast, minimal, and efficient Linux distribution without a graphical user interface (GUI)? Lightweight, GUI-less Linux distros are perfect for older hardware or specialized tasks like servers and embedded systems. They consume fewer res

Wine 10.0 stable version release: Running Windows applications on Linux to a higher level Wine, this open source and free application, allows Linux users to run Windows software and games on Unix/Linux operating systems, ushering in the release of the 10.0 stable version! This version has been provided with source code and binary package downloads, and supports various distributions such as Linux, Windows and Mac. This edition embodies a year of hard work and over 8,600 improvements, bringing many exciting improvements. Key highlights include: Enhanced support for Bluetooth devices. Improve support for HID input devices. Optimized performance of 32-bit and 64-bit applications.

This tutorial guides you through installing SQL Server 2022 on RHEL 8.x or 9.x, connecting via the sqlcmd command-line tool, database creation, and basic querying. Prerequisites Before beginning, ensure: A supported RHEL version (RHEL 8 or 9). Sudo


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
