• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Linux

Ulimit value : All you need to know

Published: January 13, 2017 | Modified: June 20, 2020



Understand what is ulimit? How to set it? Which all system resources can be limited using ulimit control? and how to view current ulimit settings.

In this article, we are going to see everything about bash built-in ulimit value. This is your key to keep the system safe from fork bombs or malicious codes aimed at hung systems by crunching resources.

What is ulimit?

It can roughly be called a user limit! Using this value you are limiting shell and its forked processes to use certain defined system resources. This helps in managing system resources and in turn processes efficiently. Using you can make sure that all-important processes on the server always get resources while the least important once cant hog more than what they should get. There are different parameters can be defined under ulimit umbrella which we will see ahead.

To view your current ulimit setting run below command :

# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 95174
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1024
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

As you can see in the above output, the left column denotes parameters that can be limited using ulimit, along with their measuring unit and option to be used in braces and the last column shows current set value.

ulimit controlled parameters :

See below list of parameters that can be limit using ulimit and their details. The list is from man page and parameters are self-explanatory. Since this is bash built-in; when you check the manpage, you will see all bash commands. You have to scroll that man page all the way to bottom (since its alphabetically sorted) to get to ulimit section. There you will find these parameters.

Different ulimit parameters

OptionParameter
-a
All current limits are reported
-b
The maximum socket buffer size
-c
The maximum size of core files created
-d
The maximum size of a process’s data segment
-e
The maximum scheduling priority (“nice”)
-f
The maximum size of files written by the shell and its children
-i
The maximum number of pending signals
-l
The maximum size that may be locked into memory
-m
The maximum resident set size (many systems do not honor this limit)
-n
The maximum number of open file descriptors (most systems do not allow this value to be set)
-p
The pipe size in 512-byte blocks (this may not be set)
-q
The maximum number of bytes in POSIX message queues
-r
The maximum real-time scheduling priority
-s
The maximum stack size
-t
The maximum amount of cpu time in seconds
-u
The maximum number of processes available to a single user
-v
The maximum amount of virtual memory available to the shell
-x
The maximum number of file locks
-T
The maximum number of threads

To set specific parameter limit values, you can issue the command :

# ulimit -option <value>

Once done, it will limit this parameter for the current shell (shell from where the command was run) and it’s all forked processes. A more efficient way to implement limits is through profiles that are discussed next.

How to setup ulimit :

The most common use in corporate Infra is for database servers. Since we all know that DB is resource-hungry application. So many times ulimits specified to it in terms of  -p or -n etc. This setting is done in DB owner user id like Oracle’s (user id with which DB application runs on the server) .bash_profile in its home or /etc/profile or through custom scripts which loads when DB starts. Find below code snippet which can be used in /etc/profile:

if [ $USER = "oracle" ] || [ $USER = "oradb" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 10000 -n 35000
fi
fi

Whenever users logged in, /etc/profile gets executed. It checks if the user is oracle or oradb and if yes with Ksh shell, it sets respective ulimits values for it!

This ensures parameters are set for that user’s shell when DB application starts in the user’s shell. Since,ulimit limits resources for shell and its forked processes, these values get imposed for DB apps running under that user’s shell!

⇠ Previous article
How to run your script with system boot in HPUX
Next article ⇢
How to map Linux disk to vmware disk

Related stuff:

  • Linux user management (useradd, userdel, usermod)
  • Linux mascot penguin: TUX
  • Linux scheduler: Cron, At jobs
  • How to get directory size in Linux
  • How to upgrade from Oracle Linux 6 to Oracle Linux 7
  • Understanding /etc/fstab file
  • How to configure EC2 for Session Manager
  • All you need to know about hostname in Linux
  • SUSE Manager 4 Setup Configuration
  • Difference between LVM and LVM2: Linux interview question explained
  • 9 Linux account password policies explained
  • 4 ways to check the size of physical memory (RAM) in Linux

Filed Under: Linux Tagged With: how to set ulimit, list of ulimit parameters, ulimit config, ulimit configuration in linux, What is ulimit, what is use of ulimit

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2023 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.