×

This article covers how to use the rm command in Linux. In fact, the rm command is used for removing/deleting files and directories.


How to remove directories using rm command?

If you are trying to remove a directory, then you need to use the -r command line option. Otherwise, rm will throw an error saying what you are trying to delete is a directory:

$ rm -r [dir name]

For example:

$ rm -r testdir


How to make rm prompt before every removal ?

If you want rm to prompt before each delete action it performs, then use the -i command line option: 

$ rm -i [file or dir]

For example, suppose you want to delete a directory 'testdir' and all its contents, but want rm to prompt before every deletion, then here's how you can do that:

$ rm -r -i testdir



This article will guide you on how to delete files on Linux operating systems.




More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com