how do I copy a whoel folder form one directory to another form the command line?
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.
how do I copy a whoel folder form one directory to another form the command line?
HI im trying to learn how to use the command line in linux and right now im trying to install firefox to the /usr/local directory. Basicaly what im trying to do is copy the folder firefox from /home/me to /usr/local then run the install file in firefox once it is copies over and i want to do all this from the command line with root privelages instead of having to logout of x as user then login to x as root. Thanks,
I'm not sure if you can copy a folder and execute an installation in one command line but you can try to tar the folder and then 'untar' it in the new location. This will keep the folder hierarchy intact.
From within the Firefox directory issue the following command:
tar cf - . | (cd /usr/local; tar xvf -)
This will copy the Firefox folder hierarchy to the new location intact. I got that one from my Running Linux 4th Edition book.
Ok, so then will this command tar the directory, then untar it in the proper location and execute Firefox afterwards?
tar cf - . | (cd /usr/local; tar xvf - && firefox/firefox)
I used the && to ensure that it will only try to run firefox if the untar succeeds. I think my path specification is right with firefox/firefox to inform the shell where the executable file is located in case the actual path is not part of $PATH.
Erm, normally the make install command copies the compiled stuff into it's system-wide location at eg /usr/local, so putting the files there to start with and after you've compiled them with that directory free might not be the best move. What's telling you to move the files there? Why not just make install them?
Because the firefox installer by default installs to the current working directory. Although I believe you could pass /usr/local as an argument to the installer, as an alternative to moving everything manually. You would still need to be root to have write access to /usr/local.
Why not do `su -` and do it the long way? Still saves you from logging in and out...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.