Solved

selinux chcon

Posted on 2014-09-15
4
221 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 37

Expert Comment

by:Gerwin Jansen
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 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now