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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. Understanding OS load average and run queue/blocked queue in terms of CPU utilization in Linux
  2. How to Disable the ‘lvm2-lvmetad.socket/service’ on CentOS/RHEL 7
  3. Red Hat / CentOS : How to create interface / NIC bonding
  4. How to Configure Logical Volume Manager for Cluster File System
  5. Beginners Guide to MySQL User Management
  6. CentOS / RHEL : How to mount filesystems using UUID
  7. How To Add/Remove Locale Archive in CentOS/RHEL 5,6
  8. UNIX / Linux : how to force user to change their password on next login after password has reset
  9. How to Compress and Extract Files and Directories in Linux Using gzip and bzip2
  10. How to check failed or bad login attempts in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ICMP redirects on CentOS/RHEL
  • What are Oracle Key Vault Roles
  • What Is Oracle Key Vault
  • Auditing with Oracle Database Vault Reports
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary