INSTALL(1) | General Commands Manual | INSTALL(1)

# NAME

`install` —
install binaries

# SYNOPSIS

`install` | [`-bcprsU`] [`-a` command] [`-B` suffix] [`-D` destdir] [`-f` flags] [`-g` group] [`-h` hash] [`-l` linkflags] [`-M` metalog] [`-m` mode] [`-N` dbdir] [`-o` owner] [`-S` stripflag] [`-T` tags] file1 file2

`install` | [`-bcprsU`] [`-a` command] [`-B` suffix] [`-D` destdir] [`-f` flags] [`-g` group] [`-h` hash] [`-l` linkflags] [`-M` metalog] [`-m` mode] [`-N` dbdir] [`-o` owner] [`-S` stripflag] [`-T` tags] file1 ... fileN directory

`install` | `-d` [`-pU`] [`-a` command] [`-D` destdir] [`-g` group] [`-M` metalog] [`-m` mode] [`-N` dbdir] [`-o` owner] [`-T` tags] directory ...

# DESCRIPTION

The file(s) are copied (or linked if the `-l` option is specified) to the target file or directory. If the destination is a directory, then the file is copied into directory with its original filename. If the target file already exists, it is either renamed to file.old if the `-b` option is given or overwritten if permissions allow; an alternate backup suffix may be specified via the `-B` option's argument.

`-a` command
  Run command on the target after installation and stripping (`-s`), but before ownership, permissions or timestamps are set and before renaming (`-r`) occurs. command is invoked via the sh(1) shell, allowing a single `-a` argument be to specified to `install` which the shell can then tokenize.
`-B` suffix
  Use suffix as the backup suffix if `-b` is given. If suffix contains a '%' sign, a numbered backup will be performed, and the %-pattern will be expanded using sprintf(3), given an integer counter as the backup number. The counter used starts from 0, and the first available name resulting from the expansion is used.
`-b`
  Backup any existing files before overwriting them by renaming them to file.old. See `-B` for specifying a different backup suffix.
`-c`
  Copy the file. This is the default behavior; the flag is maintained for backwards compatibility only.
`-D` destdir
  Specify the `DESTDIR` (top of the file hierarchy) that the items are installed in to. If `-M` metalog is in use, a leading string of “destdir” will be removed from the file names logged to the metalog. This option does not affect where the actual files are installed.
`-d`
  Create directories. Missing parent directories are created as required.
`-f` flags
  Specify the target's file flags. (See chflags(1) for a list of possible flags and their meanings.)
`-g` group
  Specify a group.
`-h` hash
  When copying, calculate the digest of the files with hash to store in the `-M` metalog. Supported digests:
  none
    No hash. This is the default.
  md5
    The MD5 cryptographic message digest.
  rmd160
    The RMD-160 cryptographic message digest.
  sha1
    The SHA-1 cryptographic message digest.
  sha256
    The 256-bits SHA-2 cryptographic message digest of the file.
  sha384
    The 384-bits SHA-2 cryptographic message digest of the file.
  sha512
    The 512-bits SHA-2 cryptographic message digest of the file.
`-l` linkflags
  Instead of copying the file make a link to the source. The type of the link is determined by the linkflags argument. Valid linkflags are: a (absolute), r (relative), h (hard), s (symbolic), m (mixed). Absolute and relative have effect only for symbolic links. Mixed links are hard links for files on the same filesystem, symbolic otherwise.
`-M` metalog
  Write the metadata associated with each item installed to metalog in an mtree(8) “full path” specification line. The metadata includes: the file name and file type, and depending upon other options, the owner, group, file flags, modification time, and tags.
`-m` mode
  Specify an alternative mode. The default mode is set to rwxr-xr-x (0755). The specified mode may be either an octal or symbolic value; see chmod(1) for a description of possible mode values.
`-N` dbdir
  Use the user database text file master.passwd and group database text file group from dbdir, rather than using the results from the system's getpwnam(3) and getgrnam(3) (and related) library calls.
`-o` owner
  Specify an owner.
`-p`
  Preserve the source files access and modification times.
`-r`
  Install to a temporary file and then rename the file to its final destination name. This can be used for precious files, to avoid truncation of the original when error conditions (filesystem full etc.) occur.
`-S` stripflags
  `install` passes stripflags as option arguments to strip(1). When `-S` is used, strip(1) is invoked via the sh(1) shell, allowing a single `-S` argument be to specified to `install` which the shell can then tokenize. Normally, `install` invokes strip(1) directly. This flag implies `-s`.
`-s`
  `install` exec's the command strip(1) to strip binaries so that install can be portable over a large number of systems and binary types. If the environment variable `STRIP` is set, it is used as the strip(1) program.
`-T` tags
  Specify the mtree(8) tags to write out for the file when using `-M` metalog.
`-U`
  Indicate that install is running unprivileged, and that it should not try to change the owner, the group, or the file flags of the destination. The information that would have been updated can be stored in a log file with `-M` metalog.

By default, `install` preserves all file flags, with the exception of the ``nodump'' flag.

The `install` utility attempts to prevent copying a file onto itself.

Installing /dev/null creates an empty file.

# ENVIRONMENT

`STRIP`
  The program used to strip installed binaries when the `-s` option is used. If unspecified, /usr/bin/strip is used.

# EXIT STATUS

The `install` utility exits 0 on success, and >0 if an error occurs.

# SEE ALSO

chflags(1), chgrp(1), chmod(1), cp(1), mv(1), strip(1), chown(8), mtree(8)

# HISTORY

The `install` utility appeared in 4.2BSD.

May 1, 2009 | NetBSD 9.5