Skip to content
shellmap

ulimitSet per-process resource limits in bash, zsh, fish, PowerShell, and cmd across all 5 shells

Equivalents in every shell

Bashunix
ulimit -n 8192

bash builtin. `-n` open files, `-u` user processes, `-s` stack KB, `-v` virtual memory KB, `-c` core dump KB, `-l` locked memory KB, `-m` resident memory KB (rarely enforced), `-t` CPU seconds. Without value, reads current. `-S` soft (default), `-H` hard (user-lowerable, root-raisable). `-a` summary of all. Effect is per-process and inherited by children.

Zshunix
ulimit -n 8192

zsh builtin — same flags as bash, plus zsh-specific `-T` (max number of threads, Linux only). zsh also exposes `limit` (csh-style alternative) with named arguments: `limit descriptors 8192`. Same effect; pick one. `limit -h` shows hard limits.

Fishunix
ulimit -n 8192

fish builtin (since fish 2.0). Same flags as bash; `ulimit -a` for summary. Fish lacks the csh-style `limit` command. Per-call overrides for children: `env -i ulimit -n 4096; ./child.sh` (the env-i forces a clean env that inherits the lower limit).

PowerShellwindows
(Get-Process -Id $PID).MaxWorkingSet = 1GB

pwsh has no shell-level `ulimit` builtin — Windows resource limits are per-process and live in the Job Object API. `(Get-Process -Id $PID).MaxWorkingSet` adjusts working-set quota. For open-file limits, Windows has no equivalent of `ulimit -n` (handle limits are per-process and tunable via `SetHandleInformation` or by registry — see `HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems\Windows`). On pwsh-Linux, you can shell out to `ulimit` via `bash -c "ulimit -n 8192; pwsh -File ./X.ps1"`.

cmd.exewindows
rem No native equivalent

cmd has no `ulimit` builtin and no shell-side equivalent. Windows resource limits are imposed via Job Objects, GPOs (`User Configuration > Administrative Templates > System > Process Quota`), or registry. For per-script soft limits, shell out: `powershell -Command "Set-PSResourceLimit ..."` (community module; no built-in cmdlet ships).

Worked examples

Raise the open-file limit before launching a high-FD server (databases, proxies)

Bash
ulimit -n 65536 && ./my-server
Fish
ulimit -n 65536; ./my-server

Show all current limits (soft) for the current shell

Bash
ulimit -a
Fish
ulimit -a
PowerShell
Get-Process -Id $PID | Format-List MaxWorkingSet, MinWorkingSet, WorkingSet64

Permanently raise open-file limits for a user (Linux — survives reboot)

Bash
sudo tee /etc/security/limits.d/my-app.conf <<EOF
my-app    soft    nofile    65536
my-app    hard    nofile    65536
EOF

Gotchas

  • `ulimit -n VALUE` only changes the CURRENT shell's limit. Child processes inherit, but anything you launch from a DIFFERENT shell (cron, systemd unit, supervisor) does not get this value. For systemd services, set `LimitNOFILE=65536` in the unit file. For login shells, edit `/etc/security/limits.conf` (PAM-enforced at login).
  • Soft (`-S`) limits can be raised back up to the hard (`-H`) limit by any user. Hard limits can only be RAISED by root and can be LOWERED by anyone. Once you lower the hard limit (`ulimit -Hn 4096`), you can't raise it back in that shell session — start a new login session. This is a common footgun in init scripts.
  • macOS has additional system-wide limits that override per-process ulimits — `launchctl limit maxfiles` is the macOS equivalent, and it caps what `ulimit -n` can request. Setting `ulimit -n 1000000` on macOS silently caps to `launchctl limit maxfiles` (default 524288 on macOS 14+).
  • pwsh on Windows has NO equivalent of Linux's `ulimit -n` — Windows handle limits are per-process at ~16M handles and not user-tunable from the shell. If you need handle accounting on Windows, profile with `handle.exe` (SysInternals) instead of trying to raise a limit.
  • cmd users sometimes hit the **8191-char command-line limit** (an undocumented `lpCommandLine` cap in `CreateProcess`). It's NOT a ulimit — it's a hard Windows OS limit. The workaround is response files (`@args.txt`) or stuffing the args through `cmd /c file.bat` with the bat file reading from disk.

WSL & PowerShell Core notes

pwshNo shell-level ulimit on pwsh. For Linux pwsh, shell out: `bash -c "ulimit -n 8192 && exec pwsh -File script.ps1"`. For Windows pwsh, use Job Objects via `[System.Diagnostics.Process]` start info or the unmanaged WIN32 `SetInformationJobObject` API — much heavier-weight than a one-line builtin.
WSLWSL bash `ulimit -n 65536` works for the WSL session and any process spawned from it. Limits do NOT propagate to Windows-side processes (`cmd.exe /c app.exe`). For Windows-side high-FD apps, configure Windows handle limits separately (most aren't configurable).

Related commands