zoukankan      html  css  js  c++  java
  • 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之后
  • 相关阅读:
    《趣谈网络协议》(刘超老师)读后笔记记录 001
    jenkins安装配置
    Linux 磁盘分区,挂载以及格式化
    Linux三剑客之awk
    Linux三剑客之sed
    Linux-三剑客之grep
    date那些事儿
    zookeeper集群的搭建以及命令详解
    Java多线程
    mybatis获取自增主键
  • 原文地址:https://www.cnblogs.com/qiumingcheng/p/11668423.html
Copyright © 2011-2022 走看看