Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

selinux chcon

Posted on 2014-09-15
4
Medium Priority
?
234 Views
Last Modified: 2014-09-26
I am looking for a man page, --help or an info page on a redhat 5 system that gives me a clear example of how to use the chcon command.  I forget the syntax and at work I am on a network that does not permit us checking on the web.  

redhat 5+
0
Comment
Question by:TIMFOX123
4 Comments
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40323627
http://www.linuxcommand.org/man_pages/chcon1.html

CHCON(1)                         User Commands                        CHCON(1)




NAME

       chcon - change security context


SYNOPSIS

       chcon [OPTION]... CONTEXT FILE...
       chcon [OPTION]... --reference=RFILE FILE...


DESCRIPTION

       Change the security context of each FILE to CONTEXT.

       -c, --changes
              like verbose but report only when a change is made

       -h, --no-dereference
              affect  symbolic links instead of any referenced file (available
              only on systems with lchown system call)

       -f, --silent, --quiet
              suppress most error messages

       -l, --range
              set range RANGE in the target security context

       --reference=RFILE
              use RFILE’s context instead of using a CONTEXT value

       -R, --recursive
              change files and directories recursively

       -r, --role
              set role ROLE in the target security context

       -t, --type
              set type TYPE in the target security context

       -u, --user
              set user USER in the target security context

       -v, --verbose
              output a diagnostic for every file processed

       --help display this help and exit

       --version
              output version information and exit

Open in new window

0
 
LVL 13

Accepted Solution

by:
Sandy earned 2000 total points
ID: 40324564
#chcon is used to change the context of any file..

# ls -lZ /var/log/messages

#ls -lZ /var/www/html/index.html

above both files have there different contexts.. but to provide reference and change them we use #chcon

#chcon --reference /var/log/messages /var/www/html/index.html

#ls -lZ /var/www/html/index.html

Now index.html also has the same context as /var/log/messages has because we changed it using above command to restore we use .. #restorecon -R /var/www/html/index.html

TY/SA
0
 

Author Closing Comment

by:TIMFOX123
ID: 40346081
great job and sorry for me not getting back
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question