Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 2nd, 2008, 12:23 AM
Subsciber123's Avatar
Member
 
Join Date: Nov 2006
Location: Eastern Time Zone
Posts: 83
Default User quotas

Is it possible to create a user quota on Ubuntu 8.04 for the number of processes that can be running concurrently per user?

This could be useful for preventing fork bombs, among other things.

Even better would be to be able to control how many descendants a particular program can have, though that might be too much to ask for.
Reply
  #2  
Old October 2nd, 2008, 08:01 AM
sashi's Avatar
Expert
 
Join Date: Jun 2006
Location: Seremban, Malaysia
Age: 32
Posts: 1,617
Default

Hi Subscriber,

On large systems with many users, you need to control the amount of disk space a user has access to. Disk quotas are designed specifically for this purpose. Quotas, managed per each partition, can be set for both individual users as well as groups; quotas for the group need not be as large as the aggregate quotas for the individuals in the groups.
When files are created, both a user and a group own them; ownership of the files is always part of the metadata about the files. This makes quotas based on both users and groups easy to manage.

To manage disk quotas, you must have the quota and quotatool packages installed on your system. Quota management with Ubuntu is not enabled by default and has traditionally been enabled and configured manually by system administrators. Sysadmins use the family of quota commands, such as quotacheck to initialize the quota database files, edquota to set and edit user quotas, setquota to configure disk quotas, and quotaon or quotaoff to control the service. (Other utilities include warnquota for automatically sending mail to users over their disk space usage limit.)


Implementing Quotas
To reiterate, quotas might not be enabled by default, even if the quota software package is installed on your system. When quotas are installed and enabled, you can see which partitions have either user quotas, group quotas, or both by looking at the fourth field in the /etc/fstab file. For example, one line in /etc/fstab shows that quotas are enabled for the /home partition:

Expand|Select|Wrap|Line Numbers
  1. /dev/hda5 /home ext3 defaults,usrquota,grpquota 1 1
The root of the partition with quotas enabled will have the files quota.user or quota.group in them (or both files, if both types of quotas are enabled), and the files will contain the actual quotas. The permissions of these files should be 600 so that users cannot read or write to them. (Otherwise, users would change them to allow ample space for their music files and Internet art collections.) To initialize disk quotas, the partitions must be remounted. This is easily accomplished with the following:

Expand|Select|Wrap|Line Numbers
  1. $ sudo mount -o ro,remount partition_to_be_remounted mount_point
The underlying console tools (complete with man pages) are

# quotaon, quotaoff—Toggles quotas on a partition.

# repquota—A summary status report on users and groups.

# quotacheck—Updates the status of quotas (compares new and old tables of disk usage); it is run after fsck.

# edquota—A basic quota management command.


Manually Configuring Quotas
Manual configuration of quotas involves changing entries in your system’s file system table, /etc/fstab, to add the usrquota mount option to the desired portion of your file system. As an example in a simple file system, quota management can be enabled like this:

Expand|Select|Wrap|Line Numbers
  1. LABEL=/ / ext3 defaults,usrquota 1 1
Group-level quotas can also be enabled by using the grpquota option. As the root operator, you must then create a file (using our example of creating user quotas) named quota.user in the designated portion of the file system, like so:

Expand|Select|Wrap|Line Numbers
  1. $ sudo touch /quota.user
You should then turn on the use of quotas using the quotaon command:

Expand|Select|Wrap|Line Numbers
  1. $ sudo quotaon -av
You can then edit user quotas with the edquota command to set hard and soft limits on file system use. The default system editor (vi unless you change your EDITOR environment variable) will be launched when editing a user’s quota. Any user can find out what their quotas are with

Expand|Select|Wrap|Line Numbers
  1. $ quota -v
Reply
  #3  
Old October 3rd, 2008, 06:42 PM
Subsciber123's Avatar
Member
 
Join Date: Nov 2006
Location: Eastern Time Zone
Posts: 83
Default

Very informative, but not exactly what I was looking for. I was looking for a way to set a maximum number of programs that can run per user, with the kernal returning errors if more programs try to run as a specific user.
Reply
  #4  
Old October 5th, 2008, 04:14 PM
arne's Avatar
Expert
 
Join Date: Oct 2006
Posts: 307
Default

pam comes with '/etc/security/limits.conf'. This file offers a number of resources to be limited, amongst others the number of processes (also per user).

HTH,
Arne
Reply
  #5  
Old October 7th, 2008, 02:14 AM
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Age: 21
Posts: 2,003
Default

Quote:
Originally Posted by sashi
Hi Subscriber,

On large systems with many users,...
Wow sashi, that's what I call an informative answer. Would you like to put an article together from that reply? Our Linux Article section could sure do with stuff like this!

Greetings,
Nepomuk
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles