CHCON(1)

πŸ“¦
version 9.10 Β· 5 versions
, in ubuntu stonking

πŸ’– chcon β€” change file security context πŸ’–

ok bestie, welcome to your manual page for chcon, which is a User Commands situation from the GNU coreutils girlies ✨. chcon is short for "change context," and she changes the SELinux security context. She's giving security-label glow-up, she's giving filesystem main character energy, and she is genuinely so easy once we get through this together. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

chcon [OPTION]... CONTEXT FILE...
chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
chcon [OPTION]... --reference=RFILE FILE...

like, three ways in, pick your fighter πŸ’…


🌸 DESCRIPTION 🌸

so the whole vibe: change the SELinux security context of each FILE to CONTEXT. and with --reference, change the security context of each FILE to that of RFILE. that's it. that's the job. πŸ’–

⚠️ real talk before we go any further: mandatory arguments to long options are mandatory for short options too. no cap. if a long option needs a value, the short version needs it too.

✨ the options, one by one, no skips ✨

  • --dereference β€” affect the referent of each symbolic link (this is the default), rather than the symbolic link itself. so by default we're messing with the thing the symlink points at, not the symlink. iconic behaviour tbh 🫢
  • -h, --no-dereference β€” affect symbolic links instead of any referenced file. flip it, now we're changing the link itself πŸ¦‹
  • -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 (the default). yes queen, / is just another path here πŸ™ˆ
  • --preserve-root β€” fail to operate recursively on /. the responsible option. the one your sysadmin bestie wants you to use πŸ’€
  • --reference=RFILE β€” use RFILE's security context rather than specifying a CONTEXT value. copy the drip, don't type it out πŸ”₯
  • -R, --recursive β€” operate on files and directories recursively. your whole little tree, all of it, every single one πŸ‘‘
  • -v, --verbose β€” output a diagnostic for every file processed. she's telling you everything, and honestly? we love that for us πŸ’…

🧚 how the traversal goes down 🧚

the following options modify how a hierarchy is traversed when the -R option is also specified. if more than one is specified, only the final one takes effect. -P is the default. periodt. ✨

  • -H β€” if a command line argument is a symlink to a directory, traverse it 🌸
  • -L β€” traverse every symbolic link to a directory encountered πŸ¦‹
  • -P β€” do not traverse any symbolic links 🌈

πŸŽ€ and the two classics πŸŽ€

  • --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/


πŸ” SEE ALSO πŸ”

Full documentation https://www.gnu.org/software/coreutils/chcon

or available locally via: info '(coreutils) chcon invocation'

Packaged by Ubuntu (9.10-1ubuntu2)

Copyright Β© 2026 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.


and that's the whole page bestie!! πŸ’–πŸ¦‹βœ¨ this one comes to you from GNU coreutils 9.10, dated August 2026, and it's CHCON(1) in the User Commands section β€” go forth and label responsibly, mwah πŸŽ€πŸ’…πŸ«Ά

πŸ“¦ where this page comes from