reuse
Reuse boilerplate code across projects easily
TLDR
Lint for REUSE compliance for the current project (version control aware)
Lint for REUSE compliance from the specified directory
Add copyright statement to file
Add licence information to file
Download a license by its SPDX identifier and place it in the LICENSES directory
Download all missing licenses detected in the project
SYNOPSIS
reuse source_file destination_file
PARAMETERS
source_file
The path to the file you want to copy.
destination_file
The destination path where the copied file will be created. This can be a file or a directory.
DESCRIPTION
The reuse
command is a shell utility designed to copy files while meticulously preserving their metadata. This goes beyond a simple file copy by maintaining attributes like file ownership, permissions, timestamps (access, modification, and change), and extended attributes (xattrs) where supported. Unlike the standard cp
command which can sometimes drop or alter certain metadata aspects, reuse
aims for a more complete and faithful reproduction of the original file's state. It's particularly useful in scenarios where maintaining the integrity and lineage of files is critical, such as backups, system administration tasks involving user configuration files, or forensic analysis. The command is often part of specialized security or data management toolsets.
While implementations may vary, reuse
typically relies on lower-level system calls like chown
, chmod
, utime
, and setxattr
to manipulate the metadata of the copied file. The command ensures metadata is maintained even if user has necessary privileges.
CAVEATS
The reuse
command might require elevated privileges (root or sudo) to accurately replicate ownership, especially if the user running the command doesn't own the source file. Error handling might be limited in some implementations.
EXTENDED ATTRIBUTES
A key feature of reuse
is its handling of extended attributes (xattrs). Xattrs are name/value pairs associated with files, providing a mechanism for storing additional metadata beyond standard attributes like permissions and timestamps. If the underlying filesystem supports xattrs, reuse
should copy these attributes to the destination file. Use getfattr and setfattr to see available attributes.
ERROR HANDLING
The thoroughness of error handling can vary between implementations. A robust reuse
command will check for common errors such as insufficient permissions, invalid file paths, or filesystem limitations and provide informative error messages. However, simpler implementations might simply fail silently in some cases.