- shivani singh
- November 11, 2021
Step By Step Guide to Run ULimit Commands on Ubuntu 20.04 LTS
Ulimit is a free & open source Linux command. It is used to see, set, or limit the resource usage of the current user. We can easily set the restrictions on the resources used by a process. Using ulimit commands, we gets the information about the memory size limit, maximum stack size, file size & maximum users process of the current user.
There are some commands of ulimit with examples:
Step 1: Update the System.
apt-get update
Step 2: Ulimit Syntax & Examples:
- Run the ulimit command to check current user has amount of resources to be accessed.
ulimit
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit
unlimited
- To check the ulimit value.
ulimit -a
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# 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) 15668
max locked memory (kbytes, -l) 65536
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) 15668
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
- To show maximum users process.
ulimit -u
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit -u
15668
- To show the maximum file size for current user.
ulimit -f
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit -f
unlimited
- To show maximum memory size for current user.
ulimit -m
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit -m
unlimited
- To display maximum memory size limit.
ulimit -v
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit -v
unlimited
- To show the the Hard limit.It is restriction to the maximum value of soft limits.
ulimit -Hn
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit -Hn
1048576
- To show the the Soft limit.It is the processing limit.
ulimit -Sn
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit -Sn
1024
- Change Soft Limit values.
sysctl -w fs.file-max=<value>
sysctl -w fs.file-max=500000
- Then,check the Soft limit.
cat /proc/sys/fs/file-max
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# sysctl -w fs.file-max=500000
fs.file-max = 500000
root@ip-172-31-37-166:/home/ubuntu# cat /proc/sys/fs/file-max
500000
- Check the maximum stack size.
ulimit -s
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit -s
8192
- To display all available option in ulimit.
ulimit --help
- Here is the command output.
root@ip-172-31-37-166:/home/ubuntu# ulimit --help
ulimit: ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
Modify shell resource limits.
Provides control over the resources available to the shell and processes
it creates, on systems that allow such control.
Options:
-S use the `soft' resource limit
-H use the `hard' resource limit
-a all current limits are reported
-b the 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
-k the maximum number of kqueues allocated for this process
-l the maximum size a process may lock into memory
-m the maximum resident set size
-n the maximum number of open file descriptors
-p the pipe buffer size
-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 user processes
-v the size of virtual memory
-x the maximum number of file locks
-P the maximum number of pseudoterminals
-T the maximum number of threads