Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rm(1) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

unlink(2)

rmdir(2)

rm(1)

NAME

rm, rmdir − remove files or directories

SYNOPSIS

rm [ −f ] [ −i ] file ... 

rm -r [ −f ] [ −i ] directory ... [ file ... ]

rmdir [ −p ] [ −s ] directory ... 

DESCRIPTION

rm removes the entries for one or more files from a directory.  If an entry was the last link to the file, the file is destroyed.  Removal of a file requires write permission in its directory, but neither read nor write permission on the file itself. 

If a file has no write permission, the −f option is not used, and the standard input is a terminal, its permissions are printed (in octal) and a line is read from the standard input.  If that line begins with y, or the locale’s equivalent for affirmation, the file is deleted, otherwise the file remains.  Note that if the standard input is not a terminal, the command will operate as if the −f option is in effect. 

If file is a symbolic link, the link will be removed but the file or directory to which it refers will not be deleted.  A user does not need write permission on a symbolic link to remove it, provided they have write permission in the directory. 

rmdir removes the named directories, which must be empty. 

Three options apply to rm:

−f This option causes the removal of all files (whether write-protected or not) in a directory without prompting the user.  In a write-protected directory, however, files are never removed (whatever their permissions are), but no messages are displayed. 

−r This option causes the recursive removal of any directories and subdirectories in the argument list.  The directory will be emptied of files and removed.  Note that the user is normally prompted for removal of any write-protected files which the directory contains.  The write-protected files are removed without prompting, however, if the −f option is used, or if the standard input is not a terminal and the −i option is not used. 

Symbolic links that are encountered with this option will not be traversed. 

If the removal of a non-empty, write-protected directory was attempted, the command will always fail (even if the −f option is used), resulting in an error message. 

−i With this option, rm asks whether to remove each file.  It overrides the −f option and remains in effect even if the standard input is not a terminal. 

Two options apply to rmdir:

−p This option allows users to remove the directory directory and its parent directories which become empty.  A message is printed on standard output as to whether the whole path is removed or part of the path remains for some reason. 

−s This option is used to suppress the message printed on standard error when −p is in effect. 

SECURITY FEATURES

If the security label on a file or directory is not dominated by the user’s current operating label and the standard input is a terminal, rm notifies the user that the file or directory is "classified" and prompts with a question mark for permission to remove.  If the answer begins with y (or locale’s equivalent, for yes), the deletion is attempted, otherwise the file or directory remains.  If the user attempts to remove a classified directory with rm −r, and the directory is not empty, the removal will fail since the user is not operating with a label that allows the recursive removal of files within the directory.  If the directory is empty and the current directory is writable by the user, the directory is removed as is allowed by the security policy.  The effect is as if rmdir had been used. 

SEE ALSO

unlink(2), rmdir(2) in the CX/UX Programmer’s Reference Manual. 

DIAGNOSTICS

Generally self-explanatory.  Diagnostic messages usually mean you cannot remove the file. 

Both rm and rmdir return exit codes of 0 if all the specified directories are removed successfully.  Otherwise, they return a non-zero exit code. 

CX/UX User’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026