<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/day-203-how-to-set-user-resource-limits-in-linux-b3yw4mczr" -->

---
title: Day 203 — How to Set User Resource Limits in Linux
description: Linux resource limits prevent individual users and processes from exhausting shared system resources. The post covers soft vs. hard limits, using `ulimit` for...
canonical: https://daily.dev/posts/day-203-how-to-set-user-resource-limits-in-linux-b3yw4mczr
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Day 203 — How to Set User Resource Limits in Linux | daily.dev
og:description: Linux resource limits prevent individual users and processes from exhausting shared system resources. The post covers soft vs. hard limits, using `ulimit` for...
og:url: https://daily.dev/posts/day-203-how-to-set-user-resource-limits-in-linux-b3yw4mczr
og:image: https://api.daily.dev/og/posts/b3Yw4mcZR.png
og:image:alt: Day 203 — How to Set User Resource Limits in Linux
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Day 203 — How to Set User Resource Limits in Linux

**[Medium](https://daily.dev/sources/medium_js)** · 4 min read · 0 upvotes · 0 comments

## Summary

Linux resource limits prevent individual users and processes from exhausting shared system resources. The post covers soft vs. hard limits, using `ulimit` for temporary session-level controls, configuring persistent limits via `/etc/security/limits.d/`, applying PAM integration, and setting limits for systemd-managed services using service override files. Practical examples include controlling open file descriptors, process counts, core dumps, memory, and CPU quotas.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@alokrahuldevops/day-203-how-to-set-user-resource-limits-in-linux-f6be71c3eb31>

## Questions this post answers

### How do I set persistent open file and process limits for a Linux user?

Create a configuration file under /etc/security/limits.d/, such as developers.conf, with lines following the syntax 'domain type item value', for example 'developer soft nofile 4096' and 'developer hard nofile 8192' for open files, and 'developer soft nproc 2048' with 'developer hard nproc 4096' for processes. The PAM configuration must include 'session required pam_limits.so', and users must log out and back in for changes to take effect.

_daily.dev surfaces practical sysadmin guides like this for engineers hardening shared Linux servers._

### How do I limit CPU and memory usage for a systemd service?

Run 'sudo systemctl edit myapp.service' and add a [Service] block with directives such as LimitNOFILE=16384, LimitNPROC=4096, LimitCORE=0, MemoryMax=2G, and CPUQuota=50%. Apply changes with 'sudo systemctl daemon-reload' followed by 'sudo systemctl restart myapp.service', then verify with 'systemctl show myapp.service | grep -E "Limit|MemoryMax|CPUQuota"' since PAM-based limits do not apply to systemd-managed services.

_Engineers tuning resource isolation for production services can find similar walkthroughs on daily.dev._

### What is the difference between a soft limit and a hard limit in Linux?

A soft limit is the value currently enforced by the operating system and can be raised by a regular user up to the configured hard limit, while the hard limit is the maximum allowed value that only root or a privileged process can increase. Current shell limits can be viewed with 'ulimit -a', and a specific limit like open files with 'ulimit -n'.

_daily.dev helps developers troubleshooting resource exhaustion track down Linux limit fundamentals like these._

## Similar posts on daily.dev

- [Linux Capabilities Revisited](https://daily.dev/posts/linux-capabilities-revisited-34qqueksc) · Hacker News · 0 upvotes · 0 comments
- [Day 10: File Permission Correction — Going Beyond rwx with Linux ACLs](https://daily.dev/posts/day-10-file-permission-correction-going-beyond-rwx-with-linux-acls-e8gdnbnsb) · Medium · 1 upvotes · 0 comments
- [I capped CPU and RAM on my Docker containers, and my entire self-hosted homelab became reliable](https://daily.dev/posts/i-capped-cpu-and-ram-on-my-docker-containers-and-my-entire-self-hosted-homelab-became-reliable-ane2mityw) · XDA Developers · 4 upvotes · 0 comments
- [Linux Server Hardening: What to Do First and Why It Matters](https://daily.dev/posts/linux-server-hardening-what-to-do-first-and-why-it-matters-4tf1eutt4) · Latest Hacking News · 1 upvotes · 0 comments

---

Tags: [#linux](https://daily.dev/tags/linux)

[View this post on daily.dev](https://daily.dev/posts/day-203-how-to-set-user-resource-limits-in-linux-b3yw4mczr)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Day 203 — How to Set User Resource Limits in Linux","url":"https://daily.dev/posts/day-203-how-to-set-user-resource-limits-in-linux-b3yw4mczr","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/day-203-how-to-set-user-resource-limits-in-linux-b3yw4mczr"},"datePublished":"2026-07-26T06:49:00.222Z","dateModified":"2026-09-14T06:02:37.037Z","description":"Linux resource limits prevent individual users and processes from exhausting shared system resources. The post covers soft vs. hard limits, using `ulimit` for...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/13ac407ff60bdf88ac24cdb1e7686b1e?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/13ac407ff60bdf88ac24cdb1e7686b1e?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/day-203-how-to-set-user-resource-limits-in-linux-b3yw4mczr","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"linux","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Day 203 — How to Set User Resource Limits in Linux"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/day-203-how-to-set-user-resource-limits-in-linux-b3yw4mczr#faq","mainEntity":[{"@type":"Question","name":"How do I set persistent open file and process limits for a Linux user?","acceptedAnswer":{"@type":"Answer","text":"Create a configuration file under /etc/security/limits.d/, such as developers.conf, with lines following the syntax 'domain type item value', for example 'developer soft nofile 4096' and 'developer hard nofile 8192' for open files, and 'developer soft nproc 2048' with 'developer hard nproc 4096' for processes. The PAM configuration must include 'session required pam_limits.so', and users must log out and back in for changes to take effect. daily.dev surfaces practical sysadmin guides like this for engineers hardening shared Linux servers."}},{"@type":"Question","name":"How do I limit CPU and memory usage for a systemd service?","acceptedAnswer":{"@type":"Answer","text":"Run 'sudo systemctl edit myapp.service' and add a [Service] block with directives such as LimitNOFILE=16384, LimitNPROC=4096, LimitCORE=0, MemoryMax=2G, and CPUQuota=50%. Apply changes with 'sudo systemctl daemon-reload' followed by 'sudo systemctl restart myapp.service', then verify with 'systemctl show myapp.service | grep -E \"Limit|MemoryMax|CPUQuota\"' since PAM-based limits do not apply to systemd-managed services. Engineers tuning resource isolation for production services can find similar walkthroughs on daily.dev."}},{"@type":"Question","name":"What is the difference between a soft limit and a hard limit in Linux?","acceptedAnswer":{"@type":"Answer","text":"A soft limit is the value currently enforced by the operating system and can be raised by a regular user up to the configured hard limit, while the hard limit is the maximum allowed value that only root or a privileged process can increase. Current shell limits can be viewed with 'ulimit -a', and a specific limit like open files with 'ulimit -n'. daily.dev helps developers troubleshooting resource exhaustion track down Linux limit fundamentals like these."}}]}
```

