Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
rmdir
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
defkewl
Tux's lil' helper
Tux's lil' helper


Joined: 08 Feb 2005
Posts: 75
Location: Indonesia

PostPosted: Mon Feb 14, 2005 5:57 am    Post subject: rmdir Reply with quote

Hi there,

How do I remove a directory from command line interface if the directory is not empty?
I've tried looking for source on the net but could not find it.

Thnx in advance
_________________
Not all things in life need reasoning
Visit my blog
Back to top
View user's profile Send private message
tdemarest
Tux's lil' helper
Tux's lil' helper


Joined: 18 Mar 2003
Posts: 99
Location: California, USA

PostPosted: Mon Feb 14, 2005 6:16 am    Post subject: Reply with quote

Code:

rm -fr <directory>


From the man page:

Code:

       -f     Do not prompt for confirmation. Do not write diagnostic messages.  Do not produce an error return status if  the  only  errors
              were nonexisting files.

       -i     Prompt for confirmation.  (In case both -f and -i are given, the last one given takes effect.)

       -r or -R
              Recursively remove directory trees.
Back to top
View user's profile Send private message
Lokheed
Veteran
Veteran


Joined: 12 Jul 2004
Posts: 1295
Location: /usr/src/linux

PostPosted: Mon Feb 14, 2005 6:55 am    Post subject: Reply with quote

You dont need the f. A simple "rm -r /path/to/directory" is sufficient and wont prompt you.
Back to top
View user's profile Send private message
TrueDFX
Retired Dev
Retired Dev


Joined: 02 Jun 2004
Posts: 1348

PostPosted: Mon Feb 14, 2005 8:05 am    Post subject: Reply with quote

Lokheed wrote:
You dont need the f. A simple "rm -r /path/to/directory" is sufficient and wont prompt you.

It will prompt you if any files in that directory are not writable.
Back to top
View user's profile Send private message
etnoy
Apprentice
Apprentice


Joined: 29 Aug 2003
Posts: 255
Location: Västerås, Sweden

PostPosted: Mon Feb 14, 2005 8:20 am    Post subject: Reply with quote

Remember that rm -r is very powerful. A wrong command as root could _WIPE_ your system. Use rm -r with extreme caution and use rmdir to delete directories you know are empty.
_________________
The md5sum of the above post is 06280ccd85ef9deb49c336e7945f4b5c

God is dead! - Nietzsche
Nietzsche is dead! -God
Back to top
View user's profile Send private message
curtis119
Bodhisattva
Bodhisattva


Joined: 10 Mar 2003
Posts: 2160
Location: Toledo, Ohio,USA, North America, Earth, SOL System, Milky Way, The Universe, The Cosmos, and Beyond.

PostPosted: Tue Feb 15, 2005 11:56 pm    Post subject: Reply with quote

TrueDFX wrote:
Lokheed wrote:
You dont need the f. A simple "rm -r /path/to/directory" is sufficient and wont prompt you.

It will prompt you if any files in that directory are not writable.


In that case use -R instead of -r. It's the same as -rf
_________________
Gentoo: it's like wiping your ass with silk.
Back to top
View user's profile Send private message
TrueDFX
Retired Dev
Retired Dev


Joined: 02 Jun 2004
Posts: 1348

PostPosted: Wed Feb 16, 2005 3:34 am    Post subject: Reply with quote

curtis119 wrote:
In that case use -R instead of -r. It's the same as -rf
Code:
$ mkdir dir; touch dir/file; chmod -w dir/file; rm -R dir
rm: remove write-protected regular empty file `dir/file'?
Back to top
View user's profile Send private message
curtis119
Bodhisattva
Bodhisattva


Joined: 10 Mar 2003
Posts: 2160
Location: Toledo, Ohio,USA, North America, Earth, SOL System, Milky Way, The Universe, The Cosmos, and Beyond.

PostPosted: Wed Feb 16, 2005 3:54 am    Post subject: Reply with quote

TrueDFX wrote:
curtis119 wrote:
In that case use -R instead of -r. It's the same as -rf
Code:
$ mkdir dir; touch dir/file; chmod -w dir/file; rm -R dir
rm: remove write-protected regular empty file `dir/file'?


as ROOT

Code:
lapbox ~ # mkdir dir
lapbox ~ # touch dir/file
lapbox ~ # chmod -w dir/file
lapbox ~ # rm -R dir
lapbox ~ #


as NON-ROOT

Code:
mike@lapbox ~ $ mkdir dir
mike@lapbox ~ $ touch dir/file
mike@lapbox ~ $ chmod -w dir/file
mike@lapbox ~ $ rm -R dir
rm: remove write-protected regular empty file `dir/file'? y
mike@lapbox ~ $


Sorry, I should have been more specific.
_________________
Gentoo: it's like wiping your ass with silk.
Back to top
View user's profile Send private message
TrueDFX
Retired Dev
Retired Dev


Joined: 02 Jun 2004
Posts: 1348

PostPosted: Wed Feb 16, 2005 4:32 am    Post subject: Reply with quote

As root,
Code:
# mkdir dir; touch dir/file; chmod -w dir/file; rm -r dir
doesn't prompt either. That's probably because the file's writable, because you're logged in as root.
Back to top
View user's profile Send private message
curtis119
Bodhisattva
Bodhisattva


Joined: 10 Mar 2003
Posts: 2160
Location: Toledo, Ohio,USA, North America, Earth, SOL System, Milky Way, The Universe, The Cosmos, and Beyond.

PostPosted: Wed Feb 16, 2005 4:57 am    Post subject: Reply with quote

TrueDFX wrote:
As root,
Code:
# mkdir dir; touch dir/file; chmod -w dir/file; rm -r dir
doesn't prompt either. That's probably because the file's writable, because you're logged in as root.



hmm, your right. All this time I thought -R was a root specific flag. I've been doing it that way since 1990 or so. You learn something new everyday.
_________________
Gentoo: it's like wiping your ass with silk.
Back to top
View user's profile Send private message
defkewl
Tux's lil' helper
Tux's lil' helper


Joined: 08 Feb 2005
Posts: 75
Location: Indonesia

PostPosted: Wed Feb 16, 2005 3:14 pm    Post subject: Reply with quote

tdemarest wrote:
Code:

rm -fr <directory>


From the man page:

Code:

       -f     Do not prompt for confirmation. Do not write diagnostic messages.  Do not produce an error return status if  the  only  errors
              were nonexisting files.

       -i     Prompt for confirmation.  (In case both -f and -i are given, the last one given takes effect.)

       -r or -R
              Recursively remove directory trees.

Thnx very much. But my man page only list these options:
Code:

    Remove the DIRECTORY(ies), if they are empty.

       --ignore-fail-on-non-empty

              ignore  each  failure that is solely because a directory is non-
              empty

       -p, --parents
              remove DIRECTORY, then try to remove each directory component of
              that  path  name.   E.g.,  ârmdir -p a/b/câ is similar to ârmdir
              a/b/c a/b aâ.

       -v, --verbose
              output a diagnostic for every directory processed

       --help display this help and exit

       --version
              output version information and exit

Why isn't it listed in my manual page? Hmmh. Anyway thnx alot.
_________________
Not all things in life need reasoning
Visit my blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum