The ones beginning with a "d" are directories. When a file or directory is first created it takes as its group the current group of your shell. This is the default group for all login shells, but you can start another shell with any group using the command 'newgrp project'. If you are going to create files for a secondary group then it easier to create all these files from a shell started with the newgrp command.
If you want to change the group associated with a file or directory which already exists use the command 'chgrp project filename'. You must be the owner of the file, and you must be a member of the new group in order to make the change. In many cases the group ownership does not matter, but if you want to share a file with a group, then it is important that you get the ownership correct. Otherwise you may be inviting all users to put their large files in your directory. Just setting up a file to be owned by a group does not give your group any access to the file.
Granting and limiting access is done by setting appropriate permission bits. You can see the permission bits as a set of 10 letters or dashes in the long listing of a file or directory using the 'ls -dl' command.
The -dl option on the ls command will list the information for the directory or file in long format. Without the "d" all the files in the directory would be listed instead of just the directory you asked for. For example to get a long listing for a directory with the name test. The first string of characters are the mode, the next is a link count see 'info ls' for details , the third field is the owner and the fourth field is the group which owns the file. Begins with a "d", which indicates this is a directory.
The owner, cmmiller, has permission bits rwx which is full access. Any other user in group csstaff has permission bits r-x which is browsing access can read and search without permission to add, rename or delete files in the directory.
Every other user, that is not cmmiller and not in group csstaff has permission bits which is no access. The user with login name cmmiller is the owner of the file. The owner will have permission modes according the the first three codes after the "d".
The owner always can change permission modes with the chmod command. The directory is said to be owned by this group. Any user in group csstaff, except cmmiller, will have permissions granted according to the middle three codes in the permission modes. Once you check to make sure a directory and all its files and sub-directories are owned by the correct group you can set the permission modes for everything with the one command.
The chmod command can also be used to allow members of a group to put files in a directory. The owner of the directory can open a directory for shared writing with the command:.
The "s" is the group set-ID setting, which means all new files in this group will be owned by the user putting them there, but the group ownership will be set to match the group of the directory rather than the current group of the owner.
This is the recommended way to keep group ownerships correct. This means only the owner of a file or the owner of the directory can delete or rename a file. This is recommended if several users will be putting files in the same directory. Whereas the chmod command determines the type of access that group members may have to a file or directory, the chgrp command determines which group may access that file or directory. One of the most common mistakes in sharing files on a UNIX system is to forget to set file permissions or to set them incorrectly.
If permissions are not set correctly, then a user will see the following message or a similar one when they try to access your directory or files:. Another common problem is to set file permissions for existing files, but to neglect to set permissions for newly created files. By default, others cannot access your files. You must give explicit permissions to each file when it is created.
Skip to main content. Unix Group Membership Users are organized into groups, where every user is in at least one group, and may be in other groups. Group ownership of Files and Directories Every file and directory has a username and a groupname associated with it.
Group permissions of Files and Directories Just setting up a file to be owned by a group does not give your group any access to the file. The count is usually one if you are listing a file.
You are automatically assigned to a primary group when your userid is created. This primary group is the group assigned to any login shell. It is also called your default group. This will be your current group at your next login. That may be the only group to which you belong.
Use the id to see your current group which is part of your identification. When you login, you are automatically given your primary group as your current group. However, it doesn't matter if group 14 is his or her current primary group. The groups command lists the groups that a user belongs to.
A user can have only one primary group at a time. However, a user can temporarily change the user's primary group, with the newgrp command, to any other group in which the user is a member. When adding a user account, you must assign a primary group for a user or accept the default group, staff group The primary group should already exist.
If the primary group does not exist, specify the group by a GID number. User names are not added to primary groups. If user names were added to primary groups, the list might become too long. Before you can assign users to a new secondary group, you must create the group and assign it a GID number. Groups can be local to a system or managed through a name service.
These services enable you to centrally manage group memberships. The two types of groups that a user can belong to are as follows: Primary group — Specifies a group that the operating system assigns to files that are created by the user.
0コメント