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