Tuesday, February 1, 2011

HOW TO REMOVE A DIRECTORY OR FILE


To Remove a Directory 
To remove a directory, in Redhat Linux , use the rmdir <directory name> command. To delete a directory within the current working directory,  use “rmdir <directory name>” and press enter key.  To remove a directory which is not present within the current directory, Use full path to the directory. If the directory is not empty, the error message “Directory Not Empty” will be displayed and it will not remove the directory.  

But you can force the removal of the directory with the files and subdirectories within that directory. To do so, execute “rm –rf<directory name>” command.  
Caution: This Command will not ask you to confirm the deletion. And there is no way to undo the removal of the files and directories. So before executing this command, extreme caution should be used.

To Remove a File 
To remove a file, use the “rm <file name>” command. To remove a file in current working directory, you need to just enter the file name after the “rm” command. Or else you can enter the full path to the file. For example, I need to remove a file named “example.odt”  which is in /home/jofin/    directory, then I   have to enter the command as rm /home/jofin/example.odt.