LinuxQuestions.org
Review your favorite Linux distribution.
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 10-25-2006, 06:54 AM   #1
IonMarais
LQ Newbie
 
Registered: Oct 2006
Posts: 19

Rep: Reputation: 0
What copy commands does Linux have?


Hey there guys, I am using RH and are trying to copy a folder from the cdrom to a destination folder on the hard drive. I tried using the cp command but wichever way I try it I am getting errors. I think I am not using the command correctly. I found out about the command in a linux book but it doesnt however tell me in what context to use the command. I am not sure wether I should be in the source folder when typing the command or in the destination. When I try to copy the folder from the source. It tells me that the file I am trying to copy doesnt exist. But if I use the dir or ls command it shows the file to be in the folder that I am trying to copy from.I have checked and I am not typing the name incorrectly. If some one could please show me a example of how to use the command properly or give me a alternate tool to work with I would really appreciate it!
 
Old 10-25-2006, 07:34 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Quote:
Originally Posted by IonMarais
I tried using the cp command but wichever way I try it I am getting errors. I think I am not using the command correctly.
What errors are you getting?

Quote:
Originally Posted by IonMarais
I found out about the command in a linux book but it doesnt however tell me in what context to use the command.
Have you tried:
Code:
man cp
info cp
"man" and "info" commands, always specifying the command as second parameter, can show you some useful information on how to use the commands.
There are also useful online resources, like this forum (tutorials section for instance), tldp.org, etc.
[/QUOTE]

Quote:
Originally Posted by IonMarais
I am not sure wether I should be in the source folder when typing the command or in the destination.
That is irrelevant to your command, as long as you make sure that your source file/directory and target file/directory are correctly specified (ie with relative or absolute path if needed).

In general (this goes for all commands):
1. if the file/dir is in the current folder, you can omit the path or specify "./" as path.
2. if it is not, then you should specify a path, which can be absolute (ie starts with '/') or
relative (w.r.t. the current directory).
Example:
if your current directory is "/var/log", then the following are fully equivalent and all point to the file "/var/log/maillog"
maillog
./maillog
/var/log/maillog
../log/maillog #Note: ".." points to the parent directory, "." to the current one.
../../var/log/maillog

In the case of "cp" for copying, the correct syntax is:
Code:
cp source target
It is not important if the source is or is not located in the current directory. Just make sure to include it's path if it isn't. Same goes for target.

Quote:
Originally Posted by IonMarais
It tells me that the file I am trying to copy doesnt exist. But if I use the dir or ls command it shows the file to be in the folder that I am trying to copy from.
Please show us the exact commands you used and the error messages/results you got from them.

Also, please note that you need to use the "-r" option of cp to copy entire directory trees, ie:
Code:
cp -r /some/source/dir /some/target/dir
Each command can have it's own options. You'll need to use the "man" and "info" commands as described above to find out the options for a specific command.

Just for the record: there are some variants of "cp", like
cpio (for copying to I/O devices like tapes) and rsh & ssh (for copying to remote machines), to mention a few.

Last edited by timmeke; 10-25-2006 at 07:36 AM.
 
Old 10-25-2006, 07:35 AM   #3
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,587

Rep: Reputation: 121Reputation: 121
Edit: Timmeke's response was faster and better
 
Old 10-25-2006, 08:14 AM   #4
IonMarais
LQ Newbie
 
Registered: Oct 2006
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks appreciate it , I did however try cp --help and it did not answer my question. I did not try the -r extension. I think that is what I did wrong. Sorry for not giving you the error details but what I told you was more or less a summary of it.It was cp: cannot stat "filename" no such file or directory. But thanks again I will get it right now.
 
Old 10-26-2006, 03:40 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
"cannot stat" and "no such file or directory" refer to the same problem: cp being unable to find the mentioned source file/directory. This is typically caused by either a typo in the name (remember: case sensitive!) or
an incorrect path.

@titopoquito: thanks for the compliment!

Last edited by timmeke; 10-26-2006 at 03:42 AM.
 
  


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
How to copy files from an entire directory tree using terminal commands??? lusius188 Linux - General 3 04-10-2006 12:23 PM
CLI copy is greater than GUI copy ?? 0_o killahsmurf Slackware 14 01-04-2006 12:53 PM
Suse Linux Commands For These Aix Commands? Vaskar Guha Linux - Software 2 12-19-2005 01:45 AM
boot error after using Copy Commander to copy debian system onto larger new drive Interceptor Linux - Hardware 7 05-04-2003 01:40 PM
complet linux NewBie(problems with the downloaded copy of linux) merlin Linux - Software 3 03-25-2002 02:38 PM


All times are GMT -5. The time now is 11:51 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