install
Overview
install copies files with explicit mode (and optional owner/group) and can create destination directories. It is preferred in Makefiles, packaging, and deploy scripts over ad-hoc cp + chmod + mkdir -p sequences because intent is clear and modes are set in one step.
Despite the name, it is a userland coreutils program — not a package manager.
Syntax
install [options] SOURCE DEST
install [options] SOURCE... DIRECTORY
install [options] -t DIRECTORY SOURCE...
install -d [options] DIRECTORY...Common Options
| Option | Description |
|---|---|
-d, --directory |
Create directories (like mkdir -p with mode) |
-m MODE, --mode=MODE |
Permission mode (default often 755 for files historically — set explicitly) |
-o OWNER, -g GROUP |
Owner/group (requires privileges) |
-t DIR, --target-directory=DIR |
Destination directory |
-D |
Create leading components of DEST path |
-b |
Backup existing destination |
-S SUF |
Backup suffix |
-v |
Verbose |
-p |
Preserve timestamps (when supported) |
-C |
Install only if contents differ (compare; GNU) |
--strip / -s |
Strip symbol tables from binaries (toolchain) |
Key Use Cases
- Install binaries/scripts to
/usr/local/bin - Drop configs with correct mode/owner
- Create system directory trees with known permissions
- Reproducible Makefile
make installsteps - Install unit files and server config snippets with correct modes
Examples with Explanations
Install a script or binary
sudo install -m 755 bin/tool /usr/local/bin/tool
sudo install -m 755 target/release/app /usr/local/bin/appCreate directories
sudo install -d -m 755 /etc/myapp
sudo install -d -m 750 -o myapp -g myapp /var/lib/myappConfig with ownership
sudo install -m 640 -o root -g adm myapp.conf /etc/myapp/myapp.confLeading path creation (systemd unit)
sudo install -D -m 644 myapp.service \
/etc/systemd/system/myapp.service
sudo install -D -m 644 myapp.conf \
/etc/myapp/myapp.conf-D creates parent directories of the final DEST file.
Multiple sources into a directory
sudo install -m 644 -t /etc/myapp/ conf.d/*.confCompare before replace (GNU)
sudo install -C -m 644 app.conf /etc/myapp/app.confAvoids unnecessary writes/timestamp bumps when content is identical.
Makefile fragment
PREFIX ?= /usr/local
bindir ?= $(PREFIX)/bin
install:
install -d $(DESTDIR)$(bindir)
install -m 755 tool $(DESTDIR)$(bindir)/tool
Versus cp
# verbose multi-step
mkdir -p /opt/app/bin
cp tool /opt/app/bin/tool
chmod 755 /opt/app/bin/tool
# one tool
install -D -m 755 tool /opt/app/bin/toolNotes / Pitfalls
- Default mode if you forget
-mmay not be what you want — always set-m. -o/-gneed privileges; packaging often installs as root inDESTDIRthen packages own metadata.installis not atomic across filesystems in a fancy way — still a copy into place; for live configs consider write-temp +mv.- Stripping (
-s) needs strip tools and is for binaries, not scripts. - SELinux systems may need
restoreconafter install into labeled paths.
2026-relevant notes
- systemd unit installs:
install -D -m 644 unit /etc/systemd/system/thensystemctl daemon-reload. - Prefer
%install/installin packaging (RPM/deb helpers) with explicit modes for supply-chain clarity. - User-level installs under
~/.localpair well with XDG paths and no root.
Additional Resources
man install