Copying a file into place can also mean choosing its destination permissions or creating directories along the path. The GNU install utility prepares files and directories from the command line, including copying a file and creating missing parent directories.
I’ll show how to set permissions on a copied file and create the directories it needs.
TL;DR
The GNU install utility prepares files and directories from the command line. It is different from a distribution’s package installer.
- Copy one file with install source.txt destination.txt.
- Copy and create missing parents with install -D source.txt path/to/destination.txt.
- Set a destination mode with install -m 640 source.txt destination.txt.
- Ownership values: GNU accepts a user name or numeric user ID for the owner and a group name or numeric ID for the group. Resolve those values on the target host.
- Directory modes: parents created by -D receive mode 755 regardless of the requested file mode.
- File modes: GNU install defaults to 755 with set-user-ID and set-group-ID bits disabled. An explicit mode can be octal or chmod-style, such as u=rw,go=r, which grants no execute permission.
- Compare and compatibility: GNU install’s -C or --compare skips a rewrite when content and requested attributes match. Specify owner, group and mode when those attributes matter. The -c option is ignored and remains for compatibility.
- Extended attributes: GNU install does not preserve metadata outside the usual owner, group and permission fields. Use a tool that copies extended attributes when a deployment relies on them.
What Is the install Command in Linux?
This GNU Coreutils utility handles filesystem paths, while apt and other package managers handle repository metadata and dependency resolution.
An operand is a path supplied after the command and its options. Replace the SOURCE and DEST placeholders in the syntax with the names of the file and destination you intend to use.
Quote any path that contains spaces so the shell passes the full name as one operand. In scripts, validate variable paths before using them to avoid selecting unintended files.
install [OPTION]... SOURCE DEST
install [OPTION]... SOURCE... DIRECTORY
install [OPTION]... -d DIRECTORY...
A build process can prepare files in a staging directory, where a maintainer can inspect the tree before a later deployment step. Staging also keeps build output separate from the project’s source files.
How to Use the install Command Step by Step
Run install with a source path and a destination, then add only the options needed for that destination. I used a workspace-local text file to check a copy with mode 640. The command reported the copy and the resulting file had mode 640.
Step 1: Copy a file and set its mode
Use -m followed by an octal mode to set permissions on the new destination. In 640, the digits give the owner read/write access, the group read access and other users no access.
install -v -m 640 install-source.txt installed-config.txt
removed 'installed-config.txt'
'install-source.txt' -> 'installed-config.txt'

The first output line appears because the destination already existed from a prior run of the command. The verbose line records install removing the older file before copying the source.
Run stat -c ‘%a %n’ installed-config.txt to print the numeric mode and destination filename without changing the copy. For a configuration file, 640 allows its owner to edit it while preventing group members from changing its contents.
Step 2: Copy into a directory
For a copy into a directory, put that directory after the source operand. install keeps the source basename in the destination.
install config.ini /path/to/existing-configs/
This places the copy at /path/to/existing-configs/config.ini, keeping the source basename. Check that the target directory is the intended one before running the command, especially in a deployment script with a variable path.
Step 3: Copy several files into one directory
Use -t to name the target directory before listing source files.
install -t ./stage/etc app.conf service.conf
Both files are copied into ./stage/etc with their source names. That directory must exist unless you combine this form with -D. When several paths are listed, review their basenames so they do not unintentionally target the same output name.
Use -T when the destination path names an existing directory but should be treated as the file operand. Confirm that interpretation first, because an unexpected destination type can change where files are written.
Step 4: Create missing parents while copying
Add -D to create missing leading directories in the destination path, then copy the source to the final filename.
install -D -m 644 config.ini ./stage/etc/example/config.ini
The source is written to ./stage/etc/example/config.ini. Here, config.ini is the final file name, and the preceding path components are directories.
Step 5: Create directories without copying a file
When creating a directory path, choose a mode that fits the access the directory needs.
install -d -m 750 ./stage/var/lib/example
Mode 750 grants the owner read, write and search access, the group read and search access, and no access to others. Directory search permission lets an account traverse the path.
Step 6: Set the owner or group when authorized
Use -o and -g only when the process is authorized to make the requested ownership change.
sudo install -o appuser -g webgroup ./config.ini ./stage/etc/config.ini
A service account may need ownership of its configuration file to read it during startup. Confirm the account and group expected by the service before using this form.
Step 7: Preserve timestamps or back up an existing destination
Use -p when preserving the source file’s access and modification times is part of the deployment. Add a backup option when a routine refresh needs a fallback.
install -p source.conf /path/to/config.conf
install -b -S .old source.conf /path/to/config.conf
The .old suffix identifies the retained version. Review or rotate it before a later refresh so a useful rollback copy is not discarded.
What Should You Check Before Using install?
Check that the source exists and that the account can write to the destination’s parent directory before you run a copy. Verify that the path points to the intended staging or deployment location.
Relative paths start from the shell’s current working directory, not from the source file’s directory. A script that changes directories can send an otherwise valid command to a different staging tree. Use an absolute path or set the working directory explicitly in automation.
| Need | Option or check | Boundary |
|---|---|---|
| Create directories only | -d | Does not copy a source file |
| Create destination parents and copy | -D | Final path component is the file |
| Set file permissions | -m MODE | Mode applies to the copied file |
| Set owner or group | -o OWNER, -g GROUP | Changing ownership generally needs elevated privileges |
| Preserve source times | -p | Preserves access and modification times |
| Keep a previous copy | -b, optionally -S SUFFIX | Backup is made when replacing a destination |
Conclusion: Use install to Place Files with Their Attributes
Use install when a file needs to be copied into place with a chosen mode, timestamps or backup behavior. Select -d for directory creation and -D for creating missing parents before a file copy.
For related tasks, see the LinuxForDevices guide to changing file permissions and ownership with chmod and chown, or learn how mkdir creates directories. If you meant package installation, continue with the guide to Linux package management, searching Ubuntu packages with apt, or using DNF to manage packages.
FAQ
These answers cover two common distinctions that can change which command you choose.
Does install -m change the source file’s permissions?
No. The -m option sets the mode of the destination file that install copies. The source file remains the input to the copy operation.
Does install preserve source timestamps by default?
No. Use -p when the destination should keep the source file’s access and modification times.
