In this article i discussed various commands used in Linux operating system to delete a files and Directories via Terminal.

lets assume this is the sample directory which is i am going to use for demonstration and I am working on Ubuntu 10.04 Linux.
vividvilla@ubuntu:~/techiestuffs$ ls
dir1 dir2 file1
vividvilla@ubuntu:~/techiestuffs$ cd dir2
vividvilla@ubuntu:~/techiestuffs/dir2$ ls

where dir1 is a empty directory and dire2 contains a file called file2 and file1 is a textfile.

To remove a Empty directory

$ rmdir dir1
now if you try to use this same command for deleting a directory dir2 which contains some files.
$ rmdir dir2
rmdir: failed to remove `dir2': Directory not empty

you will get an error,so you cant use rmdir command for deleting a nonempty you need an alternate command

Recursive Removal of a Directory

$ rm -rf dir2
this will successfully delete directory dir2

To delete files

$ rm [file-name]
for example
$ rm file1
or you can delete the file forcefully using this command
$ rm -f file1
and finally some commands which you should not use in any case.
$ rm -rf /
$ rm -rf *

Above two commands will completely delete all files on your computer if executed.