sudo: ulimit: command not found

本文解释了为何直接使用sudo运行ulimit会遇到错误,并提供了解决方案。ulimit为shell内置命令而非独立程序,因此不能通过sudo直接执行。文章指导如何通过sudo在一个新的shell环境中提升文件描述符限制,同时保持普通用户的权限。

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.

sudo 查看ulimit报错:
google 百度,翻译都太拗口,简洁的说:

ulimit是一个shell内置的命令 像cd ,不是一个独立的进程,sudo以二进制方式运行,但是没有ulimit的二进制方式,所以你运行错误。 应该在一个shell中运行。

本文转自    憬薇   51CTO博客,原文链接:http://blog.51cto.com/welcomeweb/2044982


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值