Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
$
share|improve this question
    
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 5 '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 5 '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 5 '11 at 20:15
    
/usr/local/src is customary, I believe. The FHS says "/usr/local/src: Local source code". See pathname.com/fhs/pub/fhs-2.3.html#USRLOCALLOCALHIERARCHY –  Faheem Mitha Apr 5 '11 at 20:27
add comment

3 Answers

up vote 5 down vote accepted

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/
share|improve this answer
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
    
How does 777 help when sudo cp ... doesn't work? –  phunehehe Apr 5 '11 at 15:28
    
True. But he didn't provide information about permissions on /usr/keepass. Also he might has limited sudo rights. –  powerwade Apr 5 '11 at 15:50
    
I have nothing against your answer (I didn't downvote, in case you are suspecting that). I just think that you can add a little bit more to it. –  phunehehe Apr 5 '11 at 15:58
    
Yes, another mystery down-voter strikes again. (on several levels) ..... WHY!??? ..... ;-) –  shellter Apr 5 '11 at 16:20
    
@powerwade: the error message that he gets when he uses sudo isn't what you'd see if you had limited sudo rights. –  Ken Bloom Apr 5 '11 at 17:37
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.