Changeset View
Changeset View
Standalone View
Standalone View
head/bin/rm/rm.1
Show All 26 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)rm.1 8.5 (Berkeley) 12/5/94 | .\" @(#)rm.1 8.5 (Berkeley) 12/5/94 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd September 12, 2018 | .Dd November 10, 2018 | ||||
.Dt RM 1 | .Dt RM 1 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm rm , | .Nm rm , | ||||
.Nm unlink | .Nm unlink | ||||
.Nd remove directory entries | .Nd remove directory entries | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.Nm | .Nm | ||||
.Op Fl f | i | .Op Fl f | i | ||||
.Op Fl dIPRrvWx | .Op Fl dIRrvWx | ||||
.Ar | .Ar | ||||
.Nm unlink | .Nm unlink | ||||
.Op Fl - | .Op Fl - | ||||
.Ar file | .Ar file | ||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
The | The | ||||
.Nm | .Nm | ||||
utility attempts to remove the non-directory type files specified on the | utility attempts to remove the non-directory type files specified on the | ||||
Show All 27 Lines | |||||
options. | options. | ||||
.It Fl I | .It Fl I | ||||
Request confirmation once if more than three files are being removed or if a | Request confirmation once if more than three files are being removed or if a | ||||
directory is being recursively removed. | directory is being recursively removed. | ||||
This is a far less intrusive option than | This is a far less intrusive option than | ||||
.Fl i | .Fl i | ||||
yet provides almost the same level of protection against mistakes. | yet provides almost the same level of protection against mistakes. | ||||
.It Fl P | .It Fl P | ||||
Overwrite regular files before deleting them. | This flag has no effect. | ||||
Files are overwritten three times, first with the byte pattern 0xff, | It is kept only for backwards compatibility with | ||||
then 0x00, and then 0xff again, before they are deleted. | .Bx 4.4 Lite2 . | ||||
Files with multiple links will not be overwritten nor deleted | |||||
and a warning will be issued. | |||||
If the | |||||
.Fl f | |||||
option is specified, files with multiple links will also be overwritten | |||||
and deleted. | |||||
No warning will be issued. | |||||
.Pp | |||||
Specifying this flag for a read only file will cause | |||||
.Nm | |||||
to generate an error message and exit. | |||||
The file will not be removed or overwritten. | |||||
.Pp | |||||
N.B.: The | |||||
.Fl P | |||||
flag is not considered a security feature | |||||
.Pq see Sx BUGS . | |||||
.It Fl R | .It Fl R | ||||
Attempt to remove the file hierarchy rooted in each | Attempt to remove the file hierarchy rooted in each | ||||
.Ar file | .Ar file | ||||
argument. | argument. | ||||
The | The | ||||
.Fl R | .Fl R | ||||
option implies the | option implies the | ||||
.Fl d | .Fl d | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
.Dl "rm -- -filename" | .Dl "rm -- -filename" | ||||
.Pp | .Pp | ||||
The same behavior can be obtained by using an absolute or relative | The same behavior can be obtained by using an absolute or relative | ||||
path reference. | path reference. | ||||
For example: | For example: | ||||
.Pp | .Pp | ||||
.Dl "rm /home/user/-filename" | .Dl "rm /home/user/-filename" | ||||
.Dl "rm ./-filename" | .Dl "rm ./-filename" | ||||
.Pp | |||||
When | |||||
.Fl P | |||||
is specified with | |||||
.Fl f | |||||
the file will be overwritten and removed even if it has hard links. | |||||
.Sh EXAMPLES | .Sh EXAMPLES | ||||
Recursively remove all files contained within the | Recursively remove all files contained within the | ||||
.Pa foobar | .Pa foobar | ||||
directory hierarchy: | directory hierarchy: | ||||
.Pp | .Pp | ||||
.Dl $ rm -rf foobar | .Dl $ rm -rf foobar | ||||
.Pp | .Pp | ||||
Any of these commands will remove the file | Any of these commands will remove the file | ||||
Show All 13 Lines | |||||
The | The | ||||
.Fl v | .Fl v | ||||
option is non-standard and its use in scripts is not recommended. | option is non-standard and its use in scripts is not recommended. | ||||
.Pp | .Pp | ||||
Also, historical | Also, historical | ||||
.Bx | .Bx | ||||
implementations prompted on the standard output, | implementations prompted on the standard output, | ||||
not the standard error output. | not the standard error output. | ||||
.Pp | |||||
The | |||||
.Fl P | |||||
option does not have any effect as of | |||||
.Fx 13 | |||||
and may be removed in the future. | |||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr chflags 1 , | .Xr chflags 1 , | ||||
.Xr rmdir 1 , | .Xr rmdir 1 , | ||||
.Xr undelete 2 , | .Xr undelete 2 , | ||||
.Xr unlink 2 , | .Xr unlink 2 , | ||||
.Xr fts 3 , | .Xr fts 3 , | ||||
.Xr getopt 3 , | .Xr getopt 3 , | ||||
.Xr symlink 7 | .Xr symlink 7 | ||||
.Sh STANDARDS | .Sh STANDARDS | ||||
The | The | ||||
.Nm | .Nm | ||||
command conforms to | command conforms to | ||||
.St -p1003.1-2013 . | .St -p1003.1-2013 . | ||||
.Pp | .Pp | ||||
The simplified | The simplified | ||||
.Nm unlink | .Nm unlink | ||||
command conforms to | command conforms to | ||||
.St -susv2 . | .St -susv2 . | ||||
.Sh HISTORY | .Sh HISTORY | ||||
A | A | ||||
.Nm | .Nm | ||||
command appeared in | command appeared in | ||||
.At v1 . | .At v1 . | ||||
.Sh BUGS | |||||
The | |||||
.Fl P | |||||
option assumes that the underlying storage overwrites file blocks | |||||
when data is written to an existing offset. | |||||
Several factors including the file system and its backing store could defeat | |||||
this assumption. | |||||
This includes, but is not limited to file systems that use a | |||||
Copy-On-Write strategy (e.g. ZFS or UFS when snapshots are being used), Flash | |||||
media that are using a wear leveling algorithm, or when the backing datastore | |||||
does journaling, etc. | |||||
In addition, only regular files are overwritten, other types of files are not. |