Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does /usr/sbin/install really do?

I'm trying to install discount on my VPS which is based on Solaris and compiling works great after setting some environment variables but the install fails.

So I thought I'd do the install manually, but what does install really do? Is it simply a mv followed by a chmod? Is it magic? That error seems to show that it attempts to do a lot of searching for files all over?

Can I just copy the binary, library and header files as usual?

Googling "install" doesn't give me much relevant information so I appreciate any clarification I can get!

like image 980
Robert Sköld Avatar asked Feb 10 '11 16:02

Robert Sköld


1 Answers

According to man install:

install [OPTION]... [-T] SOURCE DEST`  
install [OPTION]... SOURCE... DIRECTORY  
install [OPTION]... -t DIRECTORY SOURCE...  
install [OPTION]... -d DIRECTORY...  

In the first three forms, copy SOURCE to DEST or multiple SOURCE(s) to the existing DIRECTORY, while setting permission modes and owner/group. In the 4th form, create all components of the given DIRECTORY(ies).

As for the difference to using cp, according to install vs. cp; and mmap, install unlinks the existing file, creating a new one linked to the same spot.

This has the advantage that, if the file you're trying to overwrite is a currently running program, it can continue running, as the file being written is in fact in a new location, and the existing program code is still in the old one.

A cp simply tries to overwrite the existing file, which will fail if the file is locked due to being in use.

Further information

  • install Command
like image 184
Sebastian Paaske Tørholm Avatar answered Sep 18 '22 12:09

Sebastian Paaske Tørholm