Installation on linux command

install(1) — Linux man page

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

Description

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).

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).

Mandatory arguments to long options are mandatory for short options too. —backup[=CONTROL] make a backup of each existing destination file -b like —backup but does not accept an argument -c (ignored) -C, —compare compare each pair of source and destination files, and in some cases, do not modify the destination at all -d, —directory treat all arguments as directory names; create all components of the specified directories -D create all leading components of DEST except the last, then copy SOURCE to DEST -g, —group=GROUP set group ownership, instead of process’ current group -m, —mode=MODE set permission mode (as in chmod), instead of rwxr-xr-x -o, —owner=OWNER set ownership (super-user only) -p, —preserve-timestamps apply access/modification times of SOURCE files to corresponding destination files -s, —strip strip symbol tables —strip-program=PROGRAM program used to strip binaries -S, —suffix=SUFFIX override the usual backup suffix -t, —target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY -T, —no-target-directory treat DEST as a normal file -v, —verbose print the name of each directory as it is created -P, —preserve-context (SELinux) preserve security context -Z, —context=CONTEXT (SELinux) set security context of files and directories —help display this help and exit —version output version information and exit

The backup suffix is ‘~’, unless set with —suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the —backup option or through the VERSION_CONTROL environment variable. Here are the values: none, off never make backups (even if —backup is given) numbered, t make numbered backups existing, nil numbered if numbered backups exist, simple otherwise simple, never always make simple backups

Читайте также:  Дистрибутив файловый сервер linux

Author

Reporting Bugs

Copyright © 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

See Also

The full documentation for install is maintained as a Texinfo manual. If the info and install programs are properly installed at your site, the command info coreutils aqinstall invocationaq

should give you access to the complete manual.

Источник

The install Command in Linux

announcement - icon

The Kubernetes ecosystem is huge and quite complex, so it’s easy to forget about costs when trying out all of the exciting tools.

To avoid overspending on your Kubernetes cluster, definitely have a look at the free K8s cost monitoring tool from the automation platform CAST AI. You can view your costs in real time, allocate them, calculate burn rates for projects, spot anomalies or spikes, and get insightful reports you can share with your team.

Connect your cluster and start monitoring your K8s costs right away:

1. Overview

Despite its name, the install command isn’t actually used for installing software packages. Instead, it can be considered a fancy way to copy files to a target location, kind of like the basic cp command but with advanced features.

The install command lets us copy files and create directories like the cp and mkdir commands, but with more control. We can adjust permission modes like with chmod, ownership like with chown, as well as make backups and preserve metadata. These features make it a go-to tool for developers and power users alike.

In this tutorial, we’ll learn the basics of the install command, exploring its functionality and usage examples.

2. Basic Usage of the install Command

The install command is a versatile tool that combines several useful functions from other commands. Here, we’ll explore how it copies data and creates directories.

2.1. Copying Files

One of the simplest uses of the install command is to copy files from a source location to a target location:

$ install -v cicada.txt bouhannana_33project/ 'cicada.txt' -> 'bouhannana_33project/cicada.txt'

Using the install command, we copied the cicada.txt file to a directory named bouhannana_33project. To display the details of the process, we included the -v option (abbreviation of –verbose).

Читайте также:  Linux поиск файлов утилита

2.2. Creating New Directories

Another basic function of install is creating directories like the mkdir command. But again, install offers extra features.

Let’s create a new directory:

$ install -d zaaiy_11project

The -d (short for –directory) option instructed the install command to create a zaaiy_11project directory if it doesn’t exist. If the directory already exists, install won’t overwrite it.

2.3. Creating Directories and Copying Files

When we want to create a new directory and copy files into it, this feature saves us time making separate calls to mkdir.

However, we don’t need -d to create a new directory and then another command to copy files into it. We can pair our command with the -D and the -t (short for –target-directory) options to achieve this with a single command:

$ install -v -D -t new_d/ cicada.txt install: creating directory 'new_dir' 'cicada.txt' -> 'new_d/cicada.txt'

Voila! The command successfully created a new directory and copied our file into it.

3. Adjusting Files and Directories Attributes

The install command lets us avoid making separate calls to other tools to modify file and directory attributes.

3.1. Setting Owners and Groups While Copying

The install command is a real time-saver when it comes to setting ownership for files and directories. With the -o (short for –owner) and -g (short for –group) options, we can set the target owner and group without having to make separate calls to chown and chgrp.

Let’s copy a target file while changing its owner and group:

$ sudo install cicada.txt -o semara -g bouhannana new_dir/

The above command copies cicada.txt into new_dir and set its owner and group to semara and bouhannana respectively. If the user or group doesn’t exist, the command will fail.

3.2. Setting Owners and Groups While Creating Directories

Let’s use the same approach to create new directories while changing ownership:

$ sudo install -v -d -o semara -g sudo newest_dir

Same as before, the command creates a directory with a specific owner and group.

3.3. Setting User Permissions

We can also use install to set the user permission flags of files, similar to the chmod command. We can do this by using the -m (short for–mode) option followed by the permission flags in octal notation:

$ install -m 644 cicada.txt newest_dir/

The command applies new permissions to the copied file in the newest_dir directory. The permissions for the owner include read and write access, while the group and others will have read-only access as the mode dictates.

Читайте также:  Atheros linux driver ar8132

Just like creating a new directory with a new owner and group, this is also true for setting new user permissions:

$ install -v -m 700 -d test_dir/ install: creating directory 'test_dir'

In this case, our install command sets read, write, and execute permissions for the user only.

4. Preserving Timestamps

By default, the install command keeps the original ownership and permission mode but updates the timestamp of the files to the time of the copy operation.

The -p (short for –preserve-timestamps) option ensures that the access and modification times of the source files apply to the destination files as well.

This can be useful in situations when copying files for backup or archiving purposes:

$ install -v -p zaaiy.txt newest_dir/ 'zaaiy.txt' -> 'newest_dir/zaaiy.txt'

The command copies a file named zaaiy.txt to a directory called newest_dir and keeps the same times when the file was last changed or opened.

5. Backing up Files

Creating file backups is essential to avoid data loss. The install command provides an easy way to create backups while copying files to a target location.

We can use the -b option with the install command to create a backup of a file we’re going to overwrite.

Let’s re-copy a file to our directory:

$ install -v -b cicada.txt bouhannana_33project/ 'cicada.txt' -> 'bouhannana_33project/cicada.txt' (backup: 'bouhannana_33project/cicada.txt~')

The -b switch instructs install to backup the existing file in the target location with a tilde (~) appended to its filename as in cicada.txt~.

To avoid appending the default tilde suffix, we can add the -S (short for –suffix) to specify our own:

$ install -b -S .OLD cicada.txt bouhannana_33project/ $ ls bouhannana_33project/ cicada.txt cicada.txt.OLD

Now, our command creates a backup of the existing file with a suffix of .OLD, then overwrites it. This is useful in situations where we want to avoid overwriting an important file.

6. Conclusion

In this article, we’ve explored the install command in Linux along with its various options.

We’ve learned that the install command can help us copy, create, and modify files and directories without the use of other commands like chmod, chgrp, and chown.

Furthermore, we’ve discussed several use cases, such as copying files, setting ownership, and even creating backups.

Источник

Оцените статью
Adblock
detector