LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-04-2014, 12:11 AM   #1
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Rep: Reputation: 0
copy whole file tree (with everything)


Hello everybody

I have a very simple question and **yet** searching in the internet the responses are many and some even don't work at all.

The question is:

How do I copy an entire file tree, meaning, the folder, its subfolders, all files contained in them and all links, in other words everything from one place to another??

simple answers like "use cp -r" apparently do not work..

Thanks a thousand for your answers

Kansai

P.S> The question finished above,Just some background in case you want to know. I am developing using the source code of the kernel and userland. So far no problems. I put it somewhere, configure it, make my changes , make it and there I have solution A. But lets say I want solution B over solution A. ( I dont want to lose A) so my idea is to copy ALL the files I have been working on on another place and start on B there. I tried cp -r and it apparently copied all but when I tried to rebuild it showed errors, files not found etc. So instead of copy I downloaded again the source code , made all my changes in solution A and then solution B and it built. But I cant be doing this forever!

there must be some way to copy all my previous work some other place. Thanks a lot

Last edited by KansaiRobot; 11-04-2014 at 12:12 AM.
 
Old 11-04-2014, 12:25 AM   #2
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
This where version management tools (like git or subversion) come in.
With git you just start a new branch for your modifications. So you would create a branch modA and a branch modB. After that you can easily switch between the two branches.

A good place to learn about using git.

Cheers
 
Old 11-04-2014, 12:28 AM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

what do you mean by "do not work"? If you can answer that we can probably tell you how to achieve what you want. Tools that spring to mind include tar and rsync.

However since you are working with source code, and in particular the Linux kernel, I strongly suggest you use git.


Evo2.
 
Old 11-04-2014, 12:49 AM   #4
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by evo2 View Post
Hi,

what do you mean by "do not work"? If you can answer that we can probably tell you how to achieve what you want. Tools that spring to mind include tar and rsync.

However since you are working with source code, and in particular the Linux kernel, I strongly suggest you use git.


Evo2.
Well, as I explained previously I used cp -r and I apparently got the whole thing copied. But when I tried to build it some files were not found apparently. I imagine that some necessary links were not copied adequately and that generates the error since when I untar the original it worked without problem.
 
Old 11-04-2014, 12:52 AM   #5
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,
Quote:
Originally Posted by KansaiRobot View Post
Well, as I explained previously I used cp -r and I apparently got the whole thing copied. But when I tried to build it some files were not found apparently. I imagine that some necessary links were not copied adequately and that generates the error since when I untar the original it worked without problem.
Links can preserved using the appropriate options with cp. For example use "cp -a". Same is true with tar and rsync. However, I sill think you should investigate using git.

Evo2.
 
Old 11-05-2014, 10:10 AM   #6
propofol
Member
 
Registered: Nov 2007
Location: Seattle
Distribution: Debian Wheezy & Jessie; Ubuntu
Posts: 331

Rep: Reputation: 59
How about rsync?

rsync -aHAXxv /source/ /destination/

The '-x' option is just to keep it from following links. To update a pre-existing copy, you may need to add '--delete'.

I have used this to clone systems to new smaller ssd drives where 'dd' would not have worked:

Code:
rsync -aAXxv --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found/*} / /mnt/destination/
 
Old 11-06-2014, 12:08 AM   #7
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
Thank you

I am following your recommendation and checking Git. I still havent figure it out entirely how can I use this for my goals but on my way.

Git doesnt store an entire copy of all files, does it? Only snapshots of what I have modified??

I basically modify only one or two files every time I work on something, does that mean the rest of files will be just referenced? pointed at?

back to reading
 
Old 12-10-2014, 01:35 AM   #8
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
Quick question:

what is the best graphical tool to use Git (which is command based right).

Which do you prefer and why?
 
Old 12-10-2014, 07:54 AM   #9
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
Hi,

Asking what tool is the best is asking for a flamewar to start.

Personally i use gitk (should come with git itself), which is a viewer to look at the latest changes.
Another simple tool is git-gui (should also come with git) to do basic maintenance on a git repo.

Besides that, several ide's have git support build-in. Look here and here for some more info.

Cheers,
 
Old 12-10-2014, 10:33 PM   #10
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
Thank you and sorry didnt intend to

well I installed gitg. So far so good, I can see a lot of info there and it installed without any problems.
 
Old 12-15-2014, 11:20 PM   #11
KansaiRobot
Member
 
Registered: Dec 2013
Location: Japan
Distribution: Debian...very few times Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 0
Question:

I have already practiced some about Git. The commands, stuff. Now, I know that for example for a programming project in C you stage the source files (.c and .h) and pretty much ignore anything generated (.o, etc) So far for theory I understand.

Now I want to apply this to my real problem. Which is I downloaded the kernel and the userland source files (linux). I am going to use menuconfig to set some options and then build this into some image files to burn into my device.

Now the question is, which files should I stage?? or should I just stage the whole two directories that I downloaded (kernel and userland)


I realize that once I make the image files a lot of object files are going to be generated


Thank you for your help

Last edited by KansaiRobot; 12-15-2014 at 11:23 PM.
 
Old 12-16-2014, 12:37 AM   #12
ndc85430
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 92

Rep: Reputation: Disabled
The staging area is for changes you want to commit to the repository, so if you make changes to a file, then stage it and commit. After committing, if you need to move back to the state before the commit, you can do so (take a look at git reset).
 
Old 12-16-2014, 11:19 AM   #13
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Use:

cp -a /path/directory1 /path/directory2

or

cp -dpr /path/directory1 /path/directory2

Also while buiding linux kernel you can put built object files in other directory.
Untar the kernel sources and cd to it and type

make help
 
  


Reply

Tags
copy


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
How to copy directory tree to cd rom using command line? keithostertag Linux - Newbie 11 03-14-2013 02:21 PM
Copy an entire folder tree pshankland Linux - Newbie 3 09-28-2010 03:48 AM
locate and copy files - without directory tree rodda Linux - General 1 01-16-2005 02:10 AM
How to copy tree without files in it? BladeRunner Linux - Newbie 6 03-22-2004 01:01 PM
How to copy a directory tree without copying the files in it? system Linux - General 2 01-15-2002 09:36 PM

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

All times are GMT -5. The time now is 07:56 AM.

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