LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-18-2009, 11:33 AM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
What does tar -cp do?


Hello

I cribbed a command intended to make an exact copy of files to another directory
Code:
tar cpBf - . | (cd <target directory>; tar xBf -)
and stupidly did not check it against the man page. Regards the p option the man page says "p, --same-permissions, --preserve-permissions. ignore umask when extracting files (the default for root)". Thus the p option is undefined when used with the c (create) option; it is only defined in conjunction with the x (extract) option.

The source directories (/etc/rc.[0-6S].d in turn) contain symbolic links and an ordinary file. After running the command, the modification times on all the symlinks was reset to the time the tar command was run; the ordinary files had the original modification time.

How did that happen?!

That's what backups are for

Edit:
Code:
c@CW8:~$ tar --version
tar (GNU tar) 1.19
Best

Charles

Last edited by catkin; 07-18-2009 at 11:43 AM.
 
Old 07-18-2009, 01:24 PM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Are you just complaining?

You didn't give the exact command that got you into trouble. Did you overwrite the files in the same place?

I wonder if you are confusing access time with modification time. If you overwrote the original files then the modification time change makes sense. Otherwise it doesn't.

This is how to use tar to copy a directory tree. I use this all the time.
Code:
tar c . | tar --directory /destination/dir -xvp
Code:
tar --version
tar (GNU tar) 1.19
I used to use that (cd /destination/dir; tar xp -) but the --directory parameter just makes it all much simpler.

Last edited by stress_junkie; 07-18-2009 at 01:34 PM.
 
Old 07-18-2009, 01:40 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Thanks stress_junkie
Quote:
Originally Posted by stress_junkie View Post
Are you just complaining? It seems as though you answered your own question. First, you improperly used the p parameter.

This is how to use tar to copy a directory tree. I use this all the time.
Code:
tar c . | tar --directory /destination/dir -xvp
Code:
tar --version
tar (GNU tar) 1.19
I used to use that (cd /destination/dir; tar xp -) but the --directory parameter just makes it all much simpler.
Not complaining -- things are how they are -- more wanting to understand. Maybe it's an undocumented feature that some guru can explain.

Conventionally, incorrect use of options results in an error so I would regard the reported behaviour as a bug if it is as I presently understand it, especially as I don't expect tar c with any options to change any of the source files' properties except for access time.

Thanks for the "heads up" on the --directory option; it is a useful feature.

BTW, is it possible to use tar to copy symbolic links without changing their modification time?

Best

Charles
 
  


Reply



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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:21 PM.

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