Jump to content

Users & transferring directories/files ?


wrc1944
 Share

Recommended Posts

This might sound lame, but I've only been using one user (wrc1944) since I started linux. I just added another one (rob), and can't figure out how to be able to be able to copy stuff into each other's /home directory.

 

I tried going into userdrake, and putting them in each other's groups, but when I go to a console in wrc1944 (or even su to root), and do something like:

 

cp- a Documents /home/rob

 

I get a no permissions error, even though "rob" is in wrc1944's groups. Same error, other way around. I know it's some chown or similar command I need, but it just escapes me! I thought root could transfer anything between different users, but I must be missing something very simple.

 

My primary objective is to have user wrc1944 be able to transfer anything into "/home/rob."

 

Thanks,

wrc1944

Link to comment
Share on other sites

they may be in the same group, but the files have to have rights for that group, specifically reading.

chown -R wrc1944:goupname ./*

in your home directory should do the trick. then you have to do the permissions...with chown...which I still don't have the hang of...so maybe someone else can pop in with tips there.

Link to comment
Share on other sites

All actions performed by a user are performed under one user ID and group ID. So, even if wrc1944 belongs to the group rob, wrc1944 can only act as a member of one group at a time. So, if you need to create files that belong to the group rob, you'll need to assume that ID (although you can also change the ownership after the fact with chown is symbolically linked to newgroup). You'd switch to rob with:

$ newgrp - rob

after you've done that and written a file to the /user/home/rob, a long listing will look like this:

-rw-r--r--    1 wrc1944    rob        2376 Jun 27 18:25 some_file.txt

 

You probably shouldn't use passwords with newgrp, as it doesn't work correctly in some distros, like RH

 

 

Note that you only need to use the newgrp is better, overall.

Link to comment
Share on other sites

tmye,

I appreciate the response, but I'm as confused as ever.

 

Re: chown -R wrc1944:goupname ./*

 

What is the groupname supposed to be? rob?

And, what does the ./* signify- any dir/file I wanted to copy to rob?

 

qnr,

I did login to as rob, and I can read files in /home/wrc, but can't copy them to rob. wrc1944 is in rob's groups.

I'm still not understanding how I can copy files in wrc1944 to /home/rob.

I guess Ineed an example of the exact code or procedure, say for a file in /home/wrc/xxx to be copied into /home/rob.

 

Do you mean while logged in as wrc1944, I open a console, and type:

 

$ newgrp - rob

 

When I do that, and type rob's password, I get:

 

[wrc1944@localhost wrc1944]$ newgrp - rob

Password:

Sorry.

[wrc1944@localhost wrc1944]$

 

Any ideas as to what's wrong?

wrc1944

Link to comment
Share on other sites

Ok, I'll give a little demo here:

 

First, I'll add the user "rob":

root@timestorm:/home/terry# adduser rob

Enter new UNIX password: 

Retype new UNIX password:

 

Next, I'll add terry (myself) to the rob group, ensuring that I include all the groups I'm already a member of, or I'll be taken out of them:

root@timestorm:/home/terry# usermod -G video,exim,lp,sys,audio,rob terry

 

Next, I'll ensure that members of group rob can write to /home/rob (normally, only the owner can):

root@timestorm:/home/terry# chmod g+w /home/rob/

 

OK, now I'll drop back to terry, and attempt to write a file to /home/rob, before I do the newgrp:

root@timestorm:/home/terry# exit

exit

terry@timestorm: /home/terry

15:47:19 $ touch /home/rob/testing.txt

touch: creating `/home/rob/testing.txt': Permission denied

 

OK, that didn't work, I'll switch to rob (note that I don't give a password, since I'm a member of the rob group):

terry@timestorm: /home/terry

15:47:34 $ newgrp - rob

terry@timestorm: /home/terry

15:54:21 $ touch /home/rob/testing.txt

 

Well, that seemed to have worked. No errors... let's check and see:

terry@timestorm: /home/terry

15:54:36 $ ls -l /home/rob/

total 0

-rw-r--r--    1 terry    rob             0 Jul  4 15:54 testing.txt

 

Yup! It worked. Now, to get back to the terry group:

terry@timestorm: /home/terry

16:06:38 $ exit

You have new mail in /var/spool/mail/terry

terry@timestorm: /home/terry

16:06:39 $

 

Now, in the future, all I have to do is $ newgrp - rob

whenever I want to write something to /home/rob

 

Note that this will also allow you to copy files from terry (wrc1944) to rob, since earlier, the permissions were changed on /home/rob to allow group members to write files, and after the newgrp, you'll will be wrc1944:rob so you'll have access to both directories.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...