The limits. conf format is as follows:
Username | @ groupname type resource limit
Username | @ groupname: Set the user name to be restricted. The group name is preceded by @ and the user name. You can also use wildcard * to restrict all users.
Type: soft, hard, and-. Soft indicates the setting value that takes effect for the current system. Hard indicates the maximum value that can be set in the system. Soft cannot be more restrictive than har. -Indicates that both soft and hard values are set.
Resource:
Core-restrict the size of kernel files
Date-maximum data size
Fsize-Maximum File Size
Memlock-maximum memory address space locked
Nofile-Maximum number of opened files
RSS-maximum persistent setting size
Stack-maximum stack size
CPU-maximum CPU time in minutes
Noproc-Maximum number of processes
As-address space limit
Maxlogins-Maximum number of logins allowed by this user
To make the limits. conf file take effect, make sure that the pam_limits.so file is added to the Startup File. View the/etc/PAM. d/login file:
Session required/lib/security/pam_limits.so
Temporarily, it is applicable when logging on to a shell session through the ulimit command.
Permanently, add a corresponding ulimit statement to one of the files read by the logon shell (for example ~ /. Profile), which is a shell-specific user resource file, or by editing/etc/security/limits. conf.
What is a core file? When a program crashes, the stored images of the process are copied to the core file in the current working directory of the process. The core file is only a memory image (with debugging information added) and is mainly used for debugging. The core file is a binary file, and a corresponding tool is required to analyze the memory image when the program crashes.
The default core file size is 0, so no file is created. You can use the ulimit command to view and modify the size of the core file.
$ Ulimit-C
0
$ Ulimit-C 1000
$ Ulimit-C
1000
-C specifies the size of the core file, and 1000 specifies the size of the core file. You can also limit the size of the core file, for example:
# Ulimit-C Unlimited
# Ulimit-C
Unlimited
If you want the change to take effect permanently, You need to modify the configuration file, such as. bash_profile,/etc/profile, or/etc/security/limits. conf.
2. nofile-Maximum number of opened files
For applications that require many socket connections and make them open, it is best to use ulimit-N or set the nofile parameter, set the number of file descriptors to a higher value than the default value.