LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 01-19-2012, 02:10 AM   #1
Young_zhang
LQ Newbie
 
Registered: Nov 2011
Location: China
Distribution: centos 5.5
Posts: 21

Rep: Reputation: Disabled
Question about "cp" command


Hello, everyone
I use following command :
Code:
cp -rf /etc /test
but when i use the following command
Code:
du -sh /etc
du -sh /test
i found the size of /etc/ are differ from the size of /test.
why they are differ?
thanks for helping me.

Last edited by Young_zhang; 01-19-2012 at 08:38 PM.
 
Old 01-19-2012, 02:32 AM   #2
amilo
Member
 
Registered: Oct 2011
Location: Nederland
Distribution: Debian, Centos, Ubuntu
Posts: 78

Rep: Reputation: Disabled
Some files in /etc/may not been read by an user other then root.
Example /etc/sudoers
 
1 members found this post helpful.
Old 01-19-2012, 02:44 AM   #3
Young_zhang
LQ Newbie
 
Registered: Nov 2011
Location: China
Distribution: centos 5.5
Posts: 21

Original Poster
Rep: Reputation: Disabled
but i use "cp" command by root.
 
Old 01-19-2012, 03:49 AM   #4
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: rhel 5x,6.0,6.2, centOS 5x,6.0,6.2
Posts: 1,194
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
try this command

Code:
#cp -rvf /etc/* /test/
 
2 members found this post helpful.
Old 01-19-2012, 04:30 AM   #5
amilo
Member
 
Registered: Oct 2011
Location: Nederland
Distribution: Debian, Centos, Ubuntu
Posts: 78

Rep: Reputation: Disabled
Another possibility is when you copy a link, you are not making a copy of the link name, but its actual data.
 
1 members found this post helpful.
Old 01-19-2012, 04:44 AM   #6
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
Quote:
Originally Posted by Young_zhang View Post
Hello, everyone
I use following command :
cp -rf /etc /test
but when i use the following command
du -sh /etc
du -sh /test
i found the size of /etc/ are differ from the size of /test.
why they are differ?
thanks for helping me.
Before doing that try to boot off of LiveCD with Linux, mount your root partition and then do the copying.
 
1 members found this post helpful.
Old 01-19-2012, 05:26 AM   #7
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
Lightbulb



Dump the listing to files then use diff to figure out what is the source of the issue.


Code:
ls -lar /etc/ > etc.txt

ls -lar /test > test.txt


diff etc.txt test.txt
 
2 members found this post helpful.
Old 01-19-2012, 07:27 AM   #8
kishore_ari
LQ Newbie
 
Registered: Apr 2011
Posts: 12

Rep: Reputation: 5
cd /etc/;tree . > /tmp/etc.txt
cd /test/;tree . > /tmp/test.txt
diff /tmp/etc.txt /tmp/test.txt

If you find any differences you can compare them by using diff -y /tmp/etc.txt /tmp/test.txt.

I hope the above solution works for you.
 
1 members found this post helpful.
Old 01-19-2012, 07:59 AM   #9
Droa
Member
 
Registered: Oct 2011
Location: ~
Distribution: Debian 7
Posts: 60

Rep: Reputation: Disabled
if its becasue of the symlinks you can try using #cp -rdf /etc/* /test/

it will keep the symlinks
 
1 members found this post helpful.
Old 01-19-2012, 07:33 PM   #10
Young_zhang
LQ Newbie
 
Registered: Nov 2011
Location: China
Distribution: centos 5.5
Posts: 21

Original Poster
Rep: Reputation: Disabled
when i use diff to compare the two file as following:
Code:
ls -ral --full-time /etc  >dir1.txt
ls -ral --full-time /test/etc >dir2.txt
awk -F " " '{print $5 "   " $9}' dir1.txt >new.txt
awk -F " " '{print $5 "   " $9}' dir2.txt >old.txt
diff new.txt old.txt
but the result is nothing,the two files are the same.
I fainted!
 
Old 01-19-2012, 08:23 PM   #11
Young_zhang
LQ Newbie
 
Registered: Nov 2011
Location: China
Distribution: centos 5.5
Posts: 21

Original Poster
Rep: Reputation: Disabled
could anyone help me? thanks.

Last edited by Young_zhang; 01-19-2012 at 08:42 PM.
 
Old 01-20-2012, 05:24 AM   #12
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
How much are they off ?

Maybe use find by size to search for matches ?

Code:
 sudo find /etc/ -size +#k -exec ls -l {} \; | less

# -- number

K - Kilobtes
M - Megabytes
G - Gigabytes

I tried on my system and have no differences. This one is a mystery
 
1 members found this post helpful.
  


Reply


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
[SOLVED] Errors executing shell script: "command not found" and "no such file or directory" eko000 Linux - Newbie 1 01-14-2011 07:54 AM
ns:"error when calling class OldSim"&tclsh:"invalid command+child process exits abn." shojaru Linux - Newbie 0 03-05-2009 04:23 AM
Command "mail" returns "panic: temporary file seek" kenneho Linux - Software 5 12-23-2008 03:27 AM
Feeding the output of "diff" or "cat" command to dpkg --purge kushalkoolwal Debian 9 06-19-2008 07:27 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM

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

All times are GMT -5. The time now is 10:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration