LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-04-2005, 02:48 AM   #1
pal
Member
 
Registered: Dec 2004
Location: india
Posts: 60

Rep: Reputation: 15
Chmod ,chown ,chgrp commands not working proper----------------


hello sir, We are students working on linux project and not able to implement the commands chown,chmod ,chgrp We had already posted this query.May be we are not aware of these
commands properly.Kindly help us.
We are giving an example-----
The users test1 , test2, test3 are under group( named group1) .
The users test4 , test5 ,test6 are under group ( named group2).
Now with chmod command if we give
# chmod -R 770 test2
Then it means the group ( to which user test2 belongs to) will also have all permissions . So if we login as test1 ,we should access all the files of test2 user.But test1 can not access the files.


------------
now we will consider chown command.
if we have one file named abc under test2 user then if we issue the command
# chown test1 /home/test2/abc
then the user test1 should be the owner of file abc.And this file should not be there under home directory of user test2.But it is not happening. Are we right or not using chown command
-------------------------
Now we will consider the command chgrp. If we issue the command
# chgrp group2 /home/test2/abc
Now the group2 members should have the access to file abc.But still this file is under the test2 .
we tried seeing some documents but we could not find it in detail.
 
Old 03-04-2005, 02:50 AM   #2
ksgill
Senior Member
 
Registered: Apr 2003
Location: Toronto, Canada
Distribution: Ubuntu Jaunty (9.04)
Posts: 1,044

Rep: Reputation: 45
are u issuing those commands as a superuser (root) because if you are not, it wont work properly.
 
Old 03-04-2005, 02:54 AM   #3
krishvij
Member
 
Registered: Feb 2005
Location: India
Distribution: RHEL 3
Posts: 108

Rep: Reputation: 15
Well, you have got it all right. Just log in as root and then check the permissions on the /home directory. you can do that by giving the command

ls -ld /home

You will need to give the same permissions to this directory as what you want to give for the files under the user's directory. Also, check the permissions in the users' home directory as well.

even though u might change permissions on the files under a user's home directory, they are overridden by the permissions set on /home as well as the users' home directory. Just try this out. I think it should solve ur problem.
 
Old 03-04-2005, 03:23 AM   #4
pal
Member
 
Registered: Dec 2004
Location: india
Posts: 60

Original Poster
Rep: Reputation: 15
thanks for response sir
you mean to say that if we want to give group permission in the home directory of test2( /home/test2)
with command chmod 770 /home/test2,Then we have to first give the same permission to the /home directory also

But sir if there are two users under home directory and For one user suppose we are giving group permissions as above and for the other user we are not giving group permissions.Then at that situation how we can set the permissions of actual /home directory.
we are executing the commands as root user
 
Old 03-04-2005, 03:30 AM   #5
krishvij
Member
 
Registered: Feb 2005
Location: India
Distribution: RHEL 3
Posts: 108

Rep: Reputation: 15
let us say test1 should not access test2's files and test2 should access test1's files. what u do is that in the home directory of test2 execute the command to disable group users from accessing the files with the command

chmod 700 *

that should do the trick. in linux the directory hierarchy permissions are actually taken forward.
 
Old 03-04-2005, 08:40 AM   #6
pal
Member
 
Registered: Dec 2004
Location: india
Posts: 60

Original Poster
Rep: Reputation: 15
sir ,Actually we mean to say that the user test1 and test2 are in one group.If we give permission in the /home directory as
# chmod 770 /home
Then
#chmod -R 770 /home/test1
It means now test2 can access the files of test1 ( both in the same group)
But if we now login as test2 and try to access
# cd /home/test1

The message is coming that the permission is not there.
But if we give the permission as
#chmod 771 /home/test1
Then we are able to do cd to the /home/test1 ,it means test2 is considered as other member and not the group member of test1.If we see the /etc/group file Both test1 and test2 are in one group.
 
Old 03-04-2005, 02:39 PM   #7
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
From the description of your problem it sounds like it is a simple oversight - you may have created a group that both user1 and user2 belong to, but chances are very good that their home directories are owned by user1 as a member of group 1, and user 2 as a member of group 2. On the machine I am on at work, I have 3 acounts in addition to root for the 3 people that use it from time to time. Each of those people has their username also as their groupname. For example, I am user jim of group jim, and my coworker sitting next to me and laughing as I try to type is user dan of group dan.

So to get the permissions set up as you wish, you may have to remove the group membership from both users, then add the same group membership to both, say group new, and be certain that the /home/userx directory is owned by userx of group new.

There is a nice gui tool to do that in you have X windows on your distro, or if you're running on CLI only, the chgrp/chown commands are all you need.

Peace,
JimBass
 
Old 03-06-2005, 07:46 AM   #8
pal
Member
 
Registered: Dec 2004
Location: india
Posts: 60

Original Poster
Rep: Reputation: 15
we got Confused sir
Please tell us in simple terms.
Like we had created two users test1 and test2 using useradd.Then we created a group new.Then
# gpasswd -M test1, test2 new
Then as root we issued the command
# chmod -R 770 /home/test1
Now if we login as test2 we should we able to see the files of test1.Are we right.But this is not happening.
 
Old 03-06-2005, 08:38 AM   #9
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
As root, please do:
Code:
ls -al /home
I think what you will see from that command will include something like this:
Code:
drwxrwx---  47 test1 test1 4096 Mar  6 08:16 test1
drwx------   2  root   root 16384 Jan 15 11:02 lost+found
drwxrwx---  10 test2 test2   4096 Mar  3 11:40 test2
If that is part of what you see from the "ls -al /home" command, then all you need to do is change the group ownership of /home/test1.

Code:
chgrp -R new /home/test1
That should allow user2 full access to the home directory of user1.

Peace,
JimBass
 
Old 03-07-2005, 02:41 AM   #10
pal
Member
 
Registered: Dec 2004
Location: india
Posts: 60

Original Poster
Rep: Reputation: 15
thanks sir you have told us so simply that we are able to do this . In one time only we understood the concepts of the command chgrp and chmod.
But sir after executing chgrp -R new /home/test1
suppose we are having files a ,b ,c under /home/test1 and its permissions are given as
chmod - R 750 /home/test1
means all the members of group new are able to access the /home/test1 and its files. and they are not having the write permission for the files a ,b ,c. which is what we wanted.But when we login as user test1 himself he is also not able to edit his own files as he should be, according to the permission given to user i.e. 7 as above.
-------------------------------------------------------
lastly we want to know about chown command
If a file file1 exists in /home/test1 then
If we give chown file 1 test2
Now if we login as test2 the file1 should be under /home/test2.But it is not there in the directory.
 
Old 03-07-2005, 09:30 AM   #11
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
I need more info to help you - please post the results of this command:
Code:
ls -al /home/test1
That way we can see the full ownership of the files, and find out where the problem is. It sounds like you don't have a clear idea about the chmod/chgrp/chown strings of commands. I would run
Code:
man chown
man chgrp
man chmod
That should clear up some of the problems you are having, but if you get stuck, list the results of what I've asked for, and we can sort out your issue.

In response to your second question, you are very wrong. Chown does just what it says, it CHanges the OWNer of the file. There is nothing about moving the file, it just has a new owner. If you want it in /home/test2, you need to either create a link to it or a copy of it, but it woun't just get up and move because you changed its properties.


Peace,
JimBass

Last edited by JimBass; 03-07-2005 at 09:33 AM.
 
Old 03-07-2005, 10:44 AM   #12
pal
Member
 
Registered: Dec 2004
Location: india
Posts: 60

Original Poster
Rep: Reputation: 15
Thank u very much sir We had solved all our problems withyour kind support.Now we understood the meaning of all the three commands

Thanks again sir.
 
Old 03-07-2005, 10:55 AM   #13
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
Right on! Glad you guys were able to figure things out on your own. Many times I've found that man (whatever) is the answer to my questions, if you read carefully and try things out..

Peace,
JimBass
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using chown, chgrp, chmod on a vfat partition? Rodolfo Medina Linux - General 7 08-17-2005 09:17 AM
chmod ,chown ,chgrp------------ pal Linux - Newbie 1 02-27-2005 03:49 PM
chown, chgrp Help Icarus1701 Linux - Newbie 1 10-25-2004 07:42 PM
Help: Directories magically chgrp and chown by themselves! Blazer79 Mandriva 2 09-07-2004 12:52 PM
problems with chown and chgrp apax Linux - Software 6 11-03-2003 04:44 PM


All times are GMT -5. The time now is 08:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration