LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 10-30-2012, 01:36 PM   #1
basil_brush
LQ Newbie
 
Registered: Oct 2012
Posts: 25

Rep: Reputation: Disabled
Limiting a user to an amount of procs.


I know of /etc/limits ...is that the place to put a limit of a users processors/programs, is limited to. And if so, what is rough average for browsing, playing tunes, basically a general desktop.
 
Old 10-30-2012, 02:05 PM   #2
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.0
Posts: 2,242

Rep: Reputation: 614Reputation: 614Reputation: 614Reputation: 614Reputation: 614Reputation: 614
I created a /etc/profile.d/ulimit.sh file containing the following:
Code:
#!/bin/sh

ulimit -u 300
If you have a real multiuser setup and allow users to choose their own shells you should also create the equivalent ulimit.csh file with the appropriate c-shell command instead (I believe c shells use limit instead of ulimit...`limit maxproc 300` might work but I have no experience with those shells). I use a lightweight window manager and I haven't encountered problems with 300 processes per user, but you may with the heavier stuff (though I occasionally run KDE without problems as well).
Code:
$ ps ux | wc -l
under a heavy session would give you a starting point as to how many processes is reasonable. I could probably get away with 100 but 300 is enough to provide adequate freedom while limiting the impact of fork bombs so I'm content.
 
1 members found this post helpful.
Old 10-31-2012, 03:51 AM   #3
basil_brush
LQ Newbie
 
Registered: Oct 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled
Thanks for the reply T3slider, would you also consider limiting root?

Last edited by basil_brush; 10-31-2012 at 03:57 AM.
 
Old 10-31-2012, 11:48 AM   #4
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.0
Posts: 2,242

Rep: Reputation: 614Reputation: 614Reputation: 614Reputation: 614Reputation: 614Reputation: 614
I believe that will limit root already since it does not discriminate based on uid, but root will always have the ability to increase the max processes if needed by running ulimit in the shell (regular users cannot increase the limit above the hard limit). I guess the following would work to restrict it to regular users:
Code:
#!/bin/sh

if ! [ $UID -eq 0 ]; then
    ulimit -u 300
fi
Of course, then a fork bomb running as root would bring the system to its knees...but any fork bomb could just adjust the max processes runnable by root before executing so it's irrelevant.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ext2 Volume Manager limiting amount of data transfer aba99 General 4 08-24-2010 06:32 AM
Limiting the amount of bandwidth Apache Uses wenberg Linux - Software 0 02-07-2005 11:39 AM
PHP: limiting amount of text printed jme Programming 1 11-13-2004 08:13 AM
Java JTextArea - limiting amount of characters entered Andy@DP Programming 3 03-10-2004 01:16 AM
Limiting the total amount of memory usage by apache. SplashHost.com Linux - General 8 08-30-2002 09:56 AM


All times are GMT -5. The time now is 01:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration