Famous SELinux Contexts

1. httpd SELinux context

                                        chcon -v –type=httpd_sys_content_t /path/to/dir

2.httpd SELinux context

                   chcon -Rv –type=httpd_sys_content_t /path/to/dir

3. Restore old/default context

                   restorecon -Rv -n /var/www/html


                    ;  -n switch to prevent any relabelling occurring.
4. Changing default port for services permitted SELinux

                                     #  semanage port -l
                    # semanage port -a -t http_port_t -p tcp 81
5. For Nagios

chcon -R -t httpd_sys_content_t /usr/local/nagios

        

  1st command to see what are the supported services. 2nd one changing default port for http service.



Note: Give me time to write them with proper explanation. 

More: http://wiki.centos.org/TipsAndTricks/SelinuxBooleans

Advertisements

Process Management

Hello , My new blogpost is about Process Management and I have gone all concepts of Process Management. I have written this document with help of .Doc and it consists of images. So its hard to maintain the format in blogger too. I am placing the download link , Please use that link to download. I hope it helps you. To Download my post Please click here

Sending mail from CentOS

h1 {color:blue;} p {color:orange;} code {text-align: center;}

Actually sending mail from a CentOS server/Desktop install is pretty easy. You can do that in many ways but I like this way because it is simpler.

Before sending the mail, the content of your mail if you store at some place would be better. assume like I have stored my message /tmp/body file.

Then I will sent my message as

mail -s "This is subject of message" raja@raja.com < /tmp/message

thats it. check for your mail in inbox/spam/junk box.

Running Multiple Instances of MySQL in CentOS/Fedora/RedHat Linux


              Running Multiple Instances of MySQL in CentOS/Fedora/RedHat Linux

                       1. Make sure that you have installed mysql-server in your Linux , If not install it with
yum install –y mysql-server
              2After installing MySQL-Server , Open your terminal and paste as 
  
                        mkdir /var/lib/mysql2
chown -R mysql.mysql /var/lib/mysql2
mkdir /var/log/mysql2         
chown -R mysql.mysql /var/log/mysql2
Above code stands for creating two directories for MySQL 2nd instance , There /var/lib/mysql2  for data directory and /var/log/mysql2 is for log directory. After that changing the owner as mysql for both.
              3. Make a dump of mycnf configuration file with 
 
 cp -R /etc/my.cnf /etc/my2.cnf

                    Then Open it with

nano /etc/my2.cnf  (or ) vim /etc/my2.cnf
                     Make the changes as mentioned in the below file.
                                     # change/add the following options
                                    port = 3307     #different port
                                    datadir = /var/lib/mysql2       #diff data dir
                                    socket =  /var/lib/mysql2/mysql2.sock           # diff socket path
                                    # add [mysql_safe]
                                    log-error = /var/log/mysql2/mysql.log # diff log
                                    pid-file = /var/lib/mysql2/mysql2.pid            #diff PI
 Then save & close it.
                            4.  Now in the terminal paste these lines after one , with success of each command
mysql_install_db –user=mysql –datadir=/var/lib/mysql2/
mysqld_safe –defaults-file=/etc/my2.cnf &
mysqladmin -S  /var/lib/mysql2/mysql2.sock -u root password ‘newpass’
mysql -S  /var/lib/mysql2/mysql2.sock -u root -p
5                 5. That will start your MySQL 2ndinstance and you can check it with 
netstat -nptelu | grep my
netstat -l | grep my
6                6. If you want to shutdown that instance then you can do it with
mysqladmin -S  /var/lib/mysql2/mysql2.sock -u root -p shutdown