[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home |
Legal |
Search ]
Commands Reference, Volume 3
install Command
Purpose
Installs a command.
Syntax
/usr/bin/install [- c DirectoryA] [- f DirectoryB] [- i] [- m] [- M Mode]
[- O Owner] [- G Group] [- S] [- n DirectoryC] [- o] [- s] File [Directory ...
]
Description
The install command installs
a specified file in a specific place within a file system. It is most often
used in makefiles. When replacing files, the install
command copies (or moves) each file into the appropriate directory, thereby
retaining the original owner and permissions based on the behavior of the cp and mv commands. An attempt is
made to change the destination to owner bin and group bin. The -O Owner and -G Group flags can
be used to specify a different owner or group. The install command writes a message telling you exactly which files it is replacing
or creating and where they are going.
You must be a super-user if you want to specify the ownership of the installed
file with the -O or -G flags.
If you do not specify the Directory parameter, the install command searches a set
of default directories (/usr/bin, /etc, and /usr/lib, in that order) for a file with
the same name as the File parameter. The first time
it finds one, it overwrites it with File and issues
a message indicating that it has done so. If a match is not found, the install command issues a message telling you there was no
match and exits with no further action. If the File
parameter does not exist in the current directory, the install command displays an error message and exits with a nonzero value.
If any directories are specified on the command line,
the install command searches them before it searches
the default directories.
Flags
-c DirectoryA |
Installs a new command file in the DirectoryA variable only if that file does not already exist there. If it finds
a copy of File there, it issues a message and exits
without overwriting the file. This flag can be used alone or with the -s, -M, -O, -G, or -S flag. |
-f DirectoryB |
Forces installation of File in DirectoryB whether or not File already exists.
If the file being installed does not already exist, the command sets the permission
code and owner of the new file to 755 and bin, respectively. This flag can be used alone or with the -o,-s, -M, -O, -G, or -S
flag. |
-G Group |
Specifies a different group for the destination file. The default
group is bin. |
-i |
Ignores the default directory list and searches only those directories
specified on the command line. This flag cannot be used with the -c, -f, or -m flags. |
-m |
Moves the File parameter to the directory
instead of being copied. Cannot be used with the -c, -f, -i, or -n
flag. |
-M Mode |
Specifies the mode of the destination file. |
-n DirectoryC |
Installs the File parameter in the DirectoryC variable if it is not in any of the searched directories,
and sets the permissions and owner of the file to 755
and bin, respectively. This flag cannot be used with
the -c, -f, or -m flag. |
-o |
Saves the old copy of the File parameter
by copying it into a file called OLDFile in the same directory. This flag cannot be used with the -c flag. |
-O Owner |
Specifies a different owner of the destination file. The default
owner is bin. |
-s |
Suppresses the display of all but error messages. |
-S |
Causes the binary to be stripped after installation. |
Examples
- To replace a command that already exists in one
of the default directories, enter:
install fixit
This replaces
the fixit file if it is found in the /usr/bin, /etc, or /usr/lib
directory. Otherwise, the fixit file is not installed.
For example, if /usr/bin/fixit exists, then this file
is replaced by a copy of the file fixit in the current
directory.
- To replace a command that already exists in a
specified or default directory and to preserve the old version, enter:
install -o fixit /etc /usr/games
This replaces the fixit file if it is
found in the /etc or /usr/games
directory or in one of the default directories. Otherwise the fixit file is not installed. If the file is replaced, the old version
is preserved by renaming it OLDfixit in the directory
in which it was found.
- To replace a command that already exists in a
specified directory, enter:
install -i fixit /home/jim/bin /home/joan/bin /usr/games
This replaces
the fixit file if it is found in the /home/jim/bin, /home/joan/bin, or /usr/games directory. Otherwise, the file is not installed.
- To replace a command found in a default directory
or install it in a specified directory if it is not found, enter:
install -n /usr/bin fixit
This replaces the fixit file if it is found in one of
the default directories. If the file is not found, it is installed as /usr/bin/fixit.
- To install a new command, enter:
install -c /usr/bin fixit
This creates a new command by installing a copy of the fixit file as /usr/bin/fixit, but only if this file
does not already exist.
- To install a command in a specified directory
whether or not it already exists, enter:
install -f /usr/bin -o -s fixit
This forces the fixit file to be installed as /usr/bin/fixit whether or not it already exists. The old version, if any, is preserved
by moving it to /usr/bin/OLDfixit (a result of the -o flag). The messages that tell where the new command
is installed are suppressed (a result of the -s flag).
Compatibility
For compatibility with Berkeley Software Distribution
(BSD), two install commands exist. See the installbsd command.
Files
/usr/bin/install |
Contains the install command. |
Related Information
The chgrp command, chmod
command, chown command, cp command, installbsd command, make command, mv
command, strip command.
[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home |
Legal |
Search ]