LinuxQuestions.org
Visit Jeremy's Blog.
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 01-04-2007, 11:40 AM   #1
linuxuser00
LQ Newbie
 
Registered: Dec 2006
Posts: 10

Rep: Reputation: 0
moving contents of one directory to another


I've been using Linux for about a week now. I just installed Red Hat 7.3 onto a new hard drive, (SCSI), that is in a HP Proliant DL320 G2. Here is my dilema. I just moved a directory from one of my Sun servers to this new hd. The contents of this directory is for a database I want the new hd to run at boot time. I want to take this new directory and copy or move it's contents to the / directory. Upon advice of a co-worker I booted the server w/Knnopix 4.4. From a terminal window I ran su - to gain root access and ran the following command:
cd /mnt/sda3 (I found the newly moved directory here)

Next I ran this command from the following prompt:
root@0[sda3]# cp -prf newdir .

This didn't work and gave me the following message:
cp 'newdir' and './newdir' are the same file

I decided to try this from the same prompt
root@0[sda3]#cd newdir
root@0[newdir]#cp *.* /
cp: cannot stat '*.*': No such file or directory

Any takers?

thanks,
linuxuser00
 
Old 01-04-2007, 11:55 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by linuxuser00
root@0[sda3]# cp -prf newdir .

This didn't work and gave me the following message:
cp 'newdir' and './newdir' are the same file
This is because you were trying to copy a directory over itself. I don't think this is what you want. You have to put a correct destination path.

Quote:
Originally Posted by linuxuser00
I decided to try this from the same prompt
root@0[sda3]#cd newdir
root@0[newdir]#cp *.* /
cp: cannot stat '*.*': No such file or directory
This means that there is any files with a dot in its name. Can you post the list of files contained in the directory you want to copy? Anyway, why don't you simply use "*" instead of "*.*"?

Last edited by colucix; 01-04-2007 at 11:57 AM.
 
Old 01-04-2007, 12:00 PM   #3
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 24, 25, RHL 5.2
Posts: 560

Rep: Reputation: 56
I would recommend doing this in single user mode rather than booting up with a live cd. I like using cp -ax [source] [destination]. There are other things to consider and I found Hard Disk Upgrade mini-HOWTO to be a great source for doing this operation. Check out section 7 for the cp command that works best for your situation.

Bill
 
Old 01-04-2007, 12:01 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
"." means current directory---what you would get if you typed "pwd". So--in your first example, you are trying to copy a file from "here" to "here". It complains because it thinks you are trying to overwrite an existing file.

the syntax of cp is: cp <options> <source> <target>

source and target can be absolute pathnames, or relative to the location. Let's say you are in /home/fred and you want to move a file or directory to /home/alice. Any of the following will work:
cp <-R if moving a directory and all contents> <file_or_directory_name> ../alice
cp <-R if moving a directory and all contents> <file_or_directory_name> /home/alice
cp <-R if moving a directory and all contents> </home/fred/file_or_directory_name> ../alice

Again, "." means "here", ".." means "up one", "../.." means "up 2" etc.
Also, the "." takes on different meaning when used with a wild card. e.g. ".*" means any file beginning with "."
 
Old 01-04-2007, 01:19 PM   #5
linuxuser00
LQ Newbie
 
Registered: Dec 2006
Posts: 10

Original Poster
Rep: Reputation: 0
This is what I did:
root@0[newdir]# cp * /
cp: omitting directory '/bin'
cp: omitting directory '/etc'
cp: omitting directory '/home'
cp: omitting directory '/lib'
cp: omitting directory '/opt'
cp: omitting directory '/root'
cp: omitting directory '/sbin'
cp: omitting directory '/usr'
cp: omitting directory '/var'

root@0[newdir]# cp -a /bin /etc /home /lib /opt /root /sbin /usr /var /
cp: '/bin' and '/bin' are the same file
cp: '/etc' and 'etc' are the same file
cp: '/home' and '/home' are the same file
cp: '/lib' and '/lib' are the same file
cp: '/opt' and '/opt' are the same file
cp: '/root' and '/root' are the same file
cp: '/sbin' and '/sbin' are the same file
cp: '/usr' and '/usr' are the same file
cp: '/var' and '/var' are the same file

I changed directories and ran the following:

root@0[sda3]# cp -prf newdir /
cp: overwrite '/newdir/etc/sysconfig/network-scripts/ifcfg-lo'?
cp: overwrite '/newdir/etc/sysconfig/network-scripts/ifdown', overriding mode 0777?
cp: overwrite '/newdir/etc/sysconfig/network-scripts/ifdown-ipv6'?
cp: overwrite '/newdir/etc/sysconfig/network-scripts/ifdown-post'?
cp: overwrite '/newdir/etc/sysconfig/network-scripts/ifdown-ppp'?
cp: overwrite '/newdir/etc/sysconfig/network-scripts/ifdown-sit'?
cp: overwrite '/newdir/etc/sysconfig/network-scripts/ifdown-sl'?

ect, ect, ect....

that continued for a few more files and then I got this:

cp: overwrite '/newdir/etc/sysconfig/network-scripts/core.25001'?
cp: writing '/newdir/etc/sysconfig/network-scripts/core.25001' : No space left on device

At the very end it gave me this:

cp: cannot creat directory '/newdir/bin' : No space left on device
cp: cannot creat directory '/newdir/home' : No space left on device
cp: cannot creat directory '/newdir/lib' : No space left on device
cp: cannot creat directory '/newdir/opt' : No space left on device
cp: cannot creat directory '/newdir/sbin' : No space left on device
cp: cannot creat directory '/newdir/var' : No space left on device
cp: cannot creat directory '/newdir/root' : No space left on device
cp: cannot creat directory '/newdir/usr' : No space left on device

there's plenty of space on the disk, especially on partition sda3. I'm trying to overwrite those directories that already exist in /. The newdir subdirectories contain information / subdirectories don't have. What else can I do?

thanks for the help!
 
Old 01-04-2007, 01:47 PM   #6
linuxuser00
LQ Newbie
 
Registered: Dec 2006
Posts: 10

Original Poster
Rep: Reputation: 0
I get the same results in single user mode. Is there anything else I can do or is there something wrong w/the newdir files?
 
Old 01-04-2007, 02:37 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
I'm afraid that you are spinning your wheels here...

First, what was in newdir when you did this?: "cp * /"--ie copy all in this folder to /
Apparently, there were some directories---to copy directories, you need cp -R AND--how did all those directories get in newdir??? (Looks like the contents of /)

cp -a /bin /etc /home /lib /opt /root /sbin /usr /var /
Here you are trying to copy /xxx into / But / already has those directories--hence the messages.
<<<BUT--I did learn something new here---the -a option>>>

Let's go back to basics: What is the current configuration and how do you want to change it?
 
Old 01-04-2007, 03:49 PM   #8
linuxuser00
LQ Newbie
 
Registered: Dec 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks for the reply...
This is what I'm trying to do. I have a database running on a machine I want to get rid of. I want to move the database to a new machine. Right now, (on the new machine), the hard drive has the basic config, newly formated disk. I copied /bin /etc /home /lib /sbin /var /root and /usr directories of the old DB to a sun server. I then copied over those dir's from the sun machine to the new machine and placed them under the directory /newdir. This is what you see in the / directory:

localhost#cd /
localhost/#ls
bin etc lib mnt proc sbin tmp
boot home lost+found ntpdate.sh newdir usr dev
initrd misc opt root var
localhost/#cd newdir
localhastnewdir#ls
bin etc home lib opt var root usr

I have to overwrite what's in / with what's in newdir.
 
Old 01-04-2007, 04:19 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Well....
I do not understand why you would need to copy all those directories just to move a database.

If you really need to do what you said, then you cannot do it with the machine running from the disk (partition) mounted at /. You will have to run from a live CD, another OS, etc.

But first, what directories actually hold the database? Isn't that what needs to be copied???
 
  


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
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 05:02 AM
reading contents of a folder and moving that content vb.net mrobertson Programming 0 02-17-2006 09:14 AM
Moving contents of /var to separate partition TexasDex Linux - Software 2 03-01-2004 09:30 PM
reposition gimp selection area without moving contents mrtwice Linux - Software 6 12-19-2003 05:26 PM
mv the contents of one directory to the parent directory warkrime Linux - Newbie 4 07-14-2003 08:03 PM

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

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