Set the soft open-file limit to 2048 for the current Bash and future child processes.
Leave the hard limit unchanged.
Which command is appropriate?
ulimit -S -n 2048 sets the soft open-file limit and leaves the hard limit unchanged.
Detailed explanation
ulimit -H -n 2048Incorrect. -H changes the hard limit.
Incorrect. -H changes the hard limit.
ulimit -S -n 2048Correct. It sets the soft open-file limit to 2048.
Correct. It sets the soft open-file limit to 2048.
ulimit -S -u 2048Incorrect. -u targets user-process count.
Incorrect. -u targets user-process count.
ulimit -S -nIncorrect. Omitting the value only displays the soft limit.
Incorrect. Omitting the value only displays the soft limit.
Try it yourself
An example you can run in a temporary verification environment.
bash -c 'hard=$(ulimit -H -n); current=$(ulimit -S -n); target=$((current < 2048 ? current : 2048)); ulimit -S -n "$target"; printf "soft=%s hard=%s
" "$(ulimit -S -n)" "$(ulimit -H -n)"'Expected result
softは安全に設定した値、hardは変更前と同じ値Key points
- -S is soft
- -H is hard
- Soft cannot exceed hard
Notes
- Environment: Bash 5.x / 短命な子shell内のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.