-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathulimit.sh
More file actions
25 lines (19 loc) · 958 Bytes
/
ulimit.sh
File metadata and controls
25 lines (19 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
# Set limits in /etc/security/limits.conf
echo "* soft nofile 100000" | sudo tee -a /etc/security/limits.conf
echo "* hard nofile 100000" | sudo tee -a /etc/security/limits.conf
# Configure systemd limits
echo "DefaultLimitNOFILE=100000" | sudo tee -a /etc/systemd/system.conf
echo "DefaultLimitNOFILE=100000" | sudo tee -a /etc/systemd/user.conf
# Ensure PAM applies limits
grep -q "pam_limits.so" /etc/pam.d/common-session || echo "session required pam_limits.so" | sudo tee -a /etc/pam.d/common-session
grep -q "pam_limits.so" /etc/pam.d/common-session-noninteractive || echo "session required pam_limits.so" | sudo tee -a /etc/pam.d/common-session-noninteractive
# Apply changes to systemd
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
# Set limit in ~/.bashrc for user sessions
echo "ulimit -n 100000" >> ~/.bashrc
source ~/.bashrc
ulimit -n 100000
# Verify the new limit
echo "Updated file descriptor limit: $(ulimit -n)"