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 says help, 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 -R is specified. ⚠️
  • -L β€” traverse every symbolic link to a directory encountered. only valid when -R is specified. ⚠️
  • -P β€” do not traverse any symbolic links (this is the default). only valid when -R is 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