Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-18-2010, 09:05 AM   #1
Senior Member
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,677

Rep: Reputation: 121Reputation: 121
Help me understand -P option for cp

According to the man page, cp -P source DIRECTORY "append source path to DIRECTORY". I am trying to understand how this is different from cp -R source dest. For example if I have the following structure:


and I execute the following command

cp -R /mydata /mybackup

I end up with


If I execute

cp -R /mydata /mybackup

I get a message "omitting dirctory /mydata" and no files are copied. Obviously I do not understand what the -P option is for.


Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-18-2010, 09:29 AM   #2
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
cp -P /mydata /mybackup

I get a message "omitting dirctory /mydata" and no files are copied.
I think you mean -P here (just a typo). In this case you're trying to copy a directory without the recursive -R option, hence the error "omitting directory": cp tells you it cannot copy a directory if not recursively.

Regarding the -P option, it tells to copy the parent directories of the source if they are specified on the command line (just the path, not the entire directory tree and its files). Examples: without -P:
$ cp -R /home/user/somedir/ destination/
$ ls destination
with -P:
$ cp -R -P /home/user/somedir/ destination/
$ ls destination
$ ls destination/home
$ ls destination/home/user
and with -P but without specifying the path of the source (path relative to the current working dir):
$ cp -R -P somedir/ destination/
$ ls destination
Note that the -P option has a different meaning on recent (?) versions of the cp command. For example on my OpenSuse box, with GNU coreutils-6.12, I have
-P, --no-dereference
              never follow symbolic links in SOURCE
whereas the described behavior is given by
              use full source file name under DIRECTORY
Hope this helps.
2 members found this post helpful.
Old 05-21-2010, 03:32 PM   #3
Senior Member
Registered: Jul 2006
Location: North Carolina
Distribution: CentOS 6, CentOS 7 (with Mate), Ubuntu 16.04 Mate
Posts: 1,677

Original Poster
Rep: Reputation: 121Reputation: 121
Thanks colucix! When I read you post and shifted my brain into gear with respect to "parent directory" the operation of the --parents became clear. I was going to do a little testing however, two of my file systems (750 GB and 1 TB were missing

My Ubuntu 9.10 64 bit system goes into standby as expected about 85% of the time, logs me out instead about 14% of the time and locks up the other 1% of the time. In the last situation I have no option but to power off and restart. This time it failed to mount the 1 TB hard drive and a manual mount attempt said it was already mounted or the mount point was busy. Umount said it was not mounted. Deleting the mount point and recreating it did nothing. Unplugging the hard drive and booting up caused the same problem with the 750 GB drive. Time to upgrade to 10.04 I am thinking. Booted from a CD and fsck the drives - they are OK.

Then I made a g4l snapshot of the OS partition (called it bad), restored a snapshot from February - still two AWOL file systems(?) Installed all updates and the file systems came back(??) So another snapshot to save where I had progressed to and restored the bad snapshot planning to reinstall the latest kernel and see what would happen. Booted the restored bad snapshot - before doing anything else - the file systems were back(???)

Now that I am back in operation I ran some cp commands with the -P and --parents options. It seems that -P does not do the same as --parents on Ubuntu - same as your OpenSuse box.

Thanks again,



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to understand top command -H option connecticket Linux - Newbie 1 06-12-2009 12:46 AM
Where is the screensaver option, and where is the sound option? Cinematography SUSE / openSUSE 1 06-20-2008 05:30 PM
understand -w option with grep geeyathink Programming 5 02-21-2008 04:17 AM
Passwd prompt option for "sysdba" option in Oracle shipon_97 Linux - Security 0 09-02-2007 02:17 AM
rpm have --nodeps option with dpkg is such an option available deepclutch Debian 2 03-26-2006 09:49 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:12 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration