0

There is something not clear on relationship between file properties and user and group.

root@debian:/home/debian# ls  -l  /home/linuxsir
total 4
-rw-r--r-- 1 linuxsir root 1549 Feb 23 19:16 test.txt

I draw a conclusion that the directory /home/linuxisir contain one file named test.txt, linuxsir is its owner ,and linuxsir belong to the root group.

root@debian:/home/debian# cat /etc/group
root:x:0:
linuxsir:x:1004:
postgres:x:120:
my_test_group1:x:1005:linuxsir,linuxsir2

From cat /etc/group , linuxsir do not belong to group root?
How to think of this matter properly?

1

First of all, cat /etc/group only shows the groups created in the system. If you want to know which groups linuxsir belongs to, you need to use this command groups linuxsir.

The result of ls -lsays:

-rw-r--r-- 1 linuxsir root 1549 Feb 23 19:16 test.txt

It means:

  • user linuxsir is owner and can read and write on test.txt
  • group root can only read
  • Anyone else can only read

It doesn't say that group rootis owner of the file, it is only saying which permissions group roothas over the file.

By default, the owner of a file is the user who created it and the group assigned to a file is the primary group of the user. However, you can change the group of a file using chgrp.

| improve this answer | |
  • In my situation, groups linuxsir linuxsir : linuxsir my_test_group1 – it_is_a_literature Feb 27 '15 at 11:54
  • The User linuxsir only belongs to the groups linuxsir and my_test_group1. He isn't on the group root. – jcbermu Feb 27 '15 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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