granting permission to read or write a file, to view a directory or to execute a program to only those users allowed to do so; for instance, access to a payroll database is restricted by only allowing users in the Payroll Department to access the database files, and the ability to ping on the network is controlled by allowing only Networking Department personnel to execute the ping program
a policy is established for each action, defining who can perform it; ie., it should not be possible via telnet to login as root (since telnet does not know how to encrypt passwords)
useradd john ; passwd john
groupadd networking
usermod -G networking,users john
Note that at this point, the stage has been set, but no enforcement will take place because no permissions have been specified.
chgrp networking /bin/ping
chmod 4550 /bin/ping
The implementation and maintenance of a user and group structure is a design problem whose scope can only be appreciated by someone who has inherited a server which has a tangled mess of users and groups and does not adequately control security of system resources. It cannot be stressed strongly enough that the design of a useful and flexible group structure requires careful forethought and more than a little luck, and when ad hoc changes are made for the sake of convenience, security will be compromised quickly and effectively. Most systems administrators will keep all of the commands needed to set up their user and group structure in one or more scripts, to facilitate rebuilding the server, and to make it easier to keep track of what is already in place when making changes.
| u g t | r w x | r w x | r w x |
|---|---|---|---|
| setuid setgid text | owner | group | anyone else |
| read write execute | read write execute | read write execute |
The octal permission is a four "octit" (base 8 digit) number; missing high order numbers are assumed to be zero (as in base 10). Hence a 750 would really mean 0750; written in binary, 750 is
| u g t | r w x | r w x | r w x |
|---|---|---|---|
| 0 0 0 | 1 1 1 | 1 0 1 | 0 0 0 |
and so we see that the owner (which is root) can read, write to and execute the file, the group members can read and execute the file, and anyone else can do nothing with the file.
The first octit should be used sparingly, as it can open potentially enormous security holes. If the setuid bit is set, the program process runs as if the owner started it; in this case, ping would run as root. If the setgid bit is set, the program process runs as if a group member started it; in this case, ping would run as a member of networking (which is no big deal; setgid is only useful if anyone can execute the program). If the text bit is set, the text of the file is kept in the swap partition (emacs uses this to speed up program startup for multiple copies of the editor). The setuid bit is necessary in some cases; in fact, ping must be setuid so that an ordinary user can access the protocol stack. To find files which are setuid, use "find / -perm -4000 -ls".
The permissions which are set when ping is installed are 4555. After the changes in the above example, an "ls -l" on ping produces the following output:
This means that ping is owned by root, belongs to the networking group, can by read, written to and executed by root, can be read and executed by anyone in the networking group, cannot be read or written to or executed by anyone else, and runs as root when someone from the networking group executes it.-r-sr-x--- 1 root networki 23436 Aug 27 12:10 /bin/ping
The only time that it makes sense to use the symbolic permissions is if you need to add or remove a permission on multiple files, not all of which have the same permissions. For instance, if you needed to add write permission for the file's owner to all of the files in a directory, some of which were executable and some of which were not, the command "chmod u+w *" is very useful. You must be very careful, however, since it is easy to mistakenly use "o" for owner instead of "u" for user, and "o" does NOT mean owner, it means all of the other users who are not the owner or in the file group!
This can be accomplished by setting umask to 077 in /etc/profile.d/umask.sh (it is currently set to 022, which means that no one but the owner may write to a file). umask is an internal bash command which affects all files created by the shell or any of its children. The effect is to AND the mode specified at file creation with NOT the umask value; the resulting value is stored in the file inode. So umask specifies which bits MUST be zero in the permissions.
Note that the profile scripts are run only for a login shell (the one started by login). Therefore, changes made to any of them will only affect subsequent logins. Specifically, the changes will not affect current or new xterm shells unless you first logout.
Be aware that when you use "useradd -m", the permissions on the new directory are 755. When all users are a member of the same initial group (and umask is set to 077), you will probably want to chmod 700 the new home directory.
Accounting allows the system administrator to keep track of how much each user is using various system resources, such as cpu time, memory and i/o. It can also keep track of which programs are used by each user, and resource usage by program. While in the past this information was typically used to charge users for computer resources, its primary use now is to allow the administrator to track usage (and misusage) of the system.
The system also allows the administrator to set and enforce maximums for disk space utilization by filesystem and user, via quota control.
©2005, Kenneth R. Koehler. All Rights Reserved. This document may be freely reproduced provided that this copyright notice is included.
Please send comments or suggestions to the author.