Archive for the ‘Linux Administration’ Category.

Plesk: command to reconfigure one site

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=domain.com

OpenSSL: How To Create Self-Signed Certificate

$ openssl genrsa -out ca.key 1024
$ openssl req -new -key ca.key -out ca.csr
$ openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

For the explanation, here’s the source: OpenSSL: How To Create Self-Signed Certificate

Extract particular table from a mysqldump file

$ awksqldump dbname.dump.sql tblname


#!/bin/bash
### check parameter
E_NO_ARGS=65
if [ $# -eq 2 ]
then
# Outputs string of specified table only
awk "/Table structure for table .$2./,/UNLOCK TABLES/{print}" $1 > $1.EXTRACTED.sql
elif [ $# -eq 3 ]
then
# Outputs string starting from table1 and ends on beginning of table2
awk "/Table structure for table .$2./,/Table structure for table .$3./{print}" $1 > $1.EXTRACTED.sql
else
echo "Awk Sql Dump
Usage: awksqldump dumpfilename tablename1 [tablename2]
"
exit $E_NO_ARGS
fi

Transfer Horde emails to a new server

rsync

rsync -avz -e ssh root@i095.indigo.fastwebserver.de:/var/www/vhosts/philippinedev.com/httpdocs/ /srv/www/vhosts/philippinedev.com/httpdocs/

How to use .htaccess to change default index page

DirectoryIndex alternative-default-home-page.php

How to create reverse traceroute page on your website using PHP

<?php
$result = exec('traceroute ' . $_SERVER["REMOTE_ADDR"], $lines);
echo '<h1>Your IP is ' . $_SERVER["REMOTE_ADDR"] . '</h1>';
echo '<pre>';
foreach ($lines as $n => $line) {
	if ($n) echo '<br />';
	echo $line;
}
echo '</pre>';
echo '<p>-end-</p>';

Here’s how the resulting page looks like: reverse-traceroute.php

How to redirect pages to a new domain

RedirectMatch 301 (.*)$ http://www.newdomainhere.com$1

Save this into .htaccess and upload on the root directory on your old domain.

How to mount an .iso image file?

$ sudo mount -o loop /path/to/feisty-desktop-i386.iso /tmp/ubuntu-livecd

How to Find and Replace a String on the command line?

This command will replace all instances of ‘replaceme’ with ‘newstring’ in files ‘*.php’ on /home/mysite/httpdocs.

find /home/mysite/httpdocs -name '*.php' | xargs replace 'replaceme' 'newstring' --