what is chcon command know whith its examples

  • About chcon : change file SELinux security context
  • Comes From : coreutils-8.4-9.el6.i686

Examples:

drwxrwxrwx. mike_u:object_r:admin_home_t:s0 file.txt

U : R : T : L

            User : Role : Type: Level

1. To change a type of a web directory

$ chcon -R -t httpd_sys_content_t /web/

2. To change a security context by using the reference file

$ chcon –reference=/tmp/file2 /tmp/file2

3. To set security context on files recursively

$ chcon -R httpd_sys_content_t /web/

4. To change files user security context

$ chcon -u mike_u /file

5. To change files role security context

$ chcon -u object_r /file

6. To change files type security context

$ chcon -u admin_home_t /file

7. To change files level security context

$ chcon -u s0 /file

One thought on “what is chcon command know whith its examples

  1. **** some corrections of ur commands
    chcon -u mike_u /file | To change files user security context
    chcon -r object_r /file | To change files role security context
    chcon -t admin_home_t /file | To change files type security context
    chcon -l s0 /file | To change files level security context
    chcon -R -t httpd_sys_content_t /web/ | change a type of a web directory
    chcon –reference=/tmp/file2 /tmp/file2 | change a security context using reference file
    chcon -R httpd_sys_content_t /web/ | To set security context on files recursively

Leave a Reply

Your email address will not be published. Required fields are marked *