search
HomeSystem TutorialLINUXFind deleted files in Linux easily!

Find deleted files in Linux easily!

Feb 10, 2024 pm 06:39 PM
linuxlinux tutoriallinux systemlinux commandshell scriptembeddedlinuxGetting started with linuxlinux learning

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 deleted files in Linux easily!

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

  1. 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).
  2. 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 deleted files in Linux easily!

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"
Find deleted files in Linux easily!

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!

Statement
This article is reproduced at:良许Linux教程网. If there is any infringement, please contact admin@php.cn delete
What are the differences in user account management between Linux and Windows?What are the differences in user account management between Linux and Windows?May 02, 2025 am 12:02 AM

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.

How does the command line environment of Linux make it more/less secure than Windows?How does the command line environment of Linux make it more/less secure than Windows?May 01, 2025 am 12:03 AM

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

How to Make a USB Drive Mount Automatically in LinuxHow to Make a USB Drive Mount Automatically in LinuxApr 30, 2025 am 10:04 AM

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

Best Cross-Platform Apps for Linux, Windows, and Mac in 2025Best Cross-Platform Apps for Linux, Windows, and Mac in 2025Apr 30, 2025 am 09:57 AM

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

Best Linux Tools for AI and Machine Learning in 2025Best Linux Tools for AI and Machine Learning in 2025Apr 30, 2025 am 09:44 AM

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

5 Best Lightweight Linux Distros Without a GUI5 Best Lightweight Linux Distros Without a GUIApr 30, 2025 am 09:38 AM

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

How to Install Wine 10.0 in RedHat DistributionsHow to Install Wine 10.0 in RedHat DistributionsApr 30, 2025 am 09:32 AM

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.

How to Install and Configure SQL Server on RHELHow to Install and Configure SQL Server on RHELApr 30, 2025 am 09:27 AM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

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

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

mPDF

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),