sudo + ulimit not working ? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

sudo + ulimit not working ?

Shell Programming and Scripting


Tags
sudo, ulimit

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-07-2010
cyler cyler is offline
Registered User
 
Join Date: Jan 2010
Last Activity: 11 June 2010, 6:14 AM EDT
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
sudo + ulimit not working ?

When I use sudo with ulimit there is an error but if I use ulimit without sudo there is no error.

In bash:


Code:
user1@debian:~$ sudo -u user2 -H ulimit -S -c unlimited
sudo: ulimit: command not found
user1@debian:~$


user1@debian:/home/user1$ ulimit -S -c unlimited
user1@debian:/home/user1$


user2@debian:/home/user2$ ulimit -S -c unlimited
user2@debian:/home/user2$


The entire content of /etc/security/limits.conf is commented.


Content of /etc/sudoers :

Code:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset,timestamp_timeout=0

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL
user1 debian=(user2) NOPASSWD: ALL

# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL


Last edited by pludi; 06-07-2010 at 07:00 AM.. Reason: code tags, please...
Sponsored Links
    #2  
Old 06-07-2010
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 25 July 2014, 9:59 AM EDT
Location: St. Gallen, Switzerland
Posts: 6,215
Thanks: 120
Thanked 450 Times in 410 Posts
How shall sudo know when your command starts?
-c accepts commands, put them into double quotes.
Try:

Code:
sudo -u user2 -H -c "ulimit -S -c unlimited"

Sponsored Links
    #3  
Old 06-07-2010
cyler cyler is offline
Registered User
 
Join Date: Jan 2010
Last Activity: 11 June 2010, 6:14 AM EDT
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
-c will not work. I have an old sudo version ?


Code:
user1@debian:~$ sudo -u user2 -H -c "ulimit -S -c unlimited"
sudo: illegal option `-c'
usage: sudo -h | -K | -k | -L | -l | -V | -v
usage: sudo [-bEHPS] [-p prompt] [-u username|#uid] [VAR=value]
            {-i | -s | <command>}
usage: sudo -e [-S] [-p prompt] [-u username|#uid] file ...
user1@debian:~$

This does not produce any errors...

Code:
user1@debian:~$ sudo -u user2 -H bash -c "ulimit -S -c unlimited"
user1@debian:~$

    #4  
Old 06-07-2010
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 25 July 2014, 9:59 AM EDT
Location: St. Gallen, Switzerland
Posts: 6,215
Thanks: 120
Thanked 450 Times in 410 Posts
Sorry, forget what I wrote, I was mixing up sudo with su - I come back when I have checked it out

---------- Post updated at 04:10 PM ---------- Previous update was at 03:46 PM ----------

ulimit is a shell builtin on some OSes and in that case - you can't use shell builtins via sudo as far as I know.
If it is an option for you, you might want to change your limits permanent for some user via editing /etc/security/limits.conf or whatever file it is on your OS. Don't forget to relog to make changes for that user/shell active.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Unable to use the Sudo command. "0509-130 Symbol resolution failed for sudo because:" Chloe123 UNIX for Dummies Questions & Answers 1 12-21-2009 04:09 PM
sudo apt-get install build-essential not working sparkle UNIX for Dummies Questions & Answers 4 04-12-2009 05:28 PM
sudo command is not working inside a script when placed in cron usha rao Shell Programming and Scripting 5 02-12-2009 11:02 AM
Sudo command not working with cron job. WhotheWhat Shell Programming and Scripting 6 12-18-2008 03:10 PM
sudo chmod not working Movomito UNIX for Advanced & Expert Users 1 06-05-2008 02:41 AM



All times are GMT -4. The time now is 07:10 AM.