Managing Disk Usage by Users

When more drastic action is required, UNIX flavors usually offer utilities to remove users from the system, similar to the ones employed to add users to the system; some flavors even provide built−in commands for this purpose. Unfortunately, the automatic removal of a users files from the system could be risky, so there is always a lot to be done by hand. When removing a user from the system, a number of issues should be considered: Removing the users mail files • Removing the user from the mail aliases the file usrlibaliases, or redefining the alias to send mail to someone else • Removing pending print requests • Performing any other site−specific termination activities that may be appropriate • Users frequently interact with UNIX systems, but there are other ways a users requests and jobs could be submitted. Time−related UNIX utilities provide this function: cron Enables the submission of a users jobs for periodic execution at Enables the submission of a users jobs for execution at specific usually off−peak times batch Enables the submission of a users jobs for execution at off−peak times, when the system is less busy Removing a user account also includes making sure the user has not left any pending cron, at, or batch jobs in the system.

7.3 Disk Quotas

Disk space shortages are a very common problem on all systems. Often some users use the available disk space in an inappropriate way, storing and keeping everything on the system. In a multi−user environment such behavior is intolerable. The UNIX disk quota facility allows an administrator to limit the amount of filesystem storage that a user may consume. If quotas are enabled, the OS will maintain separate quotas for each users disk space and the total number of files the user owns on a filesystem. Originally a BSD facility, the disk quota is common today in all UNIX flavors. There are two distinct types of quotas: a hard limit and a soft limit. A user is never allowed to exceed the hard limit; the user will receive a message that the quota has been exceeded, and any more data storage will be refused. The soft limit may be exceeded only temporarily, for a limited period of time; in such cases a user will receive a warning message, but the OS grants additional storage if requested. The warning will be repeated as long as the user does not reduce the disk usage, or the limited warning period expires. If either happens, at this point the OS will react as it would in the case of a hard−limit violation.

7.3.1 Managing Disk Usage by Users

The system administrator must decide which filesystems need quotas a disk quota is implemented on the filesystem level; usually, candidates are filesystems where users reside home, users, 181 cd fs−top−dir fs−top−dir corresponds to the to the top−most directory of the selected filesystem, i.e., the filesystem mount−point touch quotas create an empty file quotas a mandatory filename chmod 600 quotas make it read−write−only for the superuser At this point, the general issues concerning disk quota are resolved; now, it is time to set the users quota limits. This must be done individually for each user, and the limits may be determined arbitrarily among the different users. The edquota command is available to establish filesystem quotas this is the only program available to edit quotas, and it invokes the standard editor — vi by default. The command can be used for a single user, or simultaneously for more users: edquota usernames The edquota command will create the hard and soft limits for the specified user and the corresponding filesystem. Each user is specified by one line of the form: fs fsname blocks soft=10000, hard=12000 inodes soft=0, hard=0 The disk space determined by blocks and the maximum number of users files determined by inodes can be limited; a 0 value indicates no limits. The edquota command has several options: −t Edit the time limits for filesystems time limits are set on filesystems, not users; the default value is usually seven days −p To copy quota settings between users, for example: edquota −p username1 username2 username3 etc. • means copy quota settings from the user username1 to other users: username2, username3, etc. After all quota limits are defined, the quotaon command must be used to enable the disk quota facility some systems enable quota checking automatically with filesystem mounting. Alternatively, the quotaoff command is used to disable quota checking. The quotacheck command is available to check the consistency of the file quotas for the specified filesystem with the current actual disk usage. Finally, the repquota command is available to report the current quotas for the specified filesystem. An example follows: repquota −av devdskc201d6s0 : Block limits File limits User used soft hard timeleft used soft hard timeleft bjl −− 140 10000 12000 73 0 0 vasili −− 121 10000 12000 63 0 0 ggu −− 1025 10000 12000 140 0 0 182 aizin −− 69 10000 12000 12 0 0 This report refers to the brand new HP−UX workstation, which had only a few active users at that time.

7.4 Accounting