9

I'm trying to copy a file from my homedir to /usr. How do I setup the permissions to allow this?

$ chmod 777 KeePass-2.14.zip
$ cp KeePass-2.14.zip /usr/keepass/
cp: cannot create regular file `/usr/keepass/KeePass-2.14.zip': Permission denied
$ sudo cp KeePass-2.14.zip /usr/keepass/
cp: cannot stat `KeePass-2.14.zip': Permission denied
$
ripper234
  • 31,763
  • Can you paste the line in /etc/sudoers that allows your user to sudo? It should be something like phunehehe ALL=(ALL) ALL... – phunehehe Apr 05 '11 at 15:49
  • Perhaps you could first tell us why you are trying to copy this file to /usr? Seems like an unusual thing to do. If you are trying to unpack for an install, that is the wrong place to put it in. Something like /usr/local/src would be better. At least, that is what I use. Is there no binary package available for keepass for your OS? – Faheem Mitha Apr 05 '11 at 16:17
  • @Faheem - why /.../src? Why not /usr/local? I haven't memorized the folder structure yet, I just want somewhere to put it (looking for the equivalent of C:\Program Files). – ripper234 Apr 05 '11 at 20:15
  • /usr/local/src is customary, I believe. The FHS says "/usr/local/src: Local source code". See http://www.pathname.com/fhs/pub/fhs-2.3.html#USRLOCALLOCALHIERARCHY – Faheem Mitha Apr 05 '11 at 20:27

3 Answers3

19

I'm guessing that sudo cp can't stat KeePass-2.14.zip because $HOME is on an NFS mount, and the NFS server doesn't grant your machine root permission to the NFS share.

Try:

cp KeePass-2.14.zip /tmp
sudo cp /tmp/KeePass-2.14.zip /usr/keepass/
Ken Bloom
  • 400
0

To answer the original question, I would adjust the permissions after the event. Just copy the file across (doesn't really matter with what permissions) and then change the permissions to match the place where you are copying it to. But in this case, I doubt that what you are trying to do is what you really want to do.

Faheem Mitha
  • 35,108
-1

Change permission on directory /usr/keepass to 777 and then cp the files to /usr/keepass/