Skip to Content

Fix cp -r not specified omitting directory with examples in Linux

Table of Contents

Copy directory in Linux

The error message “cp: -r not specified; omitting directory” is encountered when using the cp command in Linux without specifying the -r option for copying directories.

The cp command is primarily used to copy files and directories from one location to another. However, by default, cp does not copy directories unless the recursive option -r is explicitly specified.

When you attempt to copy a directory without using the -r option, you will receive the aforementioned error message. This error serves as a reminder that the -r option is required to copy directories.

To resolve this error and successfully copy a directory, you should use the cp command with the -r option, like this:

cp -r source_directory destination_directory

Replace source_directory with the path of the directory you want to copy and destination_directory with the desired destination path where you want to create a copy of the directory.

Using the -r option ensures that the cp command recursively copies all the files and subdirectories within the specified directory.

Let’s say you have a directory called source with the following structure:

    ├── file1.txt
    ├── file2.txt
    └── subdirectory/
        ├── file3.txt
        └── file4.txt


If you try to copy the source directory to a destination directory called destination without using the -r option, you will encounter the error message:

$ cp source destination
cp: -r not specified; omitting directory 'source'

To successfully copy the entire source directory and its contents to the destination directory, you need to use the -r option:

$ cp -r source destination

This will recursively copy the source directory and all its files and subdirectories to the destination directory.

Based on the example I provided earlier, the destination directory structure would be as follows:

    └── source/
        ├── file1.txt
        ├── file2.txt
        └── subdirectory/
            ├── file3.txt
            └── file4.txt



The source directory itself will be copied into the destination directory. The source subdirectory will contain the exact same structure and files as the original source directory.


Recently I was assigned the responsibility of migrating a website from one directory to another. The website contained numerous files and directories that needed to be transferred to the new directory.

To accomplish this, I decided to use the cp command to copy the website directory.

I navigated to the directory containing the website files on the source and executed the command cp website_directory destination. However, as soon as I ran the command, I encountered the error message “cp: -r not specified; omitting directory”.

After searching for this error, I understood that the -r option was necessary to copy the entire directory structure, including subdirectories and files. Without the -r option, the cp command would only copy individual files and omit directories.

This experience served as a reminder to always double-check the usage of commands and ensure that the appropriate options are included, especially when working with directories and preserving their structure during file operations.

In this post, I have summarized the problem and hope that it can help you.