install
Copy files and set attributes
TLDR
Copy files to the destination
Copy files to the destination, setting their ownership
Copy files to the destination, setting their group ownership
Copy files to the destination, setting their mode
Copy files and apply access/modification times of source to the destination
Copy files and create the directories at the destination if they don't exist
SYNOPSIS
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... SOURCE DEST
install [OPTION]... -t DIRECTORY SOURCE...
install [OPTION]... -d DIRECTORY...
PARAMETERS
-d, --directory
Create all leading components of DIRECTORYs, then create DIRECTORYs themselves.
-m, --mode=MODE
Set file permissions (mode) to MODE, similar to chmod.
-o, --owner=OWNER
Set ownership to OWNER (username or UID).
-g, --group=GROUP
Set group ownership to GROUP (group name or GID).
-s, --strip
Strip symbol tables from installed executables, reducing their size.
-v, --verbose
Print the name of each directory and file as it is installed.
-b, --backup
Make a backup of the existing destination file before overwriting.
-C, --compare
Compare source and destination files; only update if different.
-D
Create all leading components of DEST, but not DEST itself (when copying a file).
-t, --target-directory=DIRECTORY
Copy all SOURCE arguments into DIRECTORY.
DESCRIPTION
The install command is used to copy files and set their attributes (permissions, ownership, and SELinux context) for installation purposes. Unlike cp, which primarily copies files, install is specifically designed for the software installation process, often invoked by build systems like Makefiles.
It can create parent directories if they don't exist, set precise file modes (permissions), and assign specific owners and groups. This makes it ideal for placing executables, libraries, and configuration files into system directories with the correct access rights. install often performs its operations atomically by copying to a temporary file and then renaming, ensuring system consistency even during unexpected interruptions. It is a fundamental utility for deploying software on Unix-like systems.
CAVEATS
While powerful for installation, install primarily focuses on file and directory attributes. It doesn't manage package dependencies or perform complex system-wide configuration. Its primary role is to correctly place and permission files as part of a build process. Misuse of permissions or ownership can lead to security vulnerabilities or system instability.
ATOMIC OPERATIONS
install often uses a temporary file during copying and then atomically renames it to the final destination. This ensures that the destination file is always either the old version or the completely new version, preventing corrupted files if the process is interrupted.
USAGE IN BUILD SYSTEMS
It is commonly found in the 'install' targets of Makefiles (e.g., 'make install') to place compiled binaries, libraries, and configuration files into their appropriate system-wide locations with the correct permissions.
HISTORY
The install command is a standard utility included in GNU Core Utilities, building upon the functionality of earlier Unix versions. Its enhanced features, such as atomic operations and comprehensive attribute setting, make it indispensable for modern software compilation and installation processes, particularly within Makefiles.