Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
PTrenholme suggested the usage of mount above. Can you tell me if I'm on the right track? Is it some subtle use of mv -u ? I know someone else asked this problem, but I'm equally eager to solve it.
no it's not. as detailed in the man pafge it's for moving mount points, not directories. e.g. move /dev/hda5's current mount point of /home to /oldhome
How can I 'consolidate' several folders with each a partially identical structure, to one folder ?
For example
Given /test
With /test/A/ and /test/B/
And /test/A/a/b/c/ and /test/B/a/b/c/
Folders a,b,c have identical names but different content in A and B
How can I make that /test/a/b/c without loosing or overwriting any file?
Easy isn't it?
Thanks
Having read through your question a few times, I suspect it would be useful for you to phrase your question a little more precisely, possibly with an example.
This is a simple example for files only. He wants to merge all the sub directories within the Music folder in such a way such that there is one directory tree having the same directory structure as A (or B; they're identical) and containing all the files in A and B.
This is a simple example for files only. He wants to merge all the sub directories within the Music folder in such a way such that there is one directory tree having the same directory structure as A (or B; they're identical) and containing all the files in A and B.
Aaaah, thank you Gregorian. I guess, if this were to be a one-off and not a frequently recurring operation, a simple work-around with "tar" would work.
Using Gregorian's example with the destination directory of "C"
cd A
tar cvf a.tar Music <enter>
cd ..
cd B
tar cvf b.tar Music <enter>
cd ..
cd C
mv B/b.tar ./b.tar
mv A/a.tar ./a.tar
tar xvf a.tar <enter>
tar xvf b.tar <enter>
With the "-k" option you can further prevent any undesired overwrites.
Haha, good spot that! Man is my most used word at the moment, all three letters on my laptop are disappearing fast!
I do however have sympathy. The man pages will be your best bet though, as you will end up understanding it better.
I have a question too, I am trying to back up all users home dirs as part of a script, and have want them to go to a specific file at a specific regular interval (will use logger for that) but I was wonderin... to pull ALL users stuff from their home dirs, would I just need to point tar to /home/ ? leaving it blank? This gives me a huge amount of info, way more than I think is necessary,but hey, I'm a noob too! Perhaps there is a variable I can use that will pull in what I want and not all that grey matter I dont know about. And also , if i use /home/ will this just be a dir listing? should I be using the find command and piping a variable through it with grep? I am getting a bit confused.....
edit: I had a similar operation for music files and alas I did it the hard way....
I copied everything to one folder, several commands, but I got rid of all me duplicates in the process
I have a question too, I am trying to back up all users home dirs as part of a script, and have want them to go to a specific file at a specific regular interval (will use logger for that) but I was wonderin... to pull ALL users stuff from their home dirs, would I just need to point tar to /home/ ? leaving it blank? This gives me a huge amount of info, way more than I think is necessary,but hey, I'm a noob too! Perhaps there is a variable I can use that will pull in what I want and not all that grey matter I dont know about. And also , if i use /home/ will this just be a dir listing? should I be using the find command and piping a variable through it with grep? I am getting a bit confused.....
I'm not a 100% sure I follow. If you want ALL user stuff
I would expect it to be heaps.
Yes, "tar cf /big_disk/home.tar /home" will do what you want.
For subsequent runs you can use "tar uf /big_disk/home.tar /home".
To the best of my knowledge tar won't update compressed archives,
so if you want the archive compressed you'll have to do uncompressing
and compressing yourself before and after archiving.
e.g.
Code:
#!/bin/sh
gunzip /big_disk/home.tar.gz
tar uf /big_disk/home.tar /home
gzip /big_disk/home.tar
Of course that implies that the first run was done
manually all together, and that you manually compressed it.
Cheers,
Tink
P.S.: Glad you find man helpful - I use it a lot :}
You don't have to know everything, just know where and
how to find it ;}
Thanks Tink, yes I need all the users stuff, so, will this do? Or is it just an ls of their home?
Also, how can I prevent people from logging on temporarily? Is there a way to use the nologin command and give it a time variable for say , while the backup is actually running?
ie:
nologin
tar -cvf /var/local/backup/homedir-$(date +%a-%b-%d).tar /home
login
This doesnt seem correct, and the man pages for no login are sparse, is there another command I could use?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.