• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

cp: omitting directory – error while copying a directory in Linux

by admin

The Problem

When we are trying to copy a directory to other location, we get below error:

$ cp /data01 /data02
cp: omitting directory '/data01'
$

The Solution

The error above is a common mistake done by Linux newbies while copying a directory to other locations without using the recursive copy option in the ‘cp’ command.

In order to avoid this error use the “-r” or the “-a” option in the copy command. From the man page of ‘cp’ command:

# man cp
-R, -r, --recursive
    copy directories recursively

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

For example:

# cp -r /srcdir /tgtdir

or

# cp -R /srcdir /tgtdir

or

# cp -a /srcdir /tgtdir

If you do not use the “-r” or “-a” options in cp command, by default the command will try to only copy the files and not the directories from the source. The “-r” and “-R” are the same options and can be used interchangeably.

Filed Under: Linux

Some more articles you might also be interested in …

  1. Configure VSFTPD Chroot Environment in CentOS and RHEL
  2. CentOS / RHEL : How to create new LVM based swap partition
  3. “Warning: Missing charsets in String to FontSet conversion” – how to resolve the xclock warning message
  4. LVM ISCSI Physical Volume Not Available After Server Reboot
  5. /dev/shm permission change after node reboot
  6. xeyes: command not found
  7. How to use “btrfs device” comamnd to add/delete device to/from btrfs filesystem
  8. Linux OS Service ‘yum-updatesd’
  9. How to Mirror Swap, Boot and Root Partions in CentOS/RHEL 7 Using mdadm Utility
  10. BTRFS: too many missing devices, writeable mount is not allowed

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright