PDA

View Full Version : The cp command



Ullrich
23rd May 2007, 08:03 PM
[root@ Nissanka]# find / -name gnupg
/gnupg
/usr/lib64/gnupg
/usr/share/gnupg

[root@ Nissanka]# pwd
/home/Nissanka

[root@ Nissanka]# cp /gnupg /home/Nissanka/Documents
cp: omitting directory `/gnupg'
[root@ Nissanka]#
----------------------
I made a pair of keys. Now I am trying to copy them for the purpose of saving. I must copy all 'gnupg' folders and the keys for future use. If I change the computers, I will be able to use all the keys.
Why didn't the 'cp' command work?
Something is omitting. What is it?

leigh123linux
23rd May 2007, 08:07 PM
try

su -
mkdir /home/Nissanka/Documents/gnupg
cp /gnupg/* /home/Nissanka/Documents/gnupg

marcrblevins
23rd May 2007, 08:09 PM
/gnupg is a directory?
If so:
mkdir /home/Nissanka/Documents/gnupg
cp /gnupg/* /home/Nissanka/Documents/gnupg

Or use your preference Linux file manager.

Ullrich
23rd May 2007, 09:04 PM
I thank both of you for the replies.
I didn't perform the step ' su - '
I just wrote the command you told me and it worked.
----------------------------------------------------------------------------------------
[root@ Nissanka]# mkdir /home/Nissanka/Documents/gnupg
[root@ Nissanka]# cp /gnupg/* /home/Nissanka/Documents/gnupg
[root@ Nissanka]#
-----------------------------------------------------------------------------------------
I need further help.
Did I copy everything now?
I will copy them on to a USB folder. Because these keys are necessary even if I change the computers. I made even the revocation key. Where is the revocation key? Is it inside this folder?
As you see there are two more folders:
/usr/lib64/gnupg
/usr/share/gnupg
Do I have to copy them too?

marcrblevins
23rd May 2007, 09:38 PM
Oh, the subdirectory... I believe -r is for recursive.

One if these should work:
cp -r /gnupg /home/Nissanka/Documents/gnupg
cp -r /gnupg/* /home/Nissanka/Documents/gnupg
cp -r /gnupg/. /home/Nissanka/Documents/gnupg

Play around with it til you get it right.

Ullrich
23rd May 2007, 09:55 PM
Yes, the following worked:
-------------------------------------------------------------------
[root@]# cp -r /gnupg /home/Nissanka/Documents/gnupg
[root@ Nissanka]#
----------------------------------------------------------------------
Did I copy everything on the following folders?

/usr/lib64/gnupg
/usr/share/gnupg
Please tell me.

Ullrich
23rd May 2007, 10:12 PM
I tried in vain to copy the 'gnupg' folder to my USB drive.
My USB drive is on the 'mnt' folder.
I created a folder called 'usbflash' inside the 'mnt' folder
----------------------------------------------------------------------
[root@ gnupg]# ls
gnupg [ This one is not a file; it is a folder.]
gpg.conf
pubring.gpg
pubring.gpg~
random_seed
secring.gpg
trustdb.gpg


[root@ gnupg]# cp /gnupg/* /home/Nissanka/mnt/usbflash/gnupg
cp: target `/home/Nissanka/mnt/usbflash/gnupg' is not a directory
[root@ gnupg]#

What is the problem?

doss
23rd May 2007, 10:40 PM
[root@ gnupg]# cp /gnupg/* /home/Nissanka/mnt/usbflash/gnupg
cp: target `/home/Nissanka/mnt/usbflash/gnupg' is not a directory
[root@ gnupg]#

What is the problem?

should be



#mkdir /mnt/usbflash/gnupg
#cp /gnupg/* /mnt/usbflash/gnupg


good luck

Ullrich
23rd May 2007, 10:55 PM
Thanks doss
It worked.
------------------
[root@ gnupg]# mkdir /mnt/usbflash/gnupg
[root@ gnupg]# #cp /gnupg/* /mnt/usbflash/gnupg
[root@ gnupg]#
---------------------------------------------------
Did I copy everything on to the USB memory?
I badly need this. I want to save this for the future. I might change computers. I have been changing computers every year.

Ullrich
23rd May 2007, 11:00 PM
I forgot to tell you the following:
In order to backup, I moved the folder to another location.
I did the following after the creation of the keys.

1. mv /.gnupg /gnupg

2. ln -s /gnupg /.gnupg

doss
23rd May 2007, 11:02 PM
you copied everything in the /gnupg dir but if you want to copy any reclusive folders you need the -r option as explained above

doss
23rd May 2007, 11:04 PM
you didnt need to do that but it wont hurt anything

Ullrich
25th May 2007, 11:36 AM
On my USB drive, I created a folder named 'Gnupg from the root'.
I want to copy the 'gnupg' folder to that folder.

After the creation of the keys, I ran the following command to copy everything on the ' .gnupg ' folder to 'gnupg' folder. By default, all your 'gpg' stuff goes to the ' .gnupg ' folder

mv / .gnupg /gnupg
[ The above copied everything on the ' . gnupg ' to ' gnupg '. ]

I want to copy the ' gnupg ' folder to ' Gnupg from the root ' folder on the USB drive.

---------------------------------------------------------------------------------------------------------
[Nissanka@]$ pwd
/home/Nissanka

[Nissanka@]$ cd /gnupg
[Nissanka@ gnupg]$ pwd
/gnupg
[Nissanka@ gnupg]$
[Nissanka@c gnupg]$

[Nissanka@ gnupg]$ ls
gpg.conf pubring.gpg pubring.gpg~ random_seed secring.gpg trustdb.gpg
[Nissanka@ gnupg]$
----------------------------------------------------------------------------------------------------------

Why didn't the following command work?
[Nissanka@]$ su root
Password:
[root@]# mount /dev/sda1 /mnt/usbflash [ I mounted the USB drive.]


[root@ Nissanka]# cp /home/Nissanka/gnupg /dev/sda1/mnt/usbflash/'Gnupg from the root'
cp: accessing `/dev/sda1/mnt/usbflash/Gnupg from the root': Not a directory
[root@ Nissanka]#


[root@ Nissanka]# cp /home/Nissanka/gnupg /home/Nissanka/dev/sda1/mnt/usbflash/'Gnupg from the root'
cp: cannot stat `/home/Nissanka/gnupg': No such file or directory


[root@ Nissanka]# cp /gnupg /home/Nissanka/dev/sda1/mnt/usbflash/'Gnupg from the root'
cp: omitting directory `/gnupg'
----------------------------------------------------------
As you see I tried 3 different commands.

Kirurgs
25th May 2007, 12:30 PM
mount /dev/sda1 /mnt/usbflash
cp -R /home/Nissanka/gnupg /mnt/usbflash
cd /mnt/usbflash
mv gnupg Gnupg\ from\ the\ root
ls

Ullrich
25th May 2007, 12:45 PM
The 'mount' command failed. Please read the following:

[root@ Nissanka]# mount /dev/sda1 /mnt/usbflash
fusermount: mount failed: Device or resource busy
FUSE mount point creation failed
Unmounting /dev/sda1 ()
[root@ Nissanka]#

I think the reason is it is already mounted. What do you think?

Kirurgs
25th May 2007, 12:56 PM
I posted WHOLE solution from the start!!!
Omit mount command if that's already mounted!

Kirurgs
25th May 2007, 01:05 PM
this could be helpful to read as well:
man mount
man cp
man mv

Ullrich
25th May 2007, 01:37 PM
Thanks Kiurugs
It didn't work.

[root@ Nissanka]# cp -R /home/Nissanka/gnupg/mnt/usbflash
cp: missing destination file operand after `/home/Nissanka/gnupg/mnt/usbflash'
Try `cp --help' for more information.
[root@ Nissanka]#

I guess the above means that there is no folder to land the file. Therefore I created a folder inside the 'usbflash' folder. The name of the folder is ' TEMP '.

I tried in vain again.
-----------------------------------------------------------------------------------
[root@ Nissanka]# cp -R /home/Nissanka/gnupg/mnt/usbflash/TEMP
cp: missing destination file operand after `/home/Nissanka/gnupg/mnt/usbflash/TEMP'
Try `cp --help' for more information.
[root@ Nissanka]#

--------------------------------------------------------------------------
Then I created a file inside the 'usbflash' folder.
The name of the file is 'TEMP1'.
[root@ Nissanka]# cp -R /home/Nissanka/gnupg/mnt/usbflash/TEMP1
cp: missing destination file operand after `/home/Nissanka/gnupg/mnt/usbflash/TEMP1'
Try `cp --help' for more information.
[root@ Nissanka]#
It didn't work.
What is the problem?
Now I am going to the gym for training. Please leave your messages. I will be back after 5 or 6 hours. My gym is far away from my home.

Kirurgs
25th May 2007, 02:29 PM
Hey, check what you are doing...
You just blindly execute smth and don't see any obvious errors... Too bad...

I wrote:
cp -R /home/Nissanka/gnupg /mnt/usbflash
You try to execute:
cp -R /home/Nissanka/gnupg/mnt/usbflash

There IS a difference...
Now, try to do as you have been told ;)

doss
25th May 2007, 05:24 PM
post the output of fdisk -l

Ullrich
25th May 2007, 08:44 PM
Thanks for the replies.
I just came home from the gym.

------------------------------------------------------------------
[Nissanka@ ~]$ su root
Passw Nissanka]# cd /mnt
[root@ mnt]# mount /dev/sda1 /mnt/usbflash
The above is to mount the USB stick. I think this is an unnecessary step because when I inserted the stick, it reacts immediately and shows me the contents of it. So I believe it gets mounted automatically.
-------------------------------------------------------------------

[root@ mnt]# cp -R /home/Nissanka/gnupg /mnt/usbflash
cp: cannot stat `/home/Nissanka/gnupg': No such file or directory
[root@ mnt]#


[root@ mnt]# cp -R /home/Nissanka/gnupg/mnt/usbflash
cp: missing destination file operand after `/home/Nissanka/gnupg/mnt/usbflash'
Try `cp --help' for more information.
[root@mnt]#

Yes, the two commands gave me different answers. If you read the above, you will read the two different outputs. This is very interesting. What makes the difference? Does a just tiny space makes difference?

-------------------------------------------------------------------------------------------

The command ' fdisk -l ' command didn't work. I knew this problem.
I must open another console and log in differently.
su -
password:
All right, here is the output of 'fdisk -l ' command.




[Nissanka@x ~]$ su -
Password:
[root@ ~]# fdisk -l

Disk /dev/hda: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


Device
Boot
Start
End
Blocks
ID
System
/dev/hda1
*
1
4551
36555876
7
HPFS/NTFS
/dev/hda 2

4553
24321
158794492+
83
Linux
/dev/hda 3

4552
4552
8032+
f
W95 Ext'd (LBA)

Partition table entries are not in disk order

Disk /dev/sda: 163.9 GB, 163928604672 bytes
255 heads, 63 sectors/track, 19929 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes



Device
Boot
Start
End
Blocks
ID
System
/dev/sda1
*
1
7690
61769893+
7
HPFS/NTFS
/dev/sda 2

7691
19929
98309767+
f
W95 Ext'd (LBA)
/dev/sda 5

7691
9220
12289693+
b
W95 FAT32
/dev/sda 6

9221
19420
81931468+
83
Linux
/dev/sda 7

19421
19675
2048256
82
Linux swap / Solaris
/dev/sda 8

19676
19929
2040223+
82
Linux swap / Solaris








Disk /dev/sdb: 503 MB, 503840256 bytes
4 heads, 8 sectors/track, 30751 cylinders
Units = cylinders of 32 * 512 = 16384 bytes

Device
Boot
Start
End
Block
ID
System
/dev/sdb1
*
1
30752
492027+
E
W95 FAT16 (LBA)

[root@ ~]#

Ullrich
25th May 2007, 08:47 PM
The output of 'fdisk -l' looks horrible.
I will try to send you a screen shot. I have forgotten the way of sending a screen shot. I will try now.

Ullrich
25th May 2007, 08:50 PM
I wrote the output of the 'fdisk -l' command manually to the wordprocessor and saved it. Here is a screen shot of the wordprocessor document.

Ullrich
25th May 2007, 08:54 PM
Again a screen shot.

Ullrich
25th May 2007, 08:58 PM
Here is the last part of the screen shot.

doss
25th May 2007, 10:03 PM
------------------------------------------------------------------
[Nissanka@ ~]$ su root
Passw Nissanka]# cd /mnt
[root@ mnt]# mount /dev/sda1 /mnt/usbflash
The above is to mount the USB stick. I think this is an unnecessary step because when I inserted the stick, it reacts immediately and shows me the contents of it. So I believe it gets mounted automatically.
-------------------------------------------------------------------

if its mounting automatically then dont worry about that step then :p this wouldnt work anyway because your usb drive is NOT sda1



[root@ mnt]# cp -R /home/Nissanka/gnupg /mnt/usbflash
cp: cannot stat `/home/Nissanka/gnupg': No such file or directory
[root@ mnt]#


[root@ mnt]# cp -R /home/Nissanka/gnupg/mnt/usbflash
cp: missing destination file operand after `/home/Nissanka/gnupg/mnt/usbflash'
Try `cp --help' for more information.
[root@mnt]#

Yes, the two commands gave me different answers. If you read the above, you will read the two different outputs. This is very interesting. What makes the difference? Does a just tiny space makes difference?

-------------------------------------------------------------------------------------------

umm...yes a space makes all the difference...its the difference between trying to copy something from one directory to another and supply 1 two few arguments to the cp command...?? your joking though im sure



[root@ mnt]# cp -R /home/Nissanka/gnupg /mnt/usbflash
cp: cannot stat `/home/Nissanka/gnupg': No such file or directory
[root@ mnt]#


based on this output i would say you dont have a folder gnupg....im just guessing here but try this


cp -R /gnupg /mnt/usbflash

if that doesnt work then you have completely lost me as to what your directory structure is

Ullrich
25th May 2007, 10:48 PM
doss

The command worked.

[root@ ~]# cp -R /gnupg /mnt/usbflash
[root@ ~]#

You don't find any strange message. So it was fine.

Ullrich
25th May 2007, 11:00 PM
Yes, it worked.
Now I find everything on the folder 'gnupg' which is inside the folder 'usbflash'.
However, the target is to put them inside the USB stick.

---------------------------------------------------------------------------------
[Nissanka@ ~]$ su root
Password:
[root@x ]# cd /mnt
[root@ mnt]# ls
cdrom
usbflash
[root@ mnt]# cd usbflash
[root@ usbflash]#
As the above shows, now I am on the 'usbflash' folder. I created this folder inside the 'mnt' folder some 6 months ago.
---------------------------------------------------------------------------------------
[root@ usbflash]# ls
gnupg
Torrents
Documents and Settings
TEMP
pagefile.sys

-------------------------


[root@ usbflash]# cd gnupg
[root@ gnupg]# ls
gpg.conf pubring.gpg pubring.gpg~ random_seed secring.gpg trustdb.gpg
[root@ gnupg]#
As you see, inside the 'gnupg' folder, files have safely landed.
However, this 'usflash' folder is a subfolder to 'mnt' folder.
I must copy them on to the USB module. This is the target.

Ullrich
25th May 2007, 11:04 PM
Eureka!
I just tried the drag and drop method.
I just drag and dropped the folder on to the USB stick.
It worked. Now it is on the USB memory.

Ullrich
25th May 2007, 11:09 PM
I need another help to properly copy the 'revocation file or rather revocation certificate' too. Now it is getting late. I must sleep.
I trained for 2 hours today. I exceeded the limits because I had so much of energy today. Usually I train for about 90 minutes.

I will ask your help tomorrow. I must sleep now.

Ullrich
26th May 2007, 11:23 AM
Usually, the 'list-keys' command should show my public key.
Yesterday, I used a Knoppix live CD.
I think it has corrupted the system.
-----------------------------------------------

[Nissanka@ ~]$ su root
Password:
[root@ Nissanka]# gpg --list-keys
/root/.gnupg/pubring.gpg
------------------------
pub 1024D/B38F13B4 1999-07-03
uid Chamath Dassanayake <chamath@t-online.de>
sub 2048g/65854110 1999-07-03
[root@ Nissanka]#
------------------------------------------------------------------------------------------
Some time ago I downloaded the public key of Chamath. I think I did it nearly 3 months ago. I made the key pair just 3 days ago.
My public key is missing. I guess some corruption has taken place.
The above doesn't show my public key.
---------------------------------------------------------------------------------------------



Just after the creation of the keys, I ran the command and got the following output. Now I don't get the same output. Luckily, I saved the output on a file.
[Nissanka@~]$ gpg --list-keys
/home/Nissanka/.gnupg/pubring.gpg
---------------------------------
pub 1024D/6BEE1A06 2007-05-23
uid Nissanka De Silva (Je suis un grand homme.) <nissanka@swipnet.se>
sub 2048g/90022BFC14 2007-05-23
-----------------------------------------------------------------------------------------------
What do you think?

Ullrich
26th May 2007, 06:22 PM
Another idea crossed my mind. It is to remove everything on the gnupg folder and reinstall the program again. I have successfully copied the keys on to a USB module.

Before erasing, I must copy the revocation certificate too. The following is my revocation certificate which I saved as a file using the 'gedit' program.

--------------------------------
iGkEIBECACkFAkZUOIciHQBJIHdhbnQgdGhlIHJldm9jYXRpb2 4gY2VydGlmaWN0
ZQAKCRD9LhUma+4aBqWoAJ9QFGq/ViLXqpGF+ZmYBhdNk3CeDACeLnuXiOBMssGw
m6cCMzcwHttKS1Y=
=z71u
------------------------------------
I am not sure about how to copy the revocation certificate. I can just copy the above on to the USB module..
Is this enough? I just want to copy the revocation certificate too on to the USB module.
Please tell me.


Afterwards, we can remove everything belong to the 'gnupg' and reinstall.

[root@ Nissanka]# find / -name gnupg
/gnupg
/usr/lib64/gnupg
/usr/share/gnupg

[root@ Nissanka]# find / -name gpg
/etc/apt/gpg
/usr/bin/gpg
[root@ Nissanka]#

Ullrich
28th May 2007, 06:58 PM
Nobody has seen my question for more than 24 hours. I solved many of it; I have copied the revocation on to a USB module. Now i need your help to the following:

1] Remove everything belong to the gnupg from my system.

2] Afterwards, I want to download gnupg again and install.

-----------------------------------------------------------------
[root@ Nissanka]# find / -name gnupg
/gnupg
/usr/lib64/gnupg
/usr/share/gnupg

[root@ Nissanka]# find / -name gpg
/etc/apt/gpg
/usr/bin/gpg
[root@ Nissanka]#