• 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
Home / Ubuntu / How To Remove Directory And All Subdirectories Without Prompt In Linux

How To Remove Directory And All Subdirectories Without Prompt In Linux

By Sourabh / May 14, 2024 Category: Ubuntu

Linux command to delete and remove directory and all subdirectories and all its content without prompt (without asking). In this tutorial we will learn how to remove directory in Linux even if permission denied.

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/

Delete All Files Recursively

To delete all files recursively, use the rm command with -r option. When executed, the rm command will remove the contents of all types of files.

To get a clear understanding, let us assume we want to delete the FOLDER22 and its contents, including all files and subdirectories. Run the syntax below.

rm -r FOLDER22/

Remove Files by Extension Recursively

To remove all txt files recursively:

find -type f -name '*.' -print -delete

Delete Files Based on Their Modification Or Time of Creation

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

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 -type f -mtime -1 -delete

NOTE: 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

How To Fix Broken Packages On Ubuntu From Terminal

Re Execute The Previous Command In Linux Ubuntu Command Line

How Much RAM Is Needed For Ubuntu PC

How To Find Large Files And Directories In Linux Command Line

How To Use Clear Command History In Linux Terminal

Linux Command To Check RAM Size In Ubuntu Terminal In GB

How To Install Proprietary Drivers In Linux Ubuntu Using Terminal

How To Shutdown Linux With A 15 Minute Delay And Message

Free AI Courses With Certificate For Beginners In India

Best AI Plugins For WordPress To Use In 2026

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

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