CHCON(1)
π CHCON π
okay bestie, gather round, because this one's from the General Commands Manual and it's lowkey iconic. you're holding the manual page for chcon (that's "change context," and yes, it's giving main character energy).
β¨ NAME β¨
chcon β change the SELinux security context of each FILE to CONTEXT.
with --reference, change the security context of each FILE to that of RFILE. π¦
πΈ SYNOPSIS πΈ
chcon [OPTION]... CONTEXT FILE...
chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
chcon [OPTION]... --reference=RFILE FILE...
π DESCRIPTION π
so basically, chcon changes the SELinux security context of each FILE to CONTEXT. no cap.
and with --reference? it changes the security context of each FILE to that of RFILE instead. two vibes, one tool. periodt. π
π OPTIONS π
--dereferenceβ affect the referent of each symbolic link (this is the default), rather than the symbolic link itself. so the thing it points to gets the glow-up, not the link.-h,--no-dereferenceβ affect symbolic links instead of any referenced file. the link itself is the star now. β¨--helpβ help. that's it, that's the option. (the original help text literally just sayshelp, bestie, I don't make the rules)--preserve-rootβ fail to operate recursively on/. it's the "please do not touch the entire filesystem" button. π--no-preserve-rootβ do not treat/specially (this is the default). do not do this while doing recursive stuff, I'm literally begging π--reference <RFILE>β use the security context of RFILE, rather than specifying a CONTEXT value. copy her outfit, don't design your own. π-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.-R,--recursiveβ operate on files and directories recursively. it goes all the way down. π-Hβ if a command line argument is a symbolic link to a directory, traverse it. only valid when-Ris specified. β οΈ-Lβ traverse every symbolic link to a directory encountered. only valid when-Ris specified. β οΈ-Pβ do not traverse any symbolic links (this is the default). only valid when-Ris specified. β οΈ-v,--verboseβ output a diagnostic for every file processed. she's chatty and we love that for her. π¬-V,--versionβ print version.[FILE]β the file(s). yeah, the original option list really does just say[FILE]like that. iykyk. π
π VERSION π
v(uutils coreutils) 0.12.0
π§ EXAMPLES π§
view the security context of a file:
ls [-lZ|-l --context] path/to/file
change the security context of a target file, using a reference file:
chcon --reference reference_file target_file
change the full SELinux security context of a file:
chcon user:role:type:range/level filename
change only the user part of the SELinux security context:
chcon [-u|--user] user filename
change only the role part of the SELinux security context:
chcon [-r|--role] role filename
change only the type part of the SELinux security context:
chcon [-t|--type] type filename
change only the range/level part of the SELinux security context:
chcon [-l|--range] range/level filename
these examples came from the tldr-pages project at <https://tldr.sh>, and they're shared under the CC BY 4.0 License. π one thing though β as uutils is a work in progress, some examples might fail. not a skill issue, just a WIP vibe check. π
okay that's the whole page, bestie, you ate. π«Ά this was CHCON(1) from the General Commands Manual, from v(uutils coreutils) 0.12.0, dated 2026-09-25. go forth and change some contexts. slay. π
π₯π
π¦ where this page comes from
- ubuntu stonking: rust-coreutils 0.12.0-1ubuntu2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms