Linux: Deleting Directory Using Rmdir Or Rm Command
For a Linux new learning, if you know how to create a directory in linux operating system, then you should also know that how to delete or remove directory. this post will guide linux newbie to remove directory in command line interface under linux.
Delete Direcotry Using Rmdir command
The syntax is as followss:
rm [options] <dirname>
Let’s see a sample deleting a directory named as “testdir” under /home/adir directory. issue the following command:
rmdir /home/dir/testdir
Output:
[root@devops ~]# rmdir /home/adir/testdir [root@devops ~]# ls /home/adir aa
Deleting Directory Using Rm Command
The above command “rmdir” just used to remove empty directories, if you want to remove all files and directories under that directory, then you need to use rm command with “-rf” option. issue the following command:
rm -rf /home/adir/testdir
Output:
[root@devops adir]# ls testdir/ testdir2 [root@devops adir]# rm -rf testdir/ [root@devops adir]# ls aa
Done….