What is the command to delete a file in linux terminal
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
rm -r is a recursive removal of the directory. It is roughly equivalent to rmdir. "rm" doesn't technically stand for anything, but many linux commands are a shortened form of their action: "remove"
Erm, erase? That's normally DOS only. Although it's possible you've got some sort of unusual setup where it will work.
And just a quick point here on the difference between rm -r and rmdir.
rm -r will delete a directory and all contents. rmdir will only delete empty directories.
yes trevelluk........i just interested to know the clear difference between rmdir and rm -r. thank you very much friend.
you may also have observed that i referred deltree from windows.
get your point clearly. you mean to say rm -r is exactly similar to deltree (in windows). and rmdir is similar to rmdir or rd (in windows/dos). am i correct?
now the million doller question is that.......do i have to confirm with "y/n" option if i use rm -r (as we have to in dos) or it directly remove all the contents with the directory without any warning?
OK, I'm not really that familiar with DOS commands. It's been a long time since I've been near the things
Regarding confirmation: rm -r will delete most files without any need for confirmation. If one of the files isn't writeable, you will be prompted. To automatically delete this as well without prompting, use rm -rf
For more info, type man rm (man <command>) will display the electronic manual page for that command. This is your friend
Well, rm could ask confirmation or not, it depends on the distribution, I think. Tested several of them, in some cases the user profiles are created with an alias to rm, so it asks for confirmation every time, while in others it doesn't.
Personally, I create the alias in such a way that rm asks me. If i don't want to be bothered, just run "\rm ...".
About the differences with rmdir, I think this does not removes the directory unless it is empty. I don't know if there is a parameter like -f for rm to force the action.
Thank you friends for your suggestions. I have learnt a lot from your discussions. I am a newbie and that is why my questions are like newbies. If I get into another problem I shall be asking all your help in the forum. Thank you again.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.