Linux command install directory

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

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.

Читайте также:  Arm unknown linux gnueabi

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.

Источник

Linux Install Command Tutorial

Find out everything you need to know about the Linux install command, and much more in this detailed blog.

Linux Install Command Tutorial

List of content you will read in this article:

The install command in Linux is used to copy files to a given location and assign attributes to them. It transfers data to a designated location. As the name implies, it is not used to install applications. Depending on the distribution method, we could use apt-get, apt, yum, and other tools to download and install the software. It’s quite close to the order ‘cp’. It also gives us leverage over the properties of the destination data.

It’s mostly used to copy programs from makefiles to their final destination. It would not copy files to itself. So in this guide, you will get brief information on the Linux «install command» and its use in all Linux distros.

Linux Install Command, All Linux Distros

The install command incorporates components from various commands, including cp, chown, chmod, mkdir, and strip. It enables one to combine the functions of all of these commands into a single operation.

install [OPTION]. [-T] SOURCE DEST

install [OPTION]. SOURCE. DIRECTORY

install [OPTION]. -t DIRECTORY SOURCE.

install [OPTION]. -d DIRECTORY.

The first three types are used to copy the source to a new directory or several sources to an existing directory and set permission modes and owner/group. On the other hand, the fourth form is used to construct all of the directory’s components.

Install Option Commands

The install command provides the following option:

  • —backup[=CONTROL]: For each current destination file, this alternative generates a backup file.
  • -b: It’s similar to the «—backup» alternative, except it doesn’t need a claim.
  • -C, —compare: It’s used to compare each pair of source and destination files, and it doesn’t always change the destination.
  • -d, —directory: Both arguments would be treated as directory names if the «-d or -directory» option is defined.
  • -D: It’s used to build all of the target directory’s components before copying the source to the destination.
  • -g, —group=GROUP: It’s used to determine the size of a group’s holdings.
  • -m, —mode=MODE:Instead of rwxr-xr-x, it is used to set the authorization mode (as in chmod).
  • -o, —owner=OWNER: It’s used to specify who owns what. Just the superuser has access to it.
  • -p, —preserve-timestamps: The access time of the source file is applied to the specified file.
  • -s, —strip: The strip symbol tables are generated with it.
  • —strip-program=PROGRAM: It is used to remove the program’s binaries.
  • -S, —suffix=SUFFIX: It’s used to replace the backup suffix that’s usually used.
  • -t, —target-directory=DIRECTORY: It copies all source arguments into the designated directory.
  • -T, —no-target-directory: It’s used to handle the destination file as if it were a regular file.
  • -v, —verbose: It is used to print the directory names.
  • —preserve-context: It aims to keep the SELinux security background secure.
  • -Z: It’s used to set the SELinux protection background of the destination file, as well as the default form of each newly generated directory.
  • —help: The support manual is shown using the ‘-help’ option.
  • —version: It’s used to display the details about the edition.
  1. Using the install button, we can tailor each folder and file to our specific requirements. It’s seen like this:
Читайте также:  Linux network device list

install -D /src/folder/*.txt /dest/folder

The ‘-D’ choice in the above command copies all text files from the source folder to the destination folder.

install -d /destination/newfolder

The command above will generate a new folder named ‘newfolder’ in the designated directory.

sudo install xyz.txt abc.txt Pictures

The above command copies the specified files to the ‘Pictures’ folder.

Conclusion

Many times people get confused with the install function and think it is used to install the software. Instead, it is widely used as a copy function. Different option commands can be used to execute different commands. We hope you got the complete details through our article and will use this command in your system.

Источник

Linux command install directory

Команда install позволяет задействовать одноименную утилиту, предназначенную для автоматизации установки файлов программного обеспечения в систему. Обычно данная утилита не используется пользователями непосредственно — для установки предварительно собранных пакетов программного обеспечения используются такие утилиты, как apt, dnf, snap и другие. В случае же сборки программного обеспечения из исходных кодов шансы ее опосредованного использования достаточно велики — обычно ее вызовы можно обнаружить в файлах конфигурации сборочной системы Make. Грубо говоря, данная утилита является аналогом утилиты для копирования файлов cp с дополнительными функциями таких инструментов, как утилита для создания директорий mkdir, утилита для изменения прав доступа к файлам chmod, утилита для изменения владельца файлов chown, утилита для изменения группы владельцев файла chgrp и утилита для удаления отладочной информации их исполняемых файлов strip.

Базовый синтаксис команды выглядит следующим образом:

$ install [параметры] имя-файла путь-для-установки

В случае классического сценария использования команда принимает имя файла и путь для его установки, а также ряд параметров. Актуальными для обычного пользователя параметрами являются параметр -D, позволяющий создать структуру родительских директорий перед копированием файла в нее, параметр -d, позволяющий создать дерево директорий без копирования файлов, параметр -o, позволяющий задать имя владельца установленного файла, параметр -g, позволяющий задать имя группы владельцев установленного файла, параметр -m, позволяющий задать права доступа к установленному файлу, параметр -s, позволяющий удалить отладочную информацию из установленного исполняемого файла, а также параметр -v, позволяющий активировать механизм вывода подробных диагностических сообщений.

Читайте также:  Linux sed in windows

Примеры использования

Установка файла в существующую директорию

Для предварительного создания директории может использоваться сама утилита install с параметром -d.

$ install -d insdir
$ file insdir
insdir: directory

Директория успешно создана — теперь можно приступить к установке в нее файла. Для установки файла в существующую директорию достаточно задать имя файла и путь к целевой директории; дополнительных параметров не требуется.

$ install thread insdir
$ ls -al insdir
итого 40
drwxrwxr-x 2 alex alex 20 авг 16 20:41 .
drwx—x—x 41 alex alex 4096 авг 16 20:41 ..
-rwxr-xr-x 1 alex alex 36184 авг 16 20:41 thread

Файл был скопирован в целевую директорию — утилита сработала корректно.

Установка файла в несуществующую директорию

Для установки файла в несуществующую директорию достаточно использовать параметр -D. Утилита позволяет создать не одну родительскую директорию, а целое дерево директорий, но в этом случае должно быть явно указано и имя установленного файла. Для наглядности активируем режим вывода диагностических сообщений с помощью параметра -v:

$ install -Dv thread insdir/insidedir/thread
install: создание каталога ‘insdir’
install: создание каталога ‘insdir/insidedir’
‘thread’ -> ‘insdir/insidedir/thread’
$ tree insdir
insdir
└── insidedir
└── thread

Дерево родительских директорий успешно создано и файл скопирован в него.

Установка файла со сменой атрибутов

Для смены атрибутов файла следует использовать параметры -o, -g и -m:

# install -Dv -o nobody -g gdm -m 777 thread insdir/thread
install: создание каталога ‘insdir’
‘thread’ -> ‘insdir/thread’
$ ls -al insdir
итого 40
drwxr-xr-x 2 root root 20 авг 16 21:00 .
drwx—x—x 41 alex alex 4096 авг 16 21:00 ..
-rwxrwxrwx 1 nobody gdm 36184 авг 16 21:00 thread

Для смены имен владельца и группы владельцев файла необходимы права суперпользователя. Именно поэтому владельцем родительской директории в результате является пользователь root. Сам же установленный файл имеет заданных владельца и группу владельцев, а также права доступа.

Установка исполняемого файла с удалением отладочной информации

Для удаления отладочной информации из устанавливаемого исполняемого файла достаточно использовать параметр -s:

$ install -Dv -s thread insdir/thread
install: создание каталога ‘insdir’
‘thread’ -> ‘insdir/thread’
$ stat thread
Файл: thread
Размер: 36184 Блоков: 72 Блок В/В: 4096 обычный файл
Устройство: 803h/2051d Инода: 146671 Ссылки: 1
Доступ: (0775/-rwxrwxr-x) Uid: ( 1000/ alex) Gid: ( 1000/ alex)
Доступ: 2022-08-16 20:41:44.637925377 +0300
Модифицирован: 2021-11-18 19:59:24.134960843 +0300
Изменён: 2021-11-18 19:59:24.134960843 +0300
Создан: 2021-11-18 19:59:24.050960896 +0300
$ stat insdir/thread
Файл: insdir/thread
Размер: 22824 Блоков: 48 Блок В/В: 4096 обычный файл
Устройство: 803h/2051d Инода: 134375192 Ссылки: 1
Доступ: (0755/-rwxr-xr-x) Uid: ( 1000/ alex) Gid: ( 1000/ alex)
Доступ: 2022-08-16 21:07:57.969776952 +0300
Модифицирован: 2022-08-16 21:07:58.017776813 +0300
Изменён: 2022-08-16 21:07:58.017776813 +0300
Создан: 2022-08-16 21:07:57.741777616 +0300

В результате размер установленного исполняемого файла уменьшается с 36184 до 22824 байт. Сам же установленный исполняемый файл будет функционировать абсолютно идентично оригинальному.

Источник

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