mktrashcan, rmtrashcan, shtrashcan - Attaches, detaches, or shows a trash-
/usr/sbin/mktrashcan trashcan directory...
Specifies the directory that contains files that were deleted from
attached directories. Whenever you delete a file in the specified
directory, the file system automatically moves the file to the trashcan
Specifies the directory that you attach to a trashcan directory.
The trashcan utilities (mktrashcan and rmtrashcan) enable you to attach or
detach an existing directory, which you specify as a trashcan directory, to
any number of directories within the same fileset.
A trashcan directory stores the files that are deleted with the unlink sys-
tem call. For instance, you can use the mktrashcan utility to attach a
trashcan directory called /usr/trashcan to one or more directories;
thereafter, when you delete a file from one of the attached directories,
the file system moves the file to the /usr/trashcan directory. Note that
when more than one directory shares attachment to a trashcan directory,
files with the same file name can overwrite each other in the trashcan
If you mistakenly delete a file, use the mv command to return the file from
the /usr/trashcan directory to its original directory.
When you enter shtrashcan at the system prompt, the system shows the trash-
can directory, if one exists, for the directory you specified.
It is important that trashcan directories have correct access permissions.
If the permissions are too restrictive, then it may be impossible to remove
files from the directories that are attached to the trashcan directory. In
general, all users and groups that expect to use the trashcan directory
need write permission to the directory. If unexpected "permission denied"
errors occur when deleting files that are in a directory attached to a
trashcan directory, use the chmod command to change the permissions on the
The directory and trashcan directories must be in the same fileset; how-
ever, you can attach the trashcan directory to any directory within the
1. The following example creates and attaches a trashcan directory,
/usr/trashcan, to two directories, /usr/ray and
/usr/projects/sql/test, which are in the same fileset. The chmod com-
mand adds write permission for all users and groups on the new trash-
% mkdir /usr/trashcan
% chmod a+w /usr/trashcan
% mktrashcan /usr/trashcan /usr/ray /usr/projects/sql/test
2. To attach the trashcan directory, /usr/trashcan, to all subdirectories
in the /usr directory, enter:
% mktrashcan /usr/trashcan /usr/*
New subdirectories that you add beneath the /usr directory are not
attached to the trashcan directory until you attach them. Also, the
mktrashcan utility distinguishes between directories and files,
attaching only directories to the trashcan directory.
Note that an attached directory produces an EDUPLICATE_DIRS (-1165)
error when /usr/trashcan is itself in the directory path you attach to
(as in the previous example). You can ignore this error message.
advfs(4), mkfset(8), showfsets(8)