install Command in Linux

This tutorial explains Linux “install” command, options and its usage with examples.

install – `install’ copies files while setting their file mode bits and, if possible, their owner and group.

DESCRIPTION:

`install’ is similar to `cp’, but allows you to control the attributes of destination files. It is typically used in Makefiles to copy programs into their destination directories. It refuses to copy files onto themselves.

This install program copies files (often just compiled) into destination locations you choose. If you want to download and install a ready-to-use package on a GNU/Linux system, you should instead be using a package manager like yum(1) or apt-get(1).

Synopsis:

install [OPTION]… [-T] SOURCE DEST
install [OPTION]… SOURCE… DIRECTORY
install [OPTION]… -t DIRECTORY SOURCE…
install [OPTION]… -d DIRECTORY…

advertisement
advertisement

* If two file names are given, `install’ copies the first file to the second.

* If the `–target-directory’ (`-t’) option is given, or failing that if the last file is a directory and the `–no-target-directory’ (`-T’) option is not given, `install’ copies each SOURCE file to the specified directory, using the SOURCEs’ names.

* If the `–directory’ (`-d’) option is given, `install’ creates each DIRECTORY and any missing parent directories. Parent directories are created with mode `u=rwx,go=rx’ (755), regardless of the `-m’ option or the current umask.

OPTIONS:

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

`-C’
`–compare’
Compare each pair of source and destination files, and if the destination has identical content and any specified owner, group,permissions,then do not modify the destination at all.
`-D’
Create any missing parent directories of DEST, then copy SOURCE to DEST. This option is ignored if a destination Directory is specified via `–target-directory=DIR’.
`-d’
`–directory’

Create any missing parent directories, giving them the default attributes. Then create each given directory, setting their owner, group and mode as given on the command line or to the defaults.
`-m MODE’
`–mode=MODE’

Set the file mode bits for the installed file or directory to MODE,which can be either an octal number, or a symbolic mode as in `chmod’. The default mode is `u=rwx,go=rx,a-s’–read, write, and execute for the owner, read and execute for group and other.
`-o OWNER’
`–owner=OWNER’

If `install’ has appropriate privileges (is run as root), set the ownership of installed files or directories to OWNER. The default is `root’. OWNER may be either a user name or a numeric user ID.
`-p’
`–preserve-timestamps’

Set the time of last access and the time of last modification of each installed file to match those of each corresponding original file. When a file is installed without this option, its last access and last modification times are both set to the time of installation.
`-t DIRECTORY’
`–target-directory=DIRECTORY’

Specify the destination DIRECTORY.
‘-g’
‘–group=GROUP’

set group ownership, instead of process’ current group

Example:

Say u need to install all .py files in a destination directory. So the following process can be followed :

$ install -d /dest/path

This creates the directory hierarchy prior to installing. AND THEN

advertisement
$ install -D /source/path/*.py /dest/path

This installs all the files in the corresponding directories created.

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

advertisement
If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.