# Users, Groups and Permissions

> Control who can read, write and execute what on a Linux system, and grant elevated access without handing out root. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/devops/users-permissions
Last updated: 2026-11-28

Control who can read, write and execute what on a Linux system, and grant elevated access without handing out root.

Beginner · about 5 hours · difficulty 2/5

Learn first: [Linux Command Line and Packages](https://www.internhack.in/roadmaps/tracks/devops/linux-basics)

Permissions are the first layer of least privilege. Misconfigured permissions cause both security holes and baffling "permission denied" failures in deploys.

### The model

- Every file has an **owner**, a **group**, and read/write/execute bits for owner, group and others. Read them with `ls -l`, change them with `chmod` (symbolic `u+x` or octal `640`) and `chown user:group`.
- On directories, **x** means "can enter" and **r** means "can list".
- Special bits: **setuid**, **setgid** (new files inherit the directory group) and the **sticky bit** (as on `/tmp`).
- **umask** sets default permissions for new files.

### Users and privilege

- Accounts live in `/etc/passwd` and `/etc/shadow`; groups in `/etc/group`. Use `useradd`, `usermod -aG`, `id`.
- **Service accounts**: run each daemon as its own non-login user.
- **sudo** with rules in `/etc/sudoers.d/` (edit via `visudo`) grants specific commands instead of full root.
- Beyond basics: ACLs (`setfacl`), and mandatory access control with SELinux or AppArmor.

### Pitfalls

`chmod -R 777` to "fix" an error, running apps as root, and disabling SELinux instead of reading its audit log.

**Good enough to move on:** you can create a service user, give a deploy group write access to one directory only, and grant a single sudo command.

## Key concepts

- **rwx bits, chmod and chown**
- **Users, groups and service accounts**
- **sudo and sudoers**
- **setuid, setgid, sticky bit**
- **umask**
- **ACLs**
- **SELinux / AppArmor**

## Mini project

Create an app user and a deployers group. Make /srv/app writable by deployers only, run a small service as the app user, and allow deployers to restart just that service with sudo.

## Check yourself

Why can a user sometimes delete a file they have no write permission on?

## Free resources

- [Linux Journey: Permissions](https://linuxjourney.com/) (linuxjourney.com)
- [sudoers(5) man page](https://man7.org/linux/man-pages/man5/sudoers.5.html) (man7.org)

Previous: [Filesystems, Disks and Storage](https://www.internhack.in/roadmaps/tracks/devops/filesystems-storage) · Next: [Services with systemd](https://www.internhack.in/roadmaps/tracks/devops/systemd-services)

## More in Living on Linux

- [Linux Command Line and Packages](https://www.internhack.in/roadmaps/tracks/devops/linux-basics)
- [Processes, Signals and Resources](https://www.internhack.in/roadmaps/tracks/devops/processes-signals)
- [Filesystems, Disks and Storage](https://www.internhack.in/roadmaps/tracks/devops/filesystems-storage)
- [Users, Groups and Permissions](https://www.internhack.in/roadmaps/tracks/devops/users-permissions)
- [Services with systemd](https://www.internhack.in/roadmaps/tracks/devops/systemd-services)
- [Performance and Troubleshooting](https://www.internhack.in/roadmaps/tracks/devops/linux-performance)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
