|
http://oldfield.wattle.id.au/luv/permissions.html Back to LUV presentations Introduction to Unix file permissionsTalk presented by Kim Oldfield to the Linux Users of Victoria Inc. on Tuesday, December 2, 2003. Basic attributes of a file
Users
To find out your
current username and uid, primary group an gid, and
additional groups you are a member of run bash> id uid=1006(kim) gid=1006(kim) groups=1006(kim),4(adm),29(audio)
Groups
Adding users or groupsAll of these commands
require that you are root. To become root from an
ordinary user run
Changes to group membership take place the next time you login. Permission bits - an examplebash> ls -l /etc/shadow -rw-r----- 1 root shadow 680 Nov 2 18:49 shadow Each of these characters correspond to type, and permissions for the user, group, and others. The first '-' indicates that this is a regular file. 'rw-' indicates that the owner of the file (root), is able to read an write to the file. The '-' indicates that root is not allowed to run the file. 'r--' indicates that anyone who is a member of the group 'shadow' is able to read to the file. '---' indicates that anyone who is not root and not a member of the group 'shadow' (ie 'others') are not able to read or write to the file. Permissions
T is one of:
Character and block devices are usually in /dev The permissions on a symbolic link are always lrwxrwxrwx. This means that anyone can see where the links points. Who can read, write, or execute the file (or directory or device) the link points to is determined by the permissions on that file, not the link. Each of the permission triplets, UUU, GGG, and OOO, can consist of:
Octal numerical representationAdd up the values for the rights required.
For example: converting
rwxr-x--- to octal: Octal values can be
given to Set uid and set gid on filesWhen run Unix executables can use the effective rights of a different user or group. This is shown by having an 's' rather than 'x'. For example: bash> ls -l /bin/su
-rw
When Any program which is suid or sgid must be written very carefully to make sure that it can not be abused by malicious users to do things they shouldn't.
Set uid and set gid on directoriesSet gid on a directory means that all new files and directories created in that directory will have the same group as that directory. When set gid is not set on a directory then the group used for new files and directories is the default group for that user. Does anyone know what suid on a directory does? The sticky bit - /tmp directoryNormally (without 't') any user who has write permission to a directory can delete any files in the directory regardless of who owns it, even if they can't read or write to the file. With 't' set, only the owner of a file can delete it. This is used on /tmp bash> ls -ld /tmp
drwxrwxrw
umask - default permissionsThe logical not of your
A typical umask is 002, not(002) = 775 (in octal). 775 corresponds to rwxrwxr-x, or the owner and group can read, write, and execute, while others can only read or execute, but not run. Where the file isn't executable rw-rw-r-- will be used. Most Linux distributions will configure a group for every user, eg my username is kim, and there is also a group kim, of which I am the only member. The default mask is 0002 so by default all files I create are group writable, but this isn't a problem as I'm the only person in the group. If you have a group of
people (eg staff) who you would like to be able to
write to a directory tree then change the base directory group to
staff, and
More informationFor more information about any of the commands or files mentioned earlier see the appropriate man page. Note that most commands are in section 1 of the manual, while section 5 details file formats.
This presentation is available from http://oldfield.wattle.id.au/luv/permissions.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
