Home » linux commands » Why you get cp: omitting directory error in Linux and how to solve

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

CP Omitting Directory

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 cp: -r not specified; omitting directory error on the terminal.

Let’s reproduce the error.

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.

 -R, -r, --recursive
copy directories recursively

The cp command – r or -R (recursive) option, allows you to copy directories/subdirectories recursively.

Now let’s again run the copy command now 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.

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

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