User Limits Made Easy
September 20, 2011
One of the tools admins have at their disposal on Linux to set hard and soft limits for users is the
When setting up or managing multi-user systems, you might want to set some resource constraints for users on the system. Using the
What you want to do is start by enabling the
That's placed in the file
After that, you need to specify the users and the limits you want to use. For that, at least on Debian-type systems, you'll want to edit
Again, here's an example taken from the Debian sample configuration:
The first field specifies the user or users affected. The
But you can also use limits.conf to nail down the limits for accounts like
The next field specifies whether a limit is hard or soft. Be careful with hard limits. You might want to start with a soft limit before moving to a hard limit just to ensure you won't, say, bring a system to a halt because a process can't spawn any more children. Note that you don't have to specify hard or soft, some limits can be left with
Next, you've got the item that's being limited. See the
Finally, the last field is the value for the limit. Use whatever values make sense here. For example, limiting users to four logins simultaneously.
A tip of the hat to Nikesh Jauhari for inspiring this week's column. It's been a while since I looked at this feature. If you're administering a Linux box, this is an easy way to nail down resources on your system without much added work.
Joe 'Zonker' Brockmeier is a freelance writer and editor with more than 10 years covering IT. Formerly the openSUSE Community Manager for Novell, Brockmeier has written for Linux Magazine, Sys Admin, Linux Pro Magazine, IBM developerWorks, Linux.com, CIO.com, Linux Weekly News, ZDNet, and many other publications. You can reach Zonker at email@example.com and follow him on Twitter.