~$ sudo apt-get

Author Archive

Force SSL with mod_rewrite

by on Oct.15, 2009, under Apache, Linux

Create a .htaccess within the document root with the following.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

You must ensure AllowOverride is set to All within the apache configuration or it will not read the .htaccess.

Leave a Comment more...

Parse single table from mysqldump

by on Oct.08, 2009, under Linux

If you wish to pull a single table from a large mysqldump, the following commands will accomplish this.

# grep -n "CREATE TABLE" databasedump.sql

If the table you want starts on line 100, and the proceeding table is on line 150, run the following commands to parse the dump.

# head -n 142 databasedump.sql > parsed.sql

# tail -n 100 parsed.sql > table.sql

Do not use the exact line number returned from grep as you will have the create table statement from the next table.

Leave a Comment more...

Remove Plesk Lockout

by on Jul.28, 2009, under Plesk

Plesk will populate psa.lockout in mySQL in the event of the lockout. Either of the following will clear the lockout.

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e 'TRUNCATE lockout'
mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e 'DELETE FROM lockout'

Check /usr/local/psa/admin/logs/httpsd_access_log for brute force attempts.

Leave a Comment more...

Display SAN information with powermt

by on May.28, 2009, under Linux, Server

powermt display dev=all

This will display all information relevant to connected SAN devices.

# powermt
powermt [class=all|clariion|ess|hitachi|hphsx|hpxp|invista|symm]

powermt check [force] [hba=|all] [dev=|all]
powermt check_registration
powermt config
powermt disable hba=
powermt display nonvirtual {dev=|all} [every=<#seconds>] [class=invista|all]
powermt display [ports] [dev=|all] [every=<#seconds>]
powermt display hba_mode
powermt display latency [dev=|all] [every=<#seconds>]
powermt display options
powermt display paths [every=<#seconds>] [width=<#col>]
powermt display port_mode
powermt display unmanaged
powermt enable hba=
powermt load [file=]
powermt manage {dev= | class=}
powermt release
powermt remove [force] hba=|all | dev=|all
powermt restore [hba=|all] [dev=|all]
powermt save [file=]
powermt set mode=active|standby [hba=|all] [dev=|all]
powermt set path_latency_monitor=on|off
powermt set path_latency_threshold=
powermt set periodic_autorestore=on|off
powermt set policy={ad|bf|co|lb|li|nr|re|rr|so} [dev=|all]
powermt set port_disable={true|false} dev=
powermt set priority= [dev=|all]
powermt unmanage {dev= | class=}
powermt update lun_names
powermt version

Leave a Comment more...

Delete Sendmail Queue

by on May.13, 2009, under Linux, Mail, Sendmail

When rm -rf /var/spool/mqueue gives you ‘bash: /bin/rm: Argument list too long’, you can use the following.

find /var/spool/mqueue/. -type f -exec rm -f {} ;
Leave a Comment more...

Total memory usage by Apache processes

by on May.13, 2009, under Apache, Linux, Server

ps ax | grep httpd | awk '{ print $1 }' | xargs pmap -x | awk '{ SUM += $2 } END { print SUM }'
Leave a Comment more...

Fixing Urchin – Urchin: Unable to open database for writing since it has been archived

by on May.04, 2009, under Linux

mkdir tmp; for i in `find ./*archive.zip`; do unzip $i; mv $i tmp; done; chown urchin:urchin *

Must be in the report directory for the profile.

/usr/local/urchin/data/reports/[profile name]

Leave a Comment more...

Backup mysql database to remote database

by on Apr.09, 2009, under Linux

mysqldump --verbose --opt -u'username' -p'password' 'database' --tables 'table' | grep -v SQL_NOTES | mysql --host='hostname or IP' -u'username' -p'password' 'database'

Input all required information and remove the single quotations.

This specific command does a mySQL dump for a specific table within a database and pipes this output to a remote mySQL database connection.

The ‘grep -v’ was added to parse out SQL_NOTES as sending machine was 4.1.22 and receiver was 5.0.0 and did not like the syntax.

Leave a Comment more...

Display successful SSH brute force attempts from secure logs

by on Apr.07, 2009, under Linux

for i in `grep "Failed password for invalid user" /var/log/secure | awk '{ print $13 }' | sort | uniq`; do grep $i /var/log/secure | grep "Accepted"; done

This is a work in progress.

Parses IPs from failed SSH attempts then runs it against the logs again for successful attempts.

Leave a Comment more...

Configure additional port for Qmail/ProFTPd

by on Apr.07, 2009, under Linux

Add an entry in /etc/services for the specific port number you would like to listen on. Preferably copy the lines for 25/SMTP.

smtp 25/tcp mail
smtp 25/udp mail
smtp-alt 225/tcp mail
smtp-alt 225/udp mail

In the /etc/xinetd.d/ directory, copy smtp_psa to smtp2_psa. Open smtp2_psa and change the first line.

service smtp
service smtp-alt

Restart xinetd after complete and verify service is listening on the correct port.

– This can be applied to other services such as ProFTPd.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...