loading

Remove Directory in Linux: How to Delete Files and Folders

Updated at
22/08/2023
Views
2088

In Linux, you can use the `rm` (remove) command to delete files and directories. Here are the steps to remove a directory in Linux:

1. Open a terminal on your Linux system.

2. Navigate to the directory that you want to delete. You can use the `cd` (change directory) command to move to the desired directory.

3. Use the `ls` command to list the contents of the directory. Make sure that you are in the correct directory and that you want to delete all of its contents.

4. To remove a directory and all its contents, use the following command:


rm -r directory_name

Replace "directory_name" with the name of the directory you want to delete. The "-r" option tells the `rm` command to remove the directory recursively, including all its contents.

5. You will be prompted to confirm the deletion. Type "y" and press Enter to confirm.

6. If the deletion is successful, you will not see any output in the terminal.

Note that the `rm` command is a powerful tool and can permanently delete files and directories. Be careful when using it, and make sure that you have selected the correct files and directories to delete.

That's it! Now you know how to remove a directory in Linux using the `rm` command.

YottaSrc footer

why choose us?

Better Pricing, Fast SSD Storage and Real 24/7
Technical Support.

control panel icon
cPanel

Managing Your Site Through CPanel With The Latest Version

security icon
FAST, RELIABLE & SECURE

99.8% Uptime Guarantee.
So Focus On Your Work!

support icon
24/7/365 Support

Day or night, rain or shine,
our team is here for you!

cloud backup icon
Daily Backup

Daily & Weekly Backup.
Your Files Are Safe!