LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how do I copy a whoel folder form one directory to another form the command line? (http://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-copy-a-whoel-folder-form-one-directory-to-another-form-the-command-line-221923/)

zwyrbla 08-24-2004 04:54 PM

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,

comprookie2000 08-24-2004 05:01 PM

Try man cp from the command line,not sure why you want to copy it there but Its up to you?

aznluvsmc 08-24-2004 05:07 PM

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.

mugstar 08-24-2004 05:24 PM

Quote:

Originally posted by aznluvsmc
[B]I'm not sure if you can copy a folder and execute an installation in one command line
You can string commands together in two ways:

- typing a semicolon ( ; ) between commands will execute the next command no matter what the outcome of the first

- typing two ampersands ( && ) will execute the second command _only_ if the first executed with no errors.

aznluvsmc 08-24-2004 05:44 PM

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.

Khabi 08-24-2004 06:02 PM

cp -R [from dirctory] [to directory]

amosf 08-24-2004 06:08 PM

I tend to use cp -a but it depends on how you wish to handle links and how links might be set up in the directory you are copying...

Proud 08-24-2004 06:17 PM

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?

mugstar 08-24-2004 06:40 PM

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...


All times are GMT -5. The time now is 03:25 AM.