Archive for the ‘Linux’ Category

Linux: IPTables

Sunday, September 27th, 2009

Enable HTTPS

iptables -I INPUT 1 -s 0/0 -i eth0 -d 0/0  -p TCP --dport 443 -j ACCEPT
  • -I INPUT 1: Insert at position #1 (do
  • -s 0/0: Any source IPs
  • -d 0/0: Any destination IPs
  • -p TCP: TCP protocol
  • –dport 443: Port number (for ssl, default is 443)

Related Links

Apache: Install SSL on Virtual Host

Sunday, September 27th, 2009

Here is the minimum configuration to enable SSL

Load the module and configure the certificate

LoadModule ssl_module modules/mod_ssl.so
Listen 443
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM
SSLCertificateFile /path/to/domain-certificate.crt
SSLCertificateKeyFile /path/to/domain-key.key
SSLCertificateChainFile /path/to/bundle-certificate.crt
SSLCACertificateFile /path/to/bundle-certificate.crt

….

NameVirtualHost *:443
<VirtualHost *:443>
DocumentRoot /path/to/html/
ServerName www.mysecuredomain.com
SSLEngine on
</VirtualHost>

Pre-requisites:

  1. Disable your /etc/httpd/conf.d/ssl.conf by renaming it to ssl.conf.disabled (otherwise, Apache will take the properties from this file, and it can get quite confusing).
  2. Open your firewall for https protocol
  3. Get a certificate (Godaddy have the cheapest one, especially for wildcard ones)

Related links

Linux: Tar cheat sheets

Monday, September 7th, 2009

Best short article on this subject: How to create and extract zip, tar, tar.gz and tar.bz2 files in Linux

Tar and gzip the folder panda/ in the panda.tar.gz

tar -cvzf panda.tar.gz panda/

Untar

tar -xvzf panda.tar.gz

or (to change the base folder name)

tar -xvzf latest.tar.gz -C ./(folder name)

Source: lowfatlinux.com

MySQL: Shell script to backup mysql database

Monday, September 7th, 2009
tdy=`date +%Y-%m-%d-%H-%M`
mkdir /var/backup/db_name/$tdy
mysqldump -u db_user -p --opt db_name > /var/backup/db_name/$tdy/db_name-$tdy.sql

Apache: SSL Certificate generate CSR

Friday, August 7th, 2009

CSR-Generation Instructions

To generate a triple-DES encrypted key pair and a Certificate Signing Request (CSR):

Enter the following commands:

  1. cd /usr/bin/ (/your path to openssl/)
    Enter a passphrase when prompted to.
  2. openssl genrsa -des3 -out <name of your certificate>.key 1024
  3. openssl req -new -key <name of your certificate>.key -out <name of your certificate>.csr

If you are requesting a Wildcard certificate, please add an asterisk (*) on the left side of the Common Name (e.g., “*.domainnamegoes.com” or “www*.domainnamegoeshere.com”). This will secure all subdomains of the Common Name.

(source: Godaddy’s help)

BTW, Godaddy has the cheapest certificates you can find (with great support).

Git: Installing Git on Centos 5

Wednesday, April 15th, 2009

Make sure you have the EPEL Repository installed in your yum repository, do the following:

> rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Install Git with

> yum install git

You should get something like:

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 git                     x86_64     1.5.5.6-2.el5    epel              3.5 M
Installing for dependencies:
 perl-Error              noarch     1:0.17010-1.el5  epel               26 k
 perl-Git                x86_64     1.5.5.6-2.el5    epel               16 k

Transaction Summary
=============================================================================
Install      3 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 3.5 M
Is this ok [y/N]: y

Make sure the git package comes from EPEL and not RPMForge. If it comes from RPMForge, then, install yum-priorities:

> yum install priorities

Make sure that yum-priorities is enabled by editing the /etc/yum/pluginconf.d/priorities.conf file, and ensuring that it contains the following lines:

[main]
enabled=1

Add a priority=3 line in the /etc/yum.repos.d/rpmforge.repo
Add a priority=1 lines in each of the three repo sections in the /etc/yum.repos.d/elrepo.repo

Then, do the “yum install git”

Linux: Installing OpenOffice On CentOS5

Thursday, April 9th, 2009

Steps:

  1. Download OpenOffice (Linux RPM)
  2. Copy the .gz file to /tmp/
  3. Unpack: tar -zxvf OOo_3.0.0_LinuxX86-64_install_en-US.tar.gz
  4. Check if you have already an OpenOffice installed
    > rpm -qa | grep office
    openoffice.org-writer-2.0.4-5.4.17.1
    openoffice.org-core-2.0.4-5.4.17.1
    openoffice.org-calc-2.0.4-5.4.17.1
    openoffice.org-draw-2.0.4-5.4.17.1
    openoffice.org-impress-2.0.4-5.4.17.1
    openoffice.org-math-2.0.4-5.4.17.1
    openoffice.org-xsltfilter-2.0.4-5.4.17.1
    openoffice.org-graphicfilter-2.0.4-5.4.17.1
  5. If yes, uninstall all rpms with:
    rpm -e openoffice.org-writer-2.0.4-5.4.17.1
    rpm -e openoffice.org-calc-2.0.4-5.4.17.1
    rpm -e openoffice.org-draw-2.0.4-5.4.17.1
    rpm -e openoffice.org-impress-2.0.4-5.4.17.1
    rpm -e openoffice.org-math-2.0.4-5.4.17.1
    rpm -e openoffice.org-xsltfilter-2.0.4-5.4.17.1
    rpm -e openoffice.org-graphicfilter-2.0.4-5.4.17.1
    rpm -e openoffice.org-core-2.0.4-5.4.17.1

    Note: remove the ..-core.. last

  6. go to the RPMS/
    cd /tmp/OOO300_m9_native_packed-1_en-US.9358/RPMS/
  7. Install all RPMs (in the /opt/ directory
    > rpm -ivh *.rpm

    or in a specific directory

    > rpm -ivh –prefix /mycoolerdir/ *.rpm
  8. You should see something like: (probably in bigger font)
    Preparing… ########################################### [100%]
    1:openoffice.org-ure ########################################### [ 2%]
    2:ooobasis3.0-core01 ########################################### [ 4%]
    3:ooobasis3.0-en-US ########################################### [ 6%]
    4:ooobasis3.0-core02 ########################################### [ 9%]
    5:ooobasis3.0-core03 ########################################### [ 11%]
    6:ooobasis3.0-core04 ########################################### [ 13%]
    7:ooobasis3.0-core05 ########################################### [ 15%]
    8:ooobasis3.0-core06 ########################################### [ 17%]
    9:ooobasis3.0-core07 ########################################### [ 19%]
    10:ooobasis3.0-calc ########################################### [ 21%]
    11:ooobasis3.0-draw ########################################### [ 23%]
    12:ooobasis3.0-impress ########################################### [ 26%]
    13:ooobasis3.0-math ########################################### [ 28%]
    14:ooobasis3.0-writer ########################################### [ 30%]
    15:ooobasis3.0-en-US-base ########################################### [ 32%]
    16:ooobasis3.0-en-US-binfi########################################### [ 34%]
    17:ooobasis3.0-en-US-calc ########################################### [ 36%]
    18:ooobasis3.0-en-US-draw ########################################### [ 38%]
    19:ooobasis3.0-en-US-help ########################################### [ 40%]
    20:ooobasis3.0-en-US-impre########################################### [ 43%]
    21:ooobasis3.0-en-US-math ########################################### [ 45%]
    22:ooobasis3.0-en-US-res ########################################### [ 47%]
    23:ooobasis3.0-en-US-write########################################### [ 49%]
    24:ooobasis3.0-base ########################################### [ 51%]
    ….
  9. The programs are under [your_office_location]/openoffice.org3/program

See Also:

Apache: htpasswd Create User for Apache Auth File

Sunday, February 8th, 2009

First user creation (create file and first user):

htpasswd -cm /path/to/auth-conf yourusername

Subsequent user creation

htpasswd -m /path/to/auth-conf yourusername

Linux: RPM query installed packages

Thursday, December 25th, 2008

Query all installed packages:

rpm -qa

Query one package:

rpm -q subversion

Linux: Using Yum

Thursday, December 25th, 2008

List (all subversion related packages)

$ yum list | grep subversion

Search

$ yum search subversion

Install

$ yum install subversion

Info about a package

$ yum info subversion

Yum repos directory

$ cd /etc/yum.repost.d