Linux “cp: omitting directory” Error and Solution

The Linux cp command is used to copy files and directories. The cp command has different options for copying files and directories. While using the cp command to copy directories the “cp: omitting directory” error may occur. In the tutorial, we will examine the cause of this error and different solutions to solve this error.

“cp: omitting directory” Error

The Linux cp command is used to copy files and directories. But by default, the cp command copies only files and does not copy the subdirectories in a recursive manner. If the -r option is not specified to copy the directory and its subdirectories you will get the “cp: omitting directory error” like below.

cp: -r not specified; omitting directory 'Downloads/'

As we can see from the error stating that the “-r not specified”. Which simply explains the error cause.

“cp: omitting directory” Error Solution

“cp: omitting directory” or “-r not specified; omitting directory” error can be solved with the recursive copy operation. The recursive copy operation also copies all source directories and their contents too. The recursive option for the cp command can be specified with the -r or –recursive like below.

cp -r Downloads /mnt/Downloads/

Alternatively the long form recursive option can be specified like below which is more readable.

cp --recursive Downloads /mnt/Downloads/
READ  $0 Script File Name Parameter Usage In Linux Bash

Leave a Comment