LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-28-2015, 07:22 AM   #1
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 211

Rep: Reputation: 8
rmdir -r


hi guys, im trying to get rid of a non empty directory. i have researched it online and it basically says that the command would be sudo rmdir -r filename
it keeps coming back with invalid option for r

what am i doing wrong?

the directory is in the home directory along with the documents, videos, download etc and i am in the home directory. i tried putting a text file there to make sure i am in the right path and it deleted it with rm so the path is correct.

i understand that i can do it with the gui but im trying to learn the terminal for the next forty years.

any suggestions would be greatly appreciated.
 
Old 04-28-2015, 07:31 AM   #2
kmhuntly
Member
 
Registered: Mar 2015
Location: Cheektowaga, NY
Distribution: ArchLinux
Posts: 34

Rep: Reputation: 7
...man rmdir?
 
1 members found this post helpful.
Old 04-28-2015, 07:36 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,121

Rep: Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270
rmdir is only for emtpy dirs. use rm -rf for non-empty dirs, but take care about it because you can easily destroy anything with that command. I mean really everything, even your linux may become useless.
 
1 members found this post helpful.
Old 04-28-2015, 07:52 AM   #4
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,453
Blog Entries: 55

Rep: Reputation: Disabled
Or try:
Code:
rm directoryname/*
then:
Code:
rmdir directoryname
 
1 members found this post helpful.
Old 04-28-2015, 07:55 AM   #5
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 211

Original Poster
Rep: Reputation: 8
just for the sake of my ongoing terminal education..... when you say 'try' this..... does that mean there are no guaranteed ways of achieving this task or are you just saying 'try this' as a figure of speech?
 
Old 04-28-2015, 07:59 AM   #6
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 211

Original Poster
Rep: Reputation: 8
it keeps telling me that r is an invalid option????? why would it say that? rmdir -rf comes back with invalid option?

---------- Post added 04-28-15 at 08:00 AM ----------

theres nothing in man rmdir that removes non empty directories
 
Old 04-28-2015, 08:05 AM   #7
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 211

Original Poster
Rep: Reputation: 8
ive tried everything and so far nothing works.
there are other directories inside the one im trying to rm but i thought rmdir -r would take care of all of that or at least rmdir -rf
is this a sudo thing? let me try that
 
Old 04-28-2015, 08:06 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154Reputation: 3154
@dunnery, please read the manual ...
http://man7.org/linux/man-pages/man2/rmdir.2.html

... There are no options for 'rmdir' !

* You can use $ rm -r directoryname
http://man7.org/linux/man-pages/man1/rm.1.html


-
 
1 members found this post helpful.
Old 04-28-2015, 08:06 AM   #9
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 211

Original Poster
Rep: Reputation: 8
wow, everything i try just says r is an invalid option. do you think my system is corrupt or damaged?
 
Old 04-28-2015, 08:12 AM   #10
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 211

Original Poster
Rep: Reputation: 8
yyeeeeeeeeeeeessssssssssss
thank you. it was rm -rf filename
oh man. what a dweeb i am.
thank you to everyone for all your help.
 
Old 04-28-2015, 08:25 AM   #11
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,453
Blog Entries: 55

Rep: Reputation: Disabled
Quote:
Originally Posted by dunnery View Post
just for the sake of my ongoing terminal education..... when you say 'try' this..... does that mean there are no guaranteed ways of achieving this task or are you just saying 'try this' as a figure of speech?
I meant: 'see if this works'. It's worked for me in the past.
 
Old 04-28-2015, 09:31 AM   #12
JeremyBoden
Member
 
Registered: Nov 2011
Posts: 939

Rep: Reputation: 174Reputation: 174
There are ways of setting up a system to stop people from using rm -r

It's quite a dangerous command for those with an exaggerated view of their own capabilities...

Personally, I usually tend to use the GUI file manager to do this kind of thing.

Last edited by JeremyBoden; 04-28-2015 at 09:32 AM.
 
Old 04-28-2015, 08:30 PM   #13
jaydul
Member
 
Registered: Sep 2012
Posts: 48

Rep: Reputation: Disabled
Also, I suggest you you never do "rm -rf *", but to be more sure, do

"rm -rf /path/to/dir/"

Remove file/Clean file and folder from Linux
[tuhin@localhost ~]$ rm -rf

Note: The rm command, especially with the -rf parameter, is dangerous. It recursively
removes an entire directory without stopping to verify any of the files. It is especially
potent when run by the root user


http://www.linux-inc.com/article/how...ory-linux.html
 
1 members found this post helpful.
Old 04-29-2015, 06:45 AM   #14
dunnery
Member
 
Registered: May 2010
Location: East Stroudsburg
Distribution: Debian Jessie
Posts: 211

Original Poster
Rep: Reputation: 8
thank you, i will be very aware of that in the future
 
  


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
rmdir not rm'ing lumix Linux - General 4 03-29-2007 10:24 PM
i deleted rmdir jzocco Linux - Newbie 13 04-12-2006 01:19 PM
Rmdir .. not emtpy ??? waelaltaqi Linux - Software 6 11-04-2005 12:28 PM
rmdir namit Linux - Software 2 10-23-2005 03:26 PM
rmdir Fatal_3rr0r Linux - General 3 06-23-2003 05:25 PM


All times are GMT -5. The time now is 10:21 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration