LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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

Reply
 
Search this Thread
Old 02-16-2005, 09:57 AM   #1
anindyanuri
Member
 
Registered: Jan 2005
Location: India
Distribution: Kubuntu Gutsy
Posts: 449

Rep: Reputation: 30
Question What is the command to delete a file in linux terminal


Using terminal what is the command I should apply to delete a file?
 
Old 02-16-2005, 10:02 AM   #2
Lleb_KCir
Senior Member
 
Registered: Nov 2003
Location: Orlando FL
Distribution: Debian
Posts: 1,765

Rep: Reputation: 45
rm file_name

or rm -r (if you want to delete a directory)
 
Old 02-16-2005, 10:14 AM   #3
anindyanuri
Member
 
Registered: Jan 2005
Location: India
Distribution: Kubuntu Gutsy
Posts: 449

Original Poster
Rep: Reputation: 30
thank you friend a lot. may you tell me please what rm stands for?
 
Old 02-16-2005, 10:16 AM   #4
anindyanuri
Member
 
Registered: Jan 2005
Location: India
Distribution: Kubuntu Gutsy
Posts: 449

Original Poster
Rep: Reputation: 30
to remove a complete dir we use rmdir but you told that rm -r. is rm - r is equivalent to deltree in windows?
 
Old 02-16-2005, 10:21 AM   #5
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
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"
 
Old 02-16-2005, 11:11 AM   #6
q_dmc12
LQ Newbie
 
Registered: Feb 2005
Location: Adirondacks
Distribution: Phat Linux (sept. 22, 2002 release);Current OS - WinXP SP2
Posts: 9

Rep: Reputation: 0
Erase <filename>

try typing help at CLI (command line interface)
 
Old 02-17-2005, 09:49 AM   #7
trevelluk
Member
 
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388

Rep: Reputation: 32
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.
 
Old 02-17-2005, 10:07 AM   #8
anindyanuri
Member
 
Registered: Jan 2005
Location: India
Distribution: Kubuntu Gutsy
Posts: 449

Original Poster
Rep: Reputation: 30
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?
 
Old 02-17-2005, 10:18 AM   #9
trevelluk
Member
 
Registered: Nov 2003
Location: Bristol, UK
Distribution: Debian Lenny, Gentoo (at work)
Posts: 388

Rep: Reputation: 32
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
 
Old 02-17-2005, 11:08 AM   #10
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 30
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.
 
Old 02-17-2005, 07:33 PM   #11
anindyanuri
Member
 
Registered: Jan 2005
Location: India
Distribution: Kubuntu Gutsy
Posts: 449

Original Poster
Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete via Terminal BarfBag Suse/Novell 1 10-13-2005 10:21 AM
Closing a port in linux terminal..any command?? fhameed Linux - Security 1 07-20-2004 11:46 PM
Tried to delete file as root but it says I don't have permission to delete it! beejayzed Mandriva 23 03-12-2004 02:46 AM
vi won't backspace or delete in terminal JamesM Linux - Software 1 08-18-2003 09:06 AM
ha ha i forgot command how to delete file tarak4u Linux - General 2 05-16-2002 01:14 AM


All times are GMT -5. The time now is 03:46 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration