• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us

Free AI Courses With Certificate For Beginners In India

There are a variety of free AI courses with certificate for beginners in India. Whether you're looking to enhance your skills or start from scratch, you can find numerous free AI courses with … [Read More...] about Free AI Courses With Certificate For Beginners In India

Home / How To / How To Delete And Remove Files Older Than 7 Days In Linux

How To Delete And Remove Files Older Than 7 Days In Linux

By Sourabh / January 14, 2026 Category: How To, Ubuntu

How to delete files of a particular date range on Linux. Say, you wish to remove files older than 7 days or 30 days in Linux Ubuntu, you can run the following steps.

Using rm Command

In Unix based systems, rm command is use to remove files or directories. The rm (remove) command is used to delete files and directories. rm removes each file specified on the command line. By default, it does not remove directories. When used recursively, it may be used to delete directories.

By default, it does not remove directories and it only works on files in its default settings. If the -r/-R/–recursive option is specified, however, rm will remove any matching directories and their contents. If the specified directory is empty, it may be removed with the -d/–dir option, instead.

Deleting using rm command

To delete a folder we can use the following command syntax:

rm -r -f /path/to/folder/

Here:

  • -f: A strong option. Never prompt for nonexistent files or arguments.
    -r: Recursively remove directories and their contents
  • You can use the -v option alongwith the command to see verbose outputs. For using the verbos eoutput, you can use the same command in the following syntax:
rm -rfv /path/to/folder/

Remove Files Older Than 30 Days In Linux

If you want to delete files created or modified on the last day, which is last 24 hours, you can use the following command – use find with the -delete option.

Note that in the following command, 1 denotes the number of days, and the minus (-) symbol denotes files created or modified before the said number of days (1 day in our example).

find /path/to/directory -type f -mtime +30 -delete
  • /path/to/directory: Replace this with the actual path to the folder where you want to delete files.
  • -type f: This ensures that only files are to be deleted, not directories or any other file types.
  • -mtime +30: This finds files that were last modified more than 30 full 24-hour periods ago.
  • -delete: This tells find to remove the matched files.

NOTE:

  • Note that if -delete is not available on your system, or for other reasons, you can use -exec or xargs.
  • You can use a plus symbol (instead of minus symbol) to remove files created or modified before a day, before 24 hours.

Primary Sidebar

Latest Posts

Best AI Plugins For WordPress To Use In 2026

3 Commands To Check USB Connection In Linux Terminal

Linux Terminal Commands for Beginners With Examples

How To Password Protect A Folder In Linux Command Line

Best Download Managers for Ubuntu Linux (2026 Edition)

5 Best Free Keyword Research Tools for Bloggers in 2026

How To Check Linux 32 or 64-Bit Command Line

How To Delete And Remove Repository In Ubuntu Terminal

Fix Unexpected Inconsistency By Running Fsck Manually From Initramfs

Install and Use GitHub Desktop on Ubuntu Linux

© 2026 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap