• 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 / How To / Delete Directory And Contents Recursively Without Prompt On Linux

Delete Directory And Contents Recursively Without Prompt On Linux

By Sourabh / May 13, 2026 Category: How To, Ubuntu

Which is the Linux command to delete all files in a folder recursively? On Ubuntu, how to remove all files and folders in current directory?

rm Command To Remove All Files In A Directory

To remove empty directories only, you can use the rm command with the -d flag or rmdir command:

$ rm -d DIRECTORY_NAME

OR

$ rmdir DIRECTORY_NAME

Note that this command will only work to remove an empty directory and if the directory still contains files or subdirectories, the rmdir command does not remove the directory.

In such case, to remove a directory and all its contents, including any subdirectories and files, you will have to use the rm command with the recursive option, which is -r (short for recursive):

$ rm -r directory

NOTE: When trying to remove a read-only directory, the rm command will produce the error message “rm: cannot remove ‘DIRECTORY_NAME’: Permission denied”.

To delete read-only directory, you will either have to change its permissions using the chmod command, or you can use the -f with the -r flag (force and recursive), which will then delete/remove the read-only directory it without any prompt for confirmation.

$ rm -rf directory

Note that you’ll have to use the sudo command to gain administrative privileges in order to delete or remove it.

NOTE: Directories once removed using the rmdir command cannot be recovered and their contents are removed permanently.

Primary Sidebar

Latest Posts

Check User Login History In Ubuntu Linux Command Line

Use Locate Command To Find File In Linux Terminal By Name

How To Change Terminal Color In Ubuntu Command Line

How To Run Fsck Manually In Linux To Fix Unexpected Inconsistency

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

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

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