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 am working with Ubuntu and I have a jar file in this folder /export/home/david

And I am logged in machineB as david user.

Some other user is also logged in that same machine. And I want other user to copy the above jar file from my location.

But somehow they are not able to do that as they are getting permission denied. Is there any way I can add some permission on that jar file or on my folder so that anybody can copy the files from that folder?

Update:-

Below is the result I got -

david@machineB:~$ groups david
david : uucp

otheruser@machineB:~$ groups otheruser
otheruser : app

david@machineB:~$ ls -l foo.jar
-rw-r--r-- 1 david uucp 6543346 2014-03-07 18:27 foo.jar

david@machineB:~$ ls -ld $(echo "/home/david/foo.jar" | sed -r ':a; s#(.*)/[^/]*$#\1#;p;ta')
drwxr-xr-x 22 root   root 4096 2014-05-04 08:04 /home
drwx------  4 david uucp 4096 2014-03-07 18:36 /home/david
share|improve this question
    
That should actually be possible out of the box. Please edit your question and post the output of these commands: groups david, groups otheruser and the permissions for the file (ls -l foo.jar) and its parent directories. If your file is at /home/david/foo/bar.jar, you can get them easily with: ls -ld $(echo "/home/david/foo/bar.js" | sed -r ':a; s#(.*)/[^/]*$#\1#;p;ta'). –  terdon May 13 at 23:23
    
@terdon: I have updated the question with all the details you needed. Let me know if there is anything else you want me to post. –  Webby May 14 at 0:07

3 Answers 3

up vote 1 down vote accepted

Well, for some strange reason, your $HOME directory is only accessible to you. This is not the default on any system I am familiar with, you or your sysadmin have probably set it up this way.

Anyway, all you need to do is give everyone read/execute access to your $HOME. This is the norm on most multi-user systems to allow people to share their work. Just run this command:

chmod a+rx ~/

This will set the permissions of your home to rwxr-xr-x and allow anyone to copy files from your $HOME.

share|improve this answer

chmod o+r /path/to/file will allow world read permissions on the file you want your friends to be able to copy.

chmod -R o+r /path/to/directory; find /path/to/directory -type d -exec chmod o+x {} \+ to allow other users to read all files in /path/to/directory. As Patrick pointed out, you will need to add world read and execute (chmod o+rx) on all parent directories as well. I don't know off the top of my head the easiest way to script this, but I'm sure it's possible.

share|improve this answer
2  
Don't forget, the parent directories need to be accessible as well. –  Patrick May 13 at 22:46
1  
Make that chmod -R o+rX (capital X), you don't need the find command. –  Gilles May 14 at 0:43

In order to give someone read access to a file of yours, they need to have read permission on the file and execute permission on all the directories leading to the file. For example, to allow Alice to read /home/david/for_alice/foo.jar, you need to ensure that Alice has the read permission to foo.jar and execute permission on /home/david and /home/david/for_alice. The execute permission on a directory is needed to access files inside that directory by their name; the read permission on a directory is needed to list the names of the files in the directory. Read permission on the directories is not strictly needed, but it more convenient, especially if Alice is going to use a GUI to browse the files.

At the moment, your home directory has the permissions rwx------, i.e. only you can access files in it.

If the files are local and ACL tools are available, you can grant access to Alice. The following commands give Alice read access to for_alice and all files underneath, but does not allow her to list the files in your home directory (she can still access files in your home directory if she guesses their name):

setfacl -m user:alice:x ~
setfacl -Rd -m user:alice:rX ~/for_alice
setfacl -R -m user:alice:rX ~/for_alice

If ACLs aren't possible, you'll have to allow group-wide or system-wide access.

chmod +x ~
chmod -R a+rX ~/public
share|improve this answer

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.