• 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. How to tar, untar files and view contents of tar file under Linux
  2. How To Auto Mount a FileSystem Using Systemd
  3. abbr Command Examples in fish-shell
  4. isoinfo: command not found
  5. pidof Command Examples in Linux
  6. lpq: command not found
  7. How to Enable X11 Forwarding on CentOS/RHEL 5,6,7
  8. emerge Command Examples in Gentoo Linux
  9. How to Run a Script When USB Devices Is Attached or Removed Using UDEV
  10. UNIX / Linux : How to lock or disable an user account

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright