SlideShare a Scribd company logo
1 of 11
Download to read offline
How to Delete/Remove a Directory in Linux? -
Hostbillo
Introduction
Understanding the core Linux commands is essential for server management
because Linux is a widely used operating system for hosting services. Across all
Linux individuals and system admins, understanding how to operate the Linux
command line is an urgent requirement. It allows you to perform basic
maintenance operations like making new files, accessing certain folders, and
relocating existing ones.
In this post, we'll demonstrate how to remove a directory in Linux command
line to delete files and directories.
System Requirements
Before beginning, you must be aware of the following predetermined
requirements:
● A Linux-based system.
● A sudo-privileged user account.
● the possibility to use the command line and terminal window.
How to Remove Directory in Linux?
You can delete a directory from the command line as well as the terminal
window using one of the following remove a directory in Linux commands:
● When using the rm command, all files and subdirectories in a directory
get deleted completely.
● By using the rmdir command, empty directories get deleted.
The rm and rmdir commands do not relocate directories to the Trash directory;
instead, they permanently destroy them. This would be vital to remember. It
follows that executing these commands will not allow you to restore a directory
that gets deleted.
Delete a Directory in Linux using rmdir Command
Linux has a command called rm that attempts to undermine directories and files.
It adopts the following syntax:
rm [options] [Name of a file or directory]
There are various rm command parameters, including:
● Removes all directories or files with the -f option.
● Before uninstalling, the -i option asks for authorization.
● When deleting over three files or performing a recursive deletion, the -I
option prompts the user once.
● The -r option recursively deletes folders and their contents.
● -d: Deletes empty folders.
● A verbose output gets provided via the -v option.
● —help: Makes the help text visible.
● —version: Indicates the command version.
When attempting to delete a directory in Linux with the rm command with no
parameters, the following message appears:
By adding the -d parameter to the rm command, you can delete an empty
directory:
Example: rm –d
To remove a directory that includes files and subdirectories, utilize -r flag. It has
many text files in the Dir1 & Dir2 subdirectories:
In contrast to the -v flag, which produces a list of every stage of the procedure,
the -r flag deletes the complete directory, with subdirectories and files:
Example: rm -r –v
You get prompted to confirm the removal of the directory when using the -i
option. Enter after typing Y to verify.
Example: rm -d –i
If a directory is write-protected, it cannot get deleted automatically. Within this
type of directory, include:
Example: sudo mkdir
Utilize the following commands to know how to delete the directory:
Example: rm -d
To confirm removal, type Y. Use the -f switch or give the command sudo-level
access to omit the confirmation:
Example: rm -d -f
Example: sudo rm -d
By using the command prompt whether other files and directories are present
inside the write-protected directory:
rm -rf <directory name>
Remove a Directory in Linux using the rm Command
All empty directories can get deleted with the Linux rmdir command. This
command seems to have the following format:
rmdir [options] [directory name]
These choices are available with the rmdir command in Linux:
● When trying to delete a non-empty directory, the option —ignore failure
on non-empty doesn't display an error message.
● -p: Erases the hierarchy's parent directory together with the working
directory.
● -v: Produces output that is verbose.
● —help: Provides a help message.
● —version: Shows the versions of the command.
A non-empty directory causes an error when the rmdir command gets used on
it. Therefore in this instance, the Test subdirectory gets found under the
Example directory:
Adding them in the opposite order of the hierarchy will allow you to delete
them using the rmdir command. The -v option's output gives an outline of each
stage in the process:
rmdir -v Example/Test Example
The -p parameter along with the name of the subfolder makes this process
easier. With this, the subdirectory's hierarchical parent is also removed:
rmdir -p -v Example/Test
Utilizing wildcards, you can execute the rmdir command to eliminate several
directories with similar titles. To delete, for reference, the directories Example1,
Example2, or Example3:
rmdir -v Example*
Cautionary Measures (Discuss the importance of taking caution
when removing directories and Explain how to prevent
accidental removal of directories)
Due to the lack of a recycle bin as well as a trash folder, files and folders in the
Linux system are permanently erased. Linux only allows you to restore
accidentally deleted files and directories from backups.
As it only functions for empty directories, using rmdir command in Linux
minimizes these unpleasant effects. If there are files in the folder, it will give
you the following error code:
rmdir: failed to delete ‘Directory’: Folder not empty
The rmdir function has the following syntax:
rmdir [option] Directory Name
To avoid using a command line parameter, delete it from the syntax. Don't
forget that the command line considers the case. To avoid confusion, enter the
folder name in uppercase if that's the case.
For instance, the following command removes the Simple-Directory folder:
rmdir Simple-Directory
Moreover, the rmdir command support various empty directories. On Linux,
you can remove all files in a directory by including the rmdir in the command
via extra arguments.
rmdir Directory 1 Directory 2 Directory 3
So let's look at several parameters for the rmdir command. A subdirectory or its
parent directory can get deleted with the first option, -p. Use the rmdir
command in Linux below if your directory path, for instance, is
/Directory/SubDirectory:
rmdir -p /Directory/SubDirectory
On the Directory path, the above command will start by deleting the
SubDirectory folder. Following the removal of the SubDirectory, the Directory
folder will get erased if it is empty.
The -v command prompt parameter specifies the verbose option, and it
represents the next choice. To confirm the removal of the chosen directory, this
parameter will print a text. An example of this command is below:
rmdir -v Simple-Directory
It will appear in the output message:
RMDIR: 'Simple-Directory' removal of a directory
Conclusion
Using the rm or rmdir commands in Linux correctly is necessary to delete
files and directory structures in Linux. The difference between the two
commands is that the rm command removes files or non-empty directories, but
the rmdir command removes just empty folders.
Keep in mind that Linux does not have a recycle bin/trash folder. By utilizing
the command line, you can permanently delete directories and files. Because of
this, use caution while using these commands or make a backup before
removing any content on your hosting server. After going through this tutorial,
you will be able to use the terminal window and perhaps the command line to
delete directories in Linux.

More Related Content

Similar to How to Delete_Remove a Directory in Linux.pdf

linux commands.pdf
linux commands.pdflinux commands.pdf
linux commands.pdfamitkamble79
 
Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3Gourav Varma
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unixsouthees
 
CMD Command prompts
CMD Command promptsCMD Command prompts
CMD Command promptsAhmed Hesham
 
Introduction to the linux command line.pdf
Introduction to the linux command line.pdfIntroduction to the linux command line.pdf
Introduction to the linux command line.pdfCesleySCruz
 
Lab 3 -Linux Files, Directories and Basic Commands.pptx
Lab 3 -Linux Files, Directories and Basic Commands.pptxLab 3 -Linux Files, Directories and Basic Commands.pptx
Lab 3 -Linux Files, Directories and Basic Commands.pptxCiceer Ghimirey
 
Lab 3 -Linux Files, Directories and Basic Commands.pptx
Lab 3 -Linux Files, Directories and Basic Commands.pptxLab 3 -Linux Files, Directories and Basic Commands.pptx
Lab 3 -Linux Files, Directories and Basic Commands.pptxCiceer Ghimirey
 
101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystemsAcácio Oliveira
 

Similar to How to Delete_Remove a Directory in Linux.pdf (20)

linux commands.pdf
linux commands.pdflinux commands.pdf
linux commands.pdf
 
Introduction to linux day-3
Introduction to linux day-3Introduction to linux day-3
Introduction to linux day-3
 
linux cmds.pptx
linux cmds.pptxlinux cmds.pptx
linux cmds.pptx
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Lec05
Lec05Lec05
Lec05
 
CMD Command prompts
CMD Command promptsCMD Command prompts
CMD Command prompts
 
Dos 16
Dos 16Dos 16
Dos 16
 
Introduction to the linux command line.pdf
Introduction to the linux command line.pdfIntroduction to the linux command line.pdf
Introduction to the linux command line.pdf
 
Lab 3 -Linux Files, Directories and Basic Commands.pptx
Lab 3 -Linux Files, Directories and Basic Commands.pptxLab 3 -Linux Files, Directories and Basic Commands.pptx
Lab 3 -Linux Files, Directories and Basic Commands.pptx
 
Lab 3 -Linux Files, Directories and Basic Commands.pptx
Lab 3 -Linux Files, Directories and Basic Commands.pptxLab 3 -Linux Files, Directories and Basic Commands.pptx
Lab 3 -Linux Files, Directories and Basic Commands.pptx
 
L1 msdos primer
L1 msdos primerL1 msdos primer
L1 msdos primer
 
101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 

Recently uploaded

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceIES VE
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 

How to Delete_Remove a Directory in Linux.pdf

  • 1. How to Delete/Remove a Directory in Linux? - Hostbillo Introduction Understanding the core Linux commands is essential for server management because Linux is a widely used operating system for hosting services. Across all Linux individuals and system admins, understanding how to operate the Linux command line is an urgent requirement. It allows you to perform basic maintenance operations like making new files, accessing certain folders, and relocating existing ones. In this post, we'll demonstrate how to remove a directory in Linux command line to delete files and directories. System Requirements
  • 2. Before beginning, you must be aware of the following predetermined requirements: ● A Linux-based system. ● A sudo-privileged user account. ● the possibility to use the command line and terminal window. How to Remove Directory in Linux? You can delete a directory from the command line as well as the terminal window using one of the following remove a directory in Linux commands: ● When using the rm command, all files and subdirectories in a directory get deleted completely. ● By using the rmdir command, empty directories get deleted. The rm and rmdir commands do not relocate directories to the Trash directory; instead, they permanently destroy them. This would be vital to remember. It follows that executing these commands will not allow you to restore a directory that gets deleted. Delete a Directory in Linux using rmdir Command Linux has a command called rm that attempts to undermine directories and files. It adopts the following syntax: rm [options] [Name of a file or directory] There are various rm command parameters, including:
  • 3. ● Removes all directories or files with the -f option. ● Before uninstalling, the -i option asks for authorization. ● When deleting over three files or performing a recursive deletion, the -I option prompts the user once. ● The -r option recursively deletes folders and their contents. ● -d: Deletes empty folders. ● A verbose output gets provided via the -v option. ● —help: Makes the help text visible. ● —version: Indicates the command version. When attempting to delete a directory in Linux with the rm command with no parameters, the following message appears: By adding the -d parameter to the rm command, you can delete an empty directory: Example: rm –d To remove a directory that includes files and subdirectories, utilize -r flag. It has many text files in the Dir1 & Dir2 subdirectories: In contrast to the -v flag, which produces a list of every stage of the procedure, the -r flag deletes the complete directory, with subdirectories and files: Example: rm -r –v
  • 4. You get prompted to confirm the removal of the directory when using the -i option. Enter after typing Y to verify. Example: rm -d –i If a directory is write-protected, it cannot get deleted automatically. Within this type of directory, include: Example: sudo mkdir Utilize the following commands to know how to delete the directory: Example: rm -d
  • 5. To confirm removal, type Y. Use the -f switch or give the command sudo-level access to omit the confirmation: Example: rm -d -f Example: sudo rm -d By using the command prompt whether other files and directories are present inside the write-protected directory: rm -rf <directory name> Remove a Directory in Linux using the rm Command All empty directories can get deleted with the Linux rmdir command. This command seems to have the following format: rmdir [options] [directory name]
  • 6. These choices are available with the rmdir command in Linux: ● When trying to delete a non-empty directory, the option —ignore failure on non-empty doesn't display an error message. ● -p: Erases the hierarchy's parent directory together with the working directory. ● -v: Produces output that is verbose. ● —help: Provides a help message. ● —version: Shows the versions of the command. A non-empty directory causes an error when the rmdir command gets used on it. Therefore in this instance, the Test subdirectory gets found under the Example directory: Adding them in the opposite order of the hierarchy will allow you to delete them using the rmdir command. The -v option's output gives an outline of each stage in the process: rmdir -v Example/Test Example The -p parameter along with the name of the subfolder makes this process easier. With this, the subdirectory's hierarchical parent is also removed:
  • 7. rmdir -p -v Example/Test Utilizing wildcards, you can execute the rmdir command to eliminate several directories with similar titles. To delete, for reference, the directories Example1, Example2, or Example3: rmdir -v Example*
  • 8. Cautionary Measures (Discuss the importance of taking caution when removing directories and Explain how to prevent accidental removal of directories) Due to the lack of a recycle bin as well as a trash folder, files and folders in the Linux system are permanently erased. Linux only allows you to restore accidentally deleted files and directories from backups. As it only functions for empty directories, using rmdir command in Linux minimizes these unpleasant effects. If there are files in the folder, it will give you the following error code: rmdir: failed to delete ‘Directory’: Folder not empty The rmdir function has the following syntax: rmdir [option] Directory Name To avoid using a command line parameter, delete it from the syntax. Don't forget that the command line considers the case. To avoid confusion, enter the folder name in uppercase if that's the case. For instance, the following command removes the Simple-Directory folder: rmdir Simple-Directory
  • 9. Moreover, the rmdir command support various empty directories. On Linux, you can remove all files in a directory by including the rmdir in the command via extra arguments. rmdir Directory 1 Directory 2 Directory 3 So let's look at several parameters for the rmdir command. A subdirectory or its parent directory can get deleted with the first option, -p. Use the rmdir command in Linux below if your directory path, for instance, is /Directory/SubDirectory: rmdir -p /Directory/SubDirectory
  • 10. On the Directory path, the above command will start by deleting the SubDirectory folder. Following the removal of the SubDirectory, the Directory folder will get erased if it is empty. The -v command prompt parameter specifies the verbose option, and it represents the next choice. To confirm the removal of the chosen directory, this parameter will print a text. An example of this command is below: rmdir -v Simple-Directory It will appear in the output message: RMDIR: 'Simple-Directory' removal of a directory Conclusion
  • 11. Using the rm or rmdir commands in Linux correctly is necessary to delete files and directory structures in Linux. The difference between the two commands is that the rm command removes files or non-empty directories, but the rmdir command removes just empty folders. Keep in mind that Linux does not have a recycle bin/trash folder. By utilizing the command line, you can permanently delete directories and files. Because of this, use caution while using these commands or make a backup before removing any content on your hosting server. After going through this tutorial, you will be able to use the terminal window and perhaps the command line to delete directories in Linux.