matchpathcon(8)
β¨ matchpathcon(8) β¨
okay bestie, so this is matchpathcon from the SELinux Command Line documentation, and it's genuinely one of my faves. sit down, grab a lil drink, let's talk default security contexts π
πΈ NAME πΈ
matchpathcon β get the default SELinux security context for the specified path from the file contexts configuration. that's it, that's the whole vibe π«Ά
π SYNOPSIS π
matchpathcon [-V] [-N] [-n] [-m type] [-f file_contexts_file] [-p prefix] [-P policy_root_path] filepath...
like, yes, that's a lot of flags, but every single one is doing something, ok?? no filler flags in this house π
π¦ DESCRIPTION π¦
So basically matchpathcon goes and queries the system policy, and then it outputs the default security context that's associated with the filepath you gave it. that's the whole job. it's giving "let me look that up for you bestie" energy β¨
β οΈ note, and this one MATTERS: identical paths can totally have different security contexts depending on the file type β regular file, directory, link file, char file, ... you get it. same name, different context. no cap. π
And here's the cute part: matchpathcon will also take the file type into consideration when it's figuring out the default security context β but only if the file exists. If the file does not exist, no file type matching will occur. periodt. that's the rule π
π OPTIONS π
-mtype β force the file type for the lookup. the valid types arefile,dir,pipe,chr_file,blk_file,lnk_file,sock_file. pick your fighter π₯-nβ do not display path. shy mode π-Nβ do not use translations. keep it raw, keep it real π§-ffile_context_file β use an alternate file_context file. (yep, the synopsis spells itfile_contexts_file, the option list spells itfile_context_fileβ iconic of it honestly π)-pprefix β use prefix to speed up translations. zoom zoom ποΈ-Ppolicy_root_path β use an alternate policy root path.-Vβ verify that the file context on disk matches the defaults. the "am i actually slaying or am i just claiming to" flag π₯
β EXAMPLE β
Show the default label of sock_file cups.sock:
# matchpathcon -m sock_file /var/run/cups/cups.sock
Verify that the /var/www/html directory is labeled correctly β and just so we're clear, the content of the folder is not checked, only the directory itself π:
# matchpathcon -V /var/www/html
π AUTHOR π
This manual page was written by Dan Walsh <dwalsh@redhat.com>. legend behaviour, honestly πΈ
π SEE ALSO π
okay so that's the whole page!! go forth and label things correctly, bestie πβ¨
this one came to you from dwalsh@redhat.com, dated 21 April 2005, in the matchpathcon(8) era of the world π¦ mwah, bye!! π
π¦ where this page comes from
- alpine 3.24: libselinux-doc 3.10-r1 Β· Public-Domain
- centos-stream 10: libselinux-utils 3.11-3.el10 Β· LicenseRef-Fedora-Public-Domain
- centos-stream 9: libselinux-utils 3.6-5.el9 Β· Public Domain
- debian trixie: selinux-utils 3.8.1-1 Β· LicenseRef-public-domain
- fedora 43: libselinux-utils 3.9-5.fc43 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-utils 3.10-1.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-utils 3.11-2.fc44 Β· LicenseRef-Fedora-Public-Domain
- nixos 26.05: libselinux 3.10
- nixpkgs unstable: libselinux 3.11
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- ubuntu questing: selinux-utils 3.8.1-1build1
- ubuntu resolute: selinux-utils 3.9-4build1 Β· LicenseRef-public-domain
- ubuntu stonking: selinux-utils 3.11-2.1 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms