前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Can not login after change limits.conf

Can not login after change limits.conf

作者头像
heidsoft
发布2019-05-15 13:25:17
9600
发布2019-05-15 13:25:17
举报

https://serverfault.com/questions/836929/can-not-login-after-change-limits-conf

ssh user@server 'echo "fs.file-max = 10000000" > /etc/sysctl.conf; echo "fs.nr_open = 10000000" >> /etc/sysctl.conf'

Quickie tutorial: ulimit, soft limits, hard limits, soft stack, hard stack

Posted on April 12, 2014 by Ben · 3 Comments

A quick thing I ran into today using ulimit. Quick, helpful, short. So short maybe it didn’t necessitate such a long blog title.

ulimit for the impatient

Helpful commands you are likely looking for

Sponsored Links

  • ulimit -S -a view all soft limits
  • ulimit -H -a view all hard limits
  • ulimit -S [option] [number] set a specific soft limit for one variable
    • e.g. ulimit -S -s 8192 set a new soft stacksize limit, “-s” is for stack
  • ulimit -H [option] [number] set a specific hard limit for one variable
    • e.g. ulimit -H -s 8192 set a new hardstacksize limit, “-s” is for stack
  • /etc/security/limits.conf file where you can set soft and hard limits per user or for everyone
    • e.g. Add in the following to /etc/security/limits.conf will set a soft stacksize of 8192 adn a hard stacksize of unlimited for username “user”: user soft stack 8192 user hard stack unlimited

ulimit tutorial in more detail

What is ulimit?

ulimit provides control over resources available to each user via a shell. You can type “ulimit -a” to get a list of all current settings. In parentheses you will see one or two items: the units in measurements (e.g. kbytes, blocks, seconds) as well as a letter option (e.g. -s, -t, -u). The letter option will let you view/edit one particular setting at a time.

What can I set?

Using “ulimit -a” you can see all the values you can set. Using the man page you can get more details about what these are.

See below:

You can also look in the man page, though I prefer viewing the /etc/security/limits.conf file for more info. Easier to read. See excerpt below:

What is “soft” limit vs “hard” limit for ulimit?

  • A hard limit is the maximum allowed to a user, set by the superuser/root. This value is set in the file /etc/security/limits.conf. Think of it as an upper bound or ceiling or roof.
  • A soft limit is the effective value right now for that user. The user can increase the soft limit on their own in times of needing more resources, but cannot set the soft limit higher than the hard limit.

Can a user change default “soft” limits?

Yes, they can do so by putting a “ulimit” command in their shell startup file (typically .bashrc, .bash_profile, .cshrc, .profile, etc.)

e.g. if user wants to change soft limit for stack size to 8192, they put this in their login start up file:

ulimit -S -s 8192

If it is a script they are running (e.g. out of cron), they can also put this statement at the start of their shell script.

How to change the default “soft” limits and “hard” limits for user?

Superuser a.k.a. root can edit the /etc/security/limits.conf file for that user

An example /etc/security/limits.conf file

With all the above bullet points made, here is an example /etc/security/limits.conf file for you to see. Mostly self explanatory on all the options, and you’ll see I changed the default “soft” and “hard” stack for a specific user “byau”

An example session with ulimit commands

I opted for a screenshot instead of copy/paste because the copy/paste did not properly format (*sigh*). Making the screenshot much easier to read:

http://geekswing.com/geek/quickie-tutorial-ulimit-soft-limits-hard-limits-soft-stack-hard-stack/

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-05-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 云数智圈 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Quickie tutorial: ulimit, soft limits, hard limits, soft stack, hard stack
  • ulimit for the impatient
  • ulimit tutorial in more detail
    • What is ulimit?
      • What can I set?
        • What is “soft” limit vs “hard” limit for ulimit?
          • Can a user change default “soft” limits?
            • How to change the default “soft” limits and “hard” limits for user?
              • An example /etc/security/limits.conf file
                • An example session with ulimit commands
                领券
                问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档