2

The commands I am/trying to use in terminal are:

sudo /bin/su -c “echo ‘fs.file-max=1000000’ >> /etc/sysctl.conf”
sudo /bin/su -c “echo ‘* soft nofile 1000000’ >> /etc/security/limits.conf”
sudo /bin/su -c “echo ‘* hard nofile 1000000’ >> /etc/security/limits.conf”
sudo /bin/su -c “echo ‘session required pam_limits.so’ >> /etc/pam.d/common-session”

All I’m getting is “permission denied” or no response to the various methods I’ve tried. I’m currently logged into the first and only account on the PC. Any help would be appreciate, just installed this Ubuntu OS last night.

Rinzwind
  • 299,756

2 Answers2

2

You can pipe echo to sudo tee -a to get the same result.

echo 'fs.file-max=1000000' | sudo tee -a /etc/sysctl.conf
echo '* soft nofile 1000000' | sudo tee -a /etc/security/limits.conf
echo '* hard nofile 1000000' | sudo tee -a /etc/security/limits.conf
echo 'session required pam_limits.so' | sudo tee -a /etc/pam.d/common-session

The -a option with tee will append the output to the end of the file. Make sure to use the -a option or you will overwrite the entire file.

Use tee --help for more information.

mchid
  • 43,546
  • 8
  • 97
  • 150
  • I would like to apologize in advance for my lack of knowledge in this area; I copy and pasted what you wrote and entered my password. " fs.file-max=1000000 " displayed and as far as I can tell nothing happened, tried ulimit -n and it is still giving me 1024. – Tickling Aug 20 '19 at 19:27
  • @Tickling After you make changes to /etc/sysctl.conf, you have to run sudo sysctl -p to apply the changes. You may need to reboot to apply the changes to the other files. The changes to /etc/sysctl.conf should show when you run cat /proc/sys/fs/file-max. – mchid Aug 20 '19 at 21:17
  • @Tickling https://www.tecmint.com/increase-set-open-file-limits-in-linux/ – mchid Aug 20 '19 at 21:19
  • @ mchid thanks again for your help. So it appears that I did change something (in fact I added the soft/hard nofile lines several times), when entering cat /proc/sys/fs/file-max, the value comes up as 1000000. I have rebooted several times and ulimit -n still shows 1024. What am I doing wrong? – Tickling Aug 20 '19 at 22:37
  • @Tickling Maybe this will help. https://askubuntu.com/questions/162229/how-do-i-increase-the-open-files-limit-for-a-non-root-user?rq=1 If you still have a problem, then you need to ask a new question. One question at a time please. Thanks! Also, ulimit --help – mchid Aug 21 '19 at 00:12
1

All of these can be done as "root". So

sudo -i
{password}
echo "fs.file-max=1000000" >> /etc/sysctl.conf
echo "* soft nofile 1000000" >> /etc/security/limits.conf
echo "* hard nofile 1000000" >> /etc/security/limits.conf
echo "session required pam_limits.so" >> /etc/pam.d/common-session

Also be wary that you are using the wrong quotes in your question.

Example:

$ sudo -i
[sudo] password for rinzwind: 
# echo "fs.file-max=1000000" >> /etc/sysctl.conf
# 
Rinzwind
  • 299,756
  • Thank you so much for your help, I am completely new to this. I copy and pasted what you wrote and it did access the root terminal, however as far as I can tell nothing happened. I tried ulimit -n and it is still showing 1024. For the quotes did you mean use " instead of ' ? – Tickling Aug 20 '19 at 19:32
  • @Tickling Changing configuration files will usually not change anything in the currently running session, please reboot to make the changes take effect. – mook765 Aug 20 '19 at 20:55
  • @Tickling The quotation marks you used in your question are and , these are fancy looking quotation marks. If you copy and paste these fancy looking quotes they may not work correctly. You can see that the quotation marks are angled and not straight up and down. The correct ones to use are " and '. You can see they are slightly different. Sometimes, the people who write tutorials don't properly format code in their HTML and so the quotation marks are fancy or there could be some other reason. – mchid Aug 20 '19 at 21:29