• sudo: ulimit: command not found


    在这看到的:http://stackoverflow.com/questions/17483723/command-not-found-when-using-sudo-ulimit

    修改系统文件打开数,具体修改方法就不写了,但是在普通用户使用sudo执行的时候报错:

    130> sudo ulimit
    sudo: ulimit: command not found
    
    本来以为ulimit没在path变量中,用绝对路径就行了:
    1> which ulimit
    /usr/bin/which: no ulimit in (/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin)
    
    查了下原因ulimit不是一个单独的程序。sudo会去找二进制文件运行。由于找不到ulimit的二进制可执行文件,故报错。 类似的命令还有:cd
    
    可以这样设置:
    sudo sh -c "ulimit -n 65535 && exec su $LOGNAME"
    
    该命令创建一个新的shell,然后设置ulimit,同时将用户切换至当前用户,当命令退出时,不会是以root权限退出。
    
    英语解释:
    ulimit is a shell builtin like cd, not a separate program. sudo looks for a binary to run, but there is no ulimit binary, which is why you get the error message. You need to run it in a shell.
    However, while you do need to be root to raise the limit to 65535, you probably don’t want to run your program as root. So after you raise the limit you should switch back to the current user.
    To do this, run:
    sudo sh -c "ulimit -n 65535 && exec su $LOGNAME"
    and you will get a new shell, without root privileges, but with the raised limit. The exec causes the new shell to replace the process with sudo privileges, so after you exit that shell, you won’t accidentally end up as root again.
    
    
    
    你将得到一个新的shell,没有root权限,但是提高了限制。 exec使新shell以sudo权限替换进程,所以在你退出shell之后
  • 相关阅读:
    Groovy Closure & Action
    Groovy A simple DSL based on groovy
    Groovy 一些小细节
    Android 那些年踩过的坑
    Android Startup
    Android 开发最佳实践
    Android 开发经验-容易忽略的问题
    Android 开发经验-Fragment相关
    AQTime + Delphi
    关于ANSI,unicode与utf-8的区别
  • 原文地址:https://www.cnblogs.com/qiumingcheng/p/11668423.html
Copyright © 2020-2023  润新知