Why you get cp: omitting directory error in Linux and how to solve


Linux cp command allows you to copy files and directories. By default, it works on file only. When you try to copy a directory. You get the below error on the terminal.

cp: -r not specified; omitting directory 

Let’s understand why you get this error in Linux and find out the solution.

First, let’s reproduce cp: omitting directory error

Let’s copy a file from src_file.txt to /home/atechtown/dest_dir folder.

cp src_file.txt /home/atechtown/dest_dir

This works fine for files.

Now, let’s run the command for the directory and see what happens. Copy a directory from src_dir to desk_dir.

cp src_dir desk_dir
cp: -r not specified; omitting directory 'src_dir'

What is wrong with the copy command? Why the error message cp omitting directory?

cp omitting directory error solution

cp: omitting directory error tells that directories are not copied as the cp command by default works on the files only. Simply, use the cp command with  -r or -R (recursive) as an argument to resolve cp: omitting directory error.

This is what this option says,

 -R, -r, – recursive
copy directories recursively

So -r or -R option allows you to copy directories/subdirectories recursively.

Now let’s run the copy command with the – r option.

cp -r src_dir dest_dir


cp -R src_dir dest_dir

Now you can see the command worked fine and directories along with contents are also copied.


Linux cp command is very useful and powerful. By default, it works on files only. You need to use the -r or -R option to copy directories otherwise, you will get omitting directory error. This solution should work on any Unix alike and Linux Distros -Ubuntu, Redhat, Fedora or OpenSuse, CentOS, et

Refer to this discussion on Askubuntu and StackOverflow for additional details.

I hope you found this article helpful. Please share and subscribe.