CHCON(1)

๐Ÿ’… chcon โ€” like, the manual page, bestie (User Commands, section 1, she's iconic)

okay so picture this: you've got files, right? and SELinux has opinions about them. chcon is the girl who goes in and changes those opinions. she's from the User Commands part of the manual, section 1, and honestly? she ate.


โœจ NAME โœจ

chcon โ€” change file security context ๐ŸŽ€


๐ŸŒธ SYNOPSIS ๐ŸŒธ


---

# ๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

So basically: change the SELinux security context of each *FILE* to *CONTEXT*. That's the whole vibe. ๐Ÿซถ

But if you pass `--reference`, it's a different story โ€” then she changes the security context of each *FILE* to that of *RFILE*. Like "make it match *that* one over there, bestie." ๐Ÿ˜Œ

> real talk though: mandatory arguments to long options are mandatory for short options too. no exceptions, no cap. โญ

### โœจ the flags, one by one โœจ

- **`--dereference`** โ€” affect the referent of each symbolic link rather than the symbolic link itself. this one is *the default*, so she's already doing it before you even ask ๐Ÿ’…
- **`-h`, `--no-dereference`** โ€” the opposite energy: affect symbolic links instead of any referenced file ๐Ÿฆ‹
- **`-u`, `--user=USER`** โ€” set user *USER* in the target security context ๐Ÿ‘‘
- **`-r`, `--role=ROLE`** โ€” set role *ROLE* in the target security context ๐ŸŽ€
- **`-t`, `--type=TYPE`** โ€” set type *TYPE* in the target security context ๐ŸŒธ
- **`-l`, `--range=RANGE`** โ€” set range *RANGE* in the target security context ๐ŸŒˆ
- **`--no-preserve-root`** โ€” do not treat `/` specially. this is the default, she's chill like that โญ
- **`--preserve-root`** โ€” fail to operate recursively on `/`. ok so *this* is the one you want if you're the cautious type ๐Ÿ”ฅ
- **`--reference=RFILE`** โ€” use *RFILE*'s security context rather than specifying a *CONTEXT* value. copy her fit exactly, iykyk ๐Ÿ™ˆ
- **`-R`, `--recursive`** โ€” operate on files and directories recursively. all the way down, bestie ๐Ÿ’€
- **`-v`, `--verbose`** โ€” output a diagnostic for every file processed. she will *tell* you about every single one ๐Ÿ—ฃ๏ธ

### ๐Ÿงš how the hierarchy gets traversed ๐Ÿงš

okay these next ones only matter when `-R` is also in the mix โ€” they modify how a hierarchy is traversed. and listen: if more than one is specified, **only the final one takes effect**. so don't be out here stacking them thinking they all apply, because they do not, periodt. ๐Ÿ’€

- **`-H`** โ€” if a command line argument is a symbolic link to a directory, traverse it ๐Ÿฆ‹
- **`-L`** โ€” traverse every symbolic link to a directory encountered ๐ŸŒธ
- **`-P`** โ€” do not traverse any symbolic links. this one is the **default** ๐Ÿ’…

### ๐ŸŽ€ the little helpers ๐ŸŽ€

- **`--help`** โ€” display this help and exit ๐Ÿ‘‹
- **`--version`** โ€” output version information and exit โœจ

---

# ๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Written by Russell Coker and Jim Meyering. legends fr fr ๐Ÿซถ

---

# ๐Ÿ”ฅ REPORTING BUGS ๐Ÿ”ฅ

- Report bugs to: `bug-coreutils@gnu.org` ๐Ÿ“ฌ
- GNU coreutils home page: <https://www.gnu.org/software/coreutils/> ๐ŸŒ
- General help using GNU software: <https://www.gnu.org/gethelp/> ๐Ÿซถ
- Report any translation bugs to <https://translationproject.org/team/> ๐ŸŒˆ

---

# ๐Ÿ’œ COPYRIGHT ๐Ÿ’œ

Copyright ยฉ 2025 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law. ๐Ÿ˜ญ (yes, really, zero warranty, read it and weep)

---

# โญ SEE ALSO โญ

- Full documentation <https://www.gnu.org/software/coreutils/chcon> ๐Ÿ“–
- or available locally via: `info '(coreutils) chcon invocation'` ๐Ÿงš

---

okay that's the whole page, go forth and context-ify responsibly ๐Ÿ’–

โ€” xoxo, this was `GNU coreutils 9.8`, dated `September 2025`, signing off from the `CHCON(1)` footer like the main character she is ๐ŸŒŸ
๐Ÿ“ฆ where this page comes from