Linux ulimit Command

Chưa phân loại
“ulimit” is an interesting Linux shell command that can set or report the resource limit of the current user.

Of course, because of its nature, working with “ulimit” requires admin access (when changing value). Moreover, it’ll only work on systems that allow control through the shell. Without further ado, let’s get started with “ulimit”!


Fire up the terminal and run the following command.

which ulimit

This shows up an error, right? Why? It’s because “ulimit” isn’t a separate binary. It’s embedded into the shell itself.

Basic usage

Just run the command by itself.


As the output suggests, the current user has “unlimited” amount of resources to be accessed. Essentially, this means the current user can consume all the resources the current system supports.

To get the report in details, add the “-a” flag at the end. This will print all the resource limits for the current user.

ulimit -a

Note: There are 2 types of resource limitation: “hard” and “soft”. Hard resource limit defines the physical limit that the user can reach. The “soft” resource limit is manageable by the user. Its value can go up to the “hard” limit.

The system resources are defined in a configuration file located at “/etc/security/limits.conf”. “ulimit”, when called, will report these values.

cat /etc/security/limits.conf

Checking different limits of a user

How about displaying the individual parameters? Then call “ulimit” with the respective parameters.

Note: Not all of these commands will work as not every system incorporates the features.

To check the value of max “core file size”, use the flag “-c”. The result will be shown in blocks.

ulimit -c

For max “data seg size” (in kilobytes), use the flag “-d”.

ulimit -d

In scheduling, priority matters. Check out the max scheduling priority of the current user with the help of the “-e” flag.

ulimit -e

To check the maximum stack size of the current user, use the flag “-s”.

ulimit -s

For the maximum number of user processes, use the flag “-u”.

ulimit -u

For the maximum number of threads, use the flag “-T”.

ulimit -T

For getting the size of virtual memory, use the following one.

ulimit -v

Let’s check out the socket buffer size!

ulimit -b

This one is an interesting one. The following command will report the time each process is allowed to run for.

=ulimit -t

File descriptors are another interesting part of the Linux ecosystem. To check out how many file descriptors a process can have, run the following one.

ulimit -n

For the complete list of “ulimit” flags, check out the help page of “ulimit”.

ulimit –help

Setting values

Up until now, we’ve seen how to check the values of the resource limits of the current system. Now, it’s time to see how to manually modify these values.

Note: For changing the “hard” limit, it’ll require admin access, i.e. “root” permission. Make sure not to mess things up!

We mentioned the “limits.conf” file, right? It’s the core that DEFINES all the limits that’ll be applicable to the users.

sudo vim /etc/security/limits.conf

As shown in the file, each entry has to follow the following structure.

<domain> <type> <item> <value>

The “domain” part can be any of these values.

  • A specific user
  • A group
  • Wildcard (* and %)

The “type” part allows the following values.

  • “soft” (for implementing soft limits)
  • “hard” (for implementing hard limits)

Next up, the “item” part. The list of available options is quite long! Here are some of the interesting ones.

  • core: Core file size (in KB).
  • data: Max data size (in KB)
  • fsize: Max file size (in KB).
  • memlock: Max locked-in-memory address space (in KB).
  • nofile: Max number of file descriptors
  • stack: Max size of the stack (in KB).
  • cpu: Maximum CPU time (in MIN).
  • maxlogins: Maximum number of logins for the current user/group
  • priority: Set the priority of the user’s processes
  • rtprio: Max priority in real-time.

As of the “value” field, put an integer value. Note that the unit of each field is associated with the value of “item” part.

The changes will take into effect after exiting and re-logging into the associated user account.

For the in-depth info on the “limits.conf” configuration file, check out its man page.

man limits.conf

Final thoughts

While the usage of the “ulimit” command isn’t so complex, it plays an important role in determining the available system resources and ultimately, determining the performance. To know more about this command, check out its man and info pages.

ulimit –help

man ulimit

info ulimit


ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Moodle [Part 6] – Hướng dẫn tạo Category (Chủ đề hay Thể loại) và các Course (Khóa học)

Ở bài viết trước, Onet đã hướng dẫn cách thêm tài khoản vào hệ thống Moodle. Trong bài viết...

Get List of Installed packages on Ubuntu 20.10

Ubuntu is a Linux based distribution that comes with many packages installed. Packages are a collection of files that require...

How to find and change the MAC address on Linux

Our network card has at least two addresses or identificators, the IP address we all know which can be dynamic and the...
Bài Viết

Bài Viết Mới Cập Nhật

mua Proxy riêng ở đâu, và nó đem lại lợi ích gì cho người sử dụng

Hướng dẫn sử dụng Proxy Helper Fakeip khi thuê proxy


Mua Proxy Nuôi Zalo Giá Rẻ Tại