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
- alpine 3.23: coreutils-doc 9.8-r1 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms