hello guys welcome to the next video on Linux command line tutorial for beginners in this video we will learn how will we can use rmdir command and how we can use RM command in linux so let's get started we will start with rmdir command now this rmdir command we can use to remove the directory or directory structures so let's see how we can use it so you just need to give rmdir command in order to use it and the option you can give so you can just write options here and then the directory name so I will just say there okay so this is how you can use it now for example I will just CD to my desktop for example and then here once again I will create a directory by mkdir command and I will name it as ABC and my directory is created you can see here right so for example I want to remove it so I can just use rmdir command to remove it so just write rmdir and the directory name and press Enter is going to remove your directory now for example you have a directory structure for example I want to create a directory structure for example mkdir a / b /c / d / e for example so this is the directory structure i want to create and for this i need to use - p command right for parents and then + enter and then it is going to create this directory structure or to see this directory structure you can just write LS - capital R and when you press ENTER it is going to show you the directory structure so you can see at the top we have directory and inside directory we have directory and inside directed me we have see and say see we have D and inside D we have e okay so this is the directory structure which we have created now in order to remove it you can just carry the same command for example RM dir and then just give a slash me /c / d / e for example ok and when you give this command it's going to you know remove or try to remove this directory but you can see it hasn't removed this directory actually right and what it does is let's see once again LS - capital R that it hasn't removed this directory it has only removed the top-level directory which is this one which is e directory e right now in order to delete the whole directory structure what you need to do is you need to use this flag which is minus P which we have seen in the last video also for parent right and E is already been deleted with this command without - D so without - P it's going to remove only the top-level directory which is at the top which is e in our case right now in order to remove the whole directory structure you just need to give minus P flag and then press enter is going to remove the whole directory structure for you okay I'm going to clear the terminal and then once again I want to create the same directory structure I want to show you one more thing so what I'm going to do is I'm going to just create this directory structure and in order to execute the previous command you have executed you just need to press up a key or up arrow P and it's going to give you the last command you have executed right and I want to create this directory structure once again and I will press ENTER and creates the directory structure once again and then I will just do LS capital R and you can see the directory structure is created and then there is one command which is this rmdir - P and then for example you want to you know remove the command and see the output okay so you can just give this flag which is for verbose okay so this flag B is called verbose flag and this verbose if you don't know what is verbose verbose refers to the mode or setting that this place or gets extended information so it will give you what's happening in the background the information of all that right and then I will press ENTER and you can see how this rmdir command is working so first of all it has removed the top level which is e directory then D then C then B then a so it works from the top level directory to the you know parent directory you can say okay so if you want to you know display the extended information you can use this V flag with P okay now for example once again I will just give the clear command which will create my terminal and once again I will create this directory structure which is a / b / lee / leave / e and it's going to create it and once again I will give this command which is LS - capital R so our directory structure is created right now for example I want to CD to for example a to the B directory okay so now I am in the B directory okay and here I want to create a file so I will just right cat and I will just say ABC dot txt file I want to create and then I will just give some remnant xed here and I will just press control D to indicate the end of the file and now this B directory contains this ami d c dot txt and this we can verify by once again LS - capital r command and now you can see in our P directory we have ABC dot txt so let me go back to directories above so we are in the desktop so it will you know go one directory back right if you remember how we can use CD then you know how to use this dot dot also right and these double or dot means we want to go one directory ahead or to the parent of the current directory okay so now we are in the desktop and then once again we will give LS - capital R and you can see the directory structure so we have a then we have B directory inside a and inside B directory we have this text file and then C directory you can see so this is the directory structure and once again for example I want to use this rmdir command to remove the directory structure and let's see what happens when I press ENTER it will give me the error in between so it says failed to remove directory a slash B directory does is not empty or directory not empty right and this is due to the fact that if the directory contains a file the rmdir command will not work for that directory so if the directory contains any file you cannot use rmdir command direct right so I will just give this command which is Alice - are once again let's see what it gives so you can see it has deleted the directory II D and C for us because they are empty and removing start from the you know the top level so it has deleted e because it was empty then it has deleted D because it was empty and then it was has deleted C directory because it was empty but when it's trying to em you know delete the B directory it contains a file so it cannot delete this.b directory and that's why this error is coming right so it removes the file in our structure right so you can see at this moment it has given us this problem or error because it's trying to delete the directory but directory contains a file now if the directory contains a file there is another command you can use which is RM command and this command we can use to remove the files and directly directories ok so just give RM and then your directory so now we only have a and b directory because c d e directories are already deleted right and if you want to delete the whole directory structure you just need to give this flag which is minus r and it stands for a recursive ok and we can just add this v flag also for just displaying the information what's happening in the background as we have done with this MK rmdir command right so if you will give this command it's fine but if you want to print the information you can give this V also with you know RM command and press enter and you can see it has removed the text file first and then it has removed the directory structure now you may have observed here that it has only deleted our text file and the B directory because in order to use the RMR you know command you just need to give the parent directory name so you just need to give RM and then minus r and then a would be enough to delete this directory and the child or subdirectory inside this directory or whatever file it contains inside this directory okay so you just need to give the parent directory and nothing else and I have given the parent directory as a /p so it considered the parent directory as this B directory inside a directory so it has only removed the txt file inside B directory and B directory not a directory if you want to remove a just give the parent directory which is a itself and press enter and it's going to remove this directory so this is the brief information about using RM command & RM dir command you can use man pages or you can you know refer to man pages to know about more about these commands okay so I hope you enjoyed this video please rate comment subscribe and bye for now
Video Description: Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux for Software Development 2023 is part of Complete Linux Course: Become a Linux Professional preparation.
The notes and questions for Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux have been prepared according to the Software Development exam syllabus.
Information about Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux covers all important topics for Software Development 2023 Exam.
Find important definitions, questions, notes, meanings, examples, exercises and tests below for Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux.
Video Lecture & Questions for Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux Video Lecture | Complete Linux Course: Become a Linux Professional - Software Development - Software Development full syllabus preparation | Free video for Software Development exam to prepare for Complete Linux Course: Become a Linux Professional.
Information about Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux
Here you can find the meaning of Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux defined & explained in the simplest way possible.
Besides explaining types of Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux theory, EduRev gives you an ample number of questions to practice Linux Command Line Tutorial For Beginners 7 - rm and rmdir commands for linux tests,
examples and also practice Software Development tests.