هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
chcon -t TYPE FILE writes a new label on the file but does not add a rule to the policy. The next restorecon or full relabel sets the old label again. For permanent labels use semanage fcontext + restorecon.
طريقة الكتابة
chcon [OPTION]... CONTEXT FILE...
chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
chcon [OPTION]... --reference=RFILE FILE...الخيارات 13
الأكثر استخدامًا
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 10
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Test a type quickly
chcon -t httpd_sys_content_t /srv/test/index.htmlWorks until the next restorecon.
2Copy the label of another file
chcon --reference=/var/www/html /srv/webSame context as /var/www/html.
3A whole folder
chcon -R -t httpd_sys_content_t /srv/webStill temporary.
4Watch it disappear
restorecon -v /srv/test/index.htmlThe label goes back to the policy rule.
5The permanent way
semanage fcontext -a -t httpd_sys_content_t "/srv/web(/.*)?"; restorecon -Rv /srv/webUse this on the exam.
6Break a label for a lab
chcon -t user_home_t /var/www/html/index.htmlPractice finding AVC denials.
7Show the full context
ls -Z /srv/webCheck the result.
8Set the full context at once
chcon system_u:object_r:httpd_sys_content_t:s0 /srv/web/index.htmlAll four parts.
9Container volume label (alternative)
podman run -v /srv/data:/data:Z …:Z lets podman set the right label instead of chcon.
10Find files with temporary labels
restorecon -Rvn /srvShows labels that differ from the policy (chcon changes too).
لا يوجد شيء يطابق هذا الفلتر.
رموز الخروج
0 :: Done. 1 :: Error.