Basic Commands in Linux - To delete file and folder

rm
   rm command is used to remove the files. 

rm filename - this will remove the file.

rm oel

rm -i filename - this will prompt before removal.

rm -i owl   
rm: remove regular empty file 'owl'?  

rm -d folder1 - this will remove the empty folder.

rm -d folder

rm -r folder - this will remove the folder with its subdirectories.

rm -r folder

rmdir
     
rmdir folder- this will remove the empty directory.

rmdir  folder

rimdir -p folder/folder1/folder2 -this will remove the folder with its subdirectories.

rm -p folder/folder1/folder2

Comments