Chmod ,chown ,chgrp commands not working proper----------------
Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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.
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
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.
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
#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.
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.
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.
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.
I need more info to help you - please post the results of this command:
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
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.