mirror of
git://slackware.nl/current.git
synced 2024-12-27 09:59:16 +01:00
75a4a592e5
Mon Apr 25 13:37:00 UTC 2011 Slackware 13.37 x86_64 stable is released! Thanks to everyone who pitched in on this release: the Slackware team, the folks producing upstream code, and linuxquestions.org for providing a great forum for collaboration and testing. The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. Please consider supporting the Slackware project by picking up a copy from store.slackware.com. We're taking pre-orders now, and offer a discount if you sign up for a subscription. As always, thanks to the Slackware community for testing, suggestions, and feedback. :-) Have fun!
189 lines
6.1 KiB
HTML
189 lines
6.1 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org" />
|
|
<title>Deletion: rm and rmdir</title>
|
|
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" />
|
|
<link rel="HOME" title="Slackware Linux Essentials" href="index.html" />
|
|
<link rel="UP" title="Handling Files and Directories" href="file-commands.html" />
|
|
<link rel="PREVIOUS" title="Copy and Move" href="file-commands-copymove.html" />
|
|
<link rel="NEXT" title="Aliasing files with ln" href="file-commands-link.html" />
|
|
<link rel="STYLESHEET" type="text/css" href="docbook.css" />
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
</head>
|
|
<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"
|
|
alink="#0000FF">
|
|
<div class="NAVHEADER">
|
|
<table summary="Header navigation table" width="100%" border="0" cellpadding="0"
|
|
cellspacing="0">
|
|
<tr>
|
|
<th colspan="3" align="center">Slackware Linux Essentials</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td width="10%" align="left" valign="bottom"><a href="file-commands-copymove.html"
|
|
accesskey="P">Prev</a></td>
|
|
<td width="80%" align="center" valign="bottom">Chapter 10 Handling Files and
|
|
Directories</td>
|
|
<td width="10%" align="right" valign="bottom"><a href="file-commands-link.html"
|
|
accesskey="N">Next</a></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<hr align="LEFT" width="100%" />
|
|
</div>
|
|
|
|
<div class="SECT1">
|
|
<h1 class="SECT1"><a id="FILE-COMMANDS-DELETION" name="FILE-COMMANDS-DELETION">10.6
|
|
Deletion: <tt class="COMMAND">rm</tt> and <tt class="COMMAND">rmdir</tt></a></h1>
|
|
|
|
<div class="SECT2">
|
|
<h2 class="SECT2"><a id="AEN3733" name="AEN3733">10.6.1 <tt
|
|
class="COMMAND">rm</tt></a></h2>
|
|
|
|
<p><tt class="COMMAND">rm</tt>(1) removes files and directory trees. DOS users will
|
|
notice the similarity to both the <tt class="COMMAND">del</tt> and <tt
|
|
class="COMMAND">deltree</tt> commands. <tt class="COMMAND">rm</tt> can be very dangerous
|
|
if you do not watch yourself. While it is sometimes possible to retrieve a recently
|
|
deleted file, it can be complicated (and potentially costly) and is beyond the scope of
|
|
this book.</p>
|
|
|
|
<p>To remove a single file, specify its name when you run rm:</p>
|
|
|
|
<table border="0" bgcolor="#E0E0E0" width="100%">
|
|
<tr>
|
|
<td>
|
|
<pre class="SCREEN">
|
|
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">rm file1</kbd>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>If the file has write permissions removed, you may get a permission denied error
|
|
message. To force removal of the file no matter what, pass the <tt
|
|
class="COMMAND">-f</tt> option, like this:</p>
|
|
|
|
<table border="0" bgcolor="#E0E0E0" width="100%">
|
|
<tr>
|
|
<td>
|
|
<pre class="SCREEN">
|
|
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">rm -f file1</kbd>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>To remove an entire directory, you use the <var class="OPTION">-r</var> and <var
|
|
class="OPTION">-f</var> options together. This is a good example of how to delete the
|
|
entire contents of your hard drive. You really don't want to do this. But here's the
|
|
command anyway:</p>
|
|
|
|
<table border="0" bgcolor="#E0E0E0" width="100%">
|
|
<tr>
|
|
<td>
|
|
<pre class="SCREEN">
|
|
<samp class="PROMPT">#</samp> <kbd class="USERINPUT">rm -rf /</kbd>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>Be very careful with <tt class="COMMAND">rm</tt>; you can shoot yourself in the foot.
|
|
There are several command line options, which are discussed in detail in the online
|
|
manual page.</p>
|
|
</div>
|
|
|
|
<div class="SECT2">
|
|
<h2 class="SECT2"><a id="AEN3764" name="AEN3764">10.6.2 <tt
|
|
class="COMMAND">rmdir</tt></a></h2>
|
|
|
|
<p><tt class="COMMAND">rmdir</tt>(1) removes directories from the filesystem. The
|
|
directory must be empty before it can be removed. The syntax is simply:</p>
|
|
|
|
<table border="0" bgcolor="#E0E0E0" width="100%">
|
|
<tr>
|
|
<td>
|
|
<pre class="SCREEN">
|
|
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">rmdir <<var
|
|
class="REPLACEABLE">directory</var>></kbd>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>This example will remove the <tt class="FILENAME">hejaz</tt> subdirectory in the
|
|
current working directory:</p>
|
|
|
|
<table border="0" bgcolor="#E0E0E0" width="100%">
|
|
<tr>
|
|
<td>
|
|
<pre class="SCREEN">
|
|
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">rmdir hejaz</kbd>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>If that directory does not exist, <tt class="COMMAND">rmdir</tt> will tell you. You
|
|
can also specify a full path to a directory to remove, as this example shows:</p>
|
|
|
|
<table border="0" bgcolor="#E0E0E0" width="100%">
|
|
<tr>
|
|
<td>
|
|
<pre class="SCREEN">
|
|
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">rmdir /tmp/hejaz</kbd>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>That example will try to remove the <tt class="FILENAME">hejaz</tt> directory inside
|
|
the <tt class="FILENAME">/tmp</tt> directory.</p>
|
|
|
|
<p>You can also remove a directory and all of its parent directories by passing the <var
|
|
class="OPTION">-p</var> option.</p>
|
|
|
|
<table border="0" bgcolor="#E0E0E0" width="100%">
|
|
<tr>
|
|
<td>
|
|
<pre class="SCREEN">
|
|
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">rmdir -p /tmp/hejaz</kbd>
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>This will first try to remove the <tt class="FILENAME">hejaz</tt> directory inside <tt
|
|
class="FILENAME">/tmp</tt>. If that is successful, it will try to remove <tt
|
|
class="FILENAME">/tmp</tt>. <tt class="COMMAND">rmdir</tt> will continue this until an
|
|
error is encountered or the entire tree specified is removed.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="NAVFOOTER">
|
|
<hr align="LEFT" width="100%" />
|
|
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0"
|
|
cellspacing="0">
|
|
<tr>
|
|
<td width="33%" align="left" valign="top"><a href="file-commands-copymove.html"
|
|
accesskey="P">Prev</a></td>
|
|
<td width="34%" align="center" valign="top"><a href="index.html"
|
|
accesskey="H">Home</a></td>
|
|
<td width="33%" align="right" valign="top"><a href="file-commands-link.html"
|
|
accesskey="N">Next</a></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td width="33%" align="left" valign="top">Copy and Move</td>
|
|
<td width="34%" align="center" valign="top"><a href="file-commands.html"
|
|
accesskey="U">Up</a></td>
|
|
<td width="33%" align="right" valign="top">Aliasing files with <tt
|
|
class="COMMAND">ln</tt></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|