Linux ulimit Command | Explained

The “ulimit” command line utility stands for “User Limit”. It is used to control or report particular user resources. The resources contain default values and limits. However, these values can be modified per the user’s requirement, i.e., to set the limit of file size, no of user processes, virtual memory, and much more.

This post provides a deep insight into the working and the usage of the ulimit command in Linux with the following outcomes:

Let’s start with the working of the “ulimit” command.

How Does ulimit Command Work in Linux?

The generalized syntax of the ulimit command is written below:


$ ulimit [flags][limit]

The syntax holds the following components:

  • ulimit: Identifies the “ulimit” command.
  • flags: Denotes the supported flags/options of the “ulimit” command.
  • limit: Represents the resource “Hard” or “Soft” limit value for a particular resource.

Limitation Types

The “ulimit” basically contains two types of resource limitations one is the “Hard” limit, and the other is the “Soft” limit. Both are described below:

Soft Limit

The soft limits are the effective value assigned to the user for the actual processing. The user can increase it but cannot adjust the soft limit higher than the hard limit.

Use the below command to get the detailed report of soft limit:

$ ulimit -Sa

Hard Limit

The “hard” limit is the maximum value that can only be changed by the root user. It also acts as an upper bound or ceiling of the soft limit.

Type the following command to check the detailed report of hard limit:

$ ulimit -Ha

Type the “–help” command in the terminal to get the built-in flags that are supported by the “ulimit” command:

$ ulimit --help

Scroll down the page to get the complete list of options/flags.

Examples of Linux ulimit Command

Now, look at the practical examples of the “ulimit” command to understand its functionality in Linux.

Example 1: Get Brief Limit Report

Generally, without any argument, the “ulimit” command provides the total value of the resources that a current user holds.

Use the “-a” flag to get the detail or brief report of that resources as shown in the screenshot:

$ ulimit -a

The output shows all the resources along with their limitations.

Example 2: Display Maximum Users Process

The “-u” flag represents the total value of the maximum process occupied by the user. The practical implementation of this flag is as follows:

$ ulimit -u

The output prints the logged-in user maximum processes that are “7490”.

Modify the Users Process Limit

To limit the process of the current logged-in “itslinuxfoss” or the particular user processes execute the “ulimit” command in the following way:

$ ulimit -u 20

The maximum process limit has been changed to “20”. This methodology is not recommended as it restricts the maximum process of each user. It prevents the users from using all the system processes.

Example 3: Show Maximum File Size

The “-f” flag displays the maximum size the user can make while working in Linux. It can be “unlimited” or a specific size in “Kilobytes”:

$ ulimit -f

The output shows that the maximum file size is “unlimited

Adjust the File size Limit

The “-f” flag is also beneficial to set or adjust the file size limit. In this example, the “File1.txt” size limit is adjusted to “40” which is occupied “39k” currently:

$ ulimit -f 40 File1.txt

If the user adds the content after adjusting its limit to “40k”, then it will show an error shown in the screenshot:

Example 4: Get Maximum Virtual Memory Size

The “-m” flag shows the maximum size of the virtual memory in “kilobytes” held by the process. It can be unlimited:

$ ulimit -v

The output displays the “unlimited” virtual memory.

The “unlimited” output specifies that the current process consumes all the available memory. The drawback of “unlimited” memory of a process is it slow downs the other processes, which consume low memory.

Set the Specific Memory Size Limit

The “unlimited” memory size of a process can be set to a specific limit by using the “-v” flag with the assigned memory:

$ ulimit -v 1000

Hence, the virtual memory has been modified to “1000kB”.

Example 5: Check Maximum Scheduling Priorities

The “-e” flag identifies the maximum scheduling priorities that a logged-in user can assign to a process. For this purpose, use the “ulimit” command with the “-e” flag in this way:

$ ulimit -e

Here, the user “itslinuxfoss” is not assigned any scheduling priority.

Example 6: Number of Opened Files

The “-n” flag shows the maximum number of files that can be opened simultaneously. It is also known as “file descriptor”. The “file descriptor” is typically a number that uniquely refers to an open file in the current working operating system.

In this example, the “-n” displays that the process has “13” file descriptors:

$ ulimit -n

How to Adjust the Hard and Soft Limits Manually?

The “limit.conf” configuration file defines the resource limits. This file is located in the “/etc/security” directory. Only the root user can make changes in this file. So logged-in as a root user or use the “sudo” command to edit this file.

Run the below command with “sudo” to open the “limit.conf” file in the “nano” text editor. This file defines all the applicable limits:

$ nano /etc/security/limits.conf

The above command pops up the “nano” editor “window” displaying “limit.conf” file information:

Scroll down the window to get the complete information.

As the file displays that each entry follows a structure. To change the default limit values and add the new limit values, follow the entry’s basic structure that contains four sections “domain”, “type”, “item”, “and value”. The description of these options is shown in the above screenshot.

It’s all about the Linux “ulimit” command.


Linux’s “ulimit” command is generally used to list down the resource limit occupied by the specific user. These limits are of two types “Hard” and “Soft”. The user can increase the limit of the resources in the range defined by default. This post has briefly illustrated a brief description of the “ulimit” command with the support of practical examples.