how to handle “cp: omitting directory ” error Ubuntu

While copying files from one location to another, you might get following error

$ sudo cp /home/code/wordpress /var/www/localfintrekking
cp: omitting directory '/home/code/wordpress'

Here is output of ls -la command

$ ls -la
total 84
drwxrwxr-x 21 USERNAME USERNAME 4096 Apr 20 23:18 .
drwxr-xr-x 45 USERNAME USERNAME 4096 May 7 14:12 ..
drwxrwxr-x 7 USERNAME USERNAME 4096 May 5 13:52 backup
drwxrwxr-x 15 USERNAME USERNAME 4096 Sep 21 2017 bootstrap
drwxrwxr-x 3 USERNAME USERNAME 4096 Mar 8 08:31 django
drwxrwxr-x 9 USERNAME USERNAME 4096 May 5 22:05 python
drwxrwxr-x 4 USERNAME USERNAME 4096 Apr 28 18:57 wordpress

By default, cp copies only the direct files in, and not sub directories in the directory. The message cp: omitting directory ‘directory’ warns you that the mentioned directory is not copied.

You solve this problem you can follow either of following command

sudo cp -r /home/code/wordpress /var/www/localtechtrekkingcom
sudo cp -a /home/code/wordpress /var/www/localtechtrekkingcom

Details about these options

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

-a, --archive
same as -dR --preserve=all

Important note: Address needs to be route address and not the address from relative folder


Leave a Reply

Your email address will not be published. Required fields are marked *