Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

第 24 章 FAQ

目录

24.1. Linux用户使用FreeBSD,问FreeBSD ulimit怎么设置?
24.2. su: Sorry

24.1. Linux用户使用FreeBSD,问FreeBSD ulimit怎么设置?

首先说明FreeBSD默认Shell是csh没有ulimit命令,但C Shell有limit命令。如果你想使用ulimit命令可以安装Bourne shell,Bash,Zsh

limit,ulimit比较

[neo@freebsd:~] limit
cputime         unlimited
filesize        unlimited
datasize        32768MB
stacksize       512MB
coredumpsize    unlimited
memoryuse       unlimited
memorylocked    unlimited
maxproc         5547
descriptors     65536
sockbufsize     unlimited
vmemorysize     unlimited
NPTS            unlimited
SWAP            unlimited

[neo@freebsd:~] env | grep SHELL
SHELL=/usr/local/bin/zsh

[neo@freebsd:~] ulimit -a
-t: cpu time (seconds)         unlimited
-f: file size (blocks)         unlimited
-d: data seg size (kbytes)     33554432
-s: stack size (kbytes)        524288
-c: core file size (blocks)    unlimited
-m: resident set size (kbytes) unlimited
-l: locked-in-memory size (kb) unlimited
-u: processes                  5547
-n: file descriptors           65536
-N  9: socket buffer size (kb) unlimited
-v: virtual memory size (kb)   unlimited
-N 11:                         unlimited
-N 12:                         unlimited

在Freebsd上,你能使用sysctl命令:

		

以 nofile - max number of open files 为例,limit、ulimit、sysctl实现同样的功能。

csh% limit descriptors unlimited
或者
csh% limit descriptors 4096

sh$ ulimit -n unlimited
或者
sh$ ulimit -n 4096

sysctl kern.maxfiles=65536
sysctl kern.maxfilesperproc=65536
		

写入配置文件 sysctl.conf

[neo@freebsd:~] cat /etc/sysctl.conf
# $FreeBSD: src/etc/sysctl.conf,v 1.8.34.1.4.1 2010/06/14 02:09:06 kensmith Exp $
#
#  This file is read when going to multi-user and its contents piped thru
#  ``sysctl'' to adjust kernel values.  ``man 5 sysctl.conf'' for details.
#

# Uncomment this to prevent users from seeing information about processes that
# are being run under another UID.
#security.bsd.see_other_uids=0

#vm.pmap.shpgperproc: 2000
#vm.pmap.pv_entry_max: 13338058
kern.ipc.shm_use_phys=1
kern.maxfiles=65536
kern.maxfilesperproc=65536
kern.ipc.somaxconn=2048

[neo@freebsd:~] /etc/rc.d/sysctl reload

[neo@freebsd:~] sysctl -a | grep maxfiles
kern.maxfiles: 65536
kern.maxfilesperproc: 65536