Unable to connect to Xen Console
by sudo on Mar.29, 2011, under Linux
If you encounter the following error when trying to connect to an instance with Xen, xenconsoled is not running.
xenconsole: Could not read tty from store: No such file or directory
To rectify, start /usr/sbin/xenconsoled.
Display configuration options for an RPM
by sudo on Mar.31, 2010, under Linux
rpm -q --queryformat="%{NAME}: %{OPTFLAGS}\n" packagename
Fast large file finder
by sudo on Jan.20, 2010, under Linux
The following will display all files over 100MB in size on the server except for those in /proc.
find / -path /proc -prune -o -type f -size +102400k -printf "%s %h/%f\n" | sort -rn -k1 | head -n 50 | awk '{ print $1/1048576 "MB" " " $2}'
Install PHP Modules via PECL
by sudo on Jan.13, 2010, under Apache, PHP
First, mount the /tmp partition with exec permissions.
mount -o remount,exec /tmp
To install a package via pecl, run the following.
pecl install ssh2
(If the package is in a state other than stable, append the state after the package name ‘pecl install ssh2-beta’)
Last few lines of the module install will list the location of the library, usually /usr/lib/php/modules. Create a ini file with the module name within /etc/php.d/ with the extension directive.
# cat /etc/php.d/gd.ini
; Enable gd extension module
extension=gd.so
At this point, run the mount command to reestablish noexec for the /tmp partition.
mount -o remount,noexec /tmp
Gracefully restart apache and you are done.
Reset mySQL root password
by sudo on Jan.12, 2010, under mySQL
First, insert the init-file directive into the mySQL configuration under the [mysqld] section.
init-file=/var/lib/mysql/mysql-init
Create /var/lib/mysql/mysql-init with the following line. Replace ‘Changeme’ with a password of your choosing.
SET PASSWORD FOR ‘root’@'localhost’=password(‘Changeme’);
Restart the mySQL service and login as root with the password used above. Remember to remove the init-file directive and the init file you created once complete.
Urchin : Unable to retrieve local file listing / Permission denied
by sudo on Dec.10, 2009, under Apache, Linux
A common issue with occurs when apache is updated. Red Hat Enterprise Linux will revert /var/log/httpd to 0755 with root:root as ownership resulting in the following error.
WARNING: (****-****-****) Unable to retrieve local file listing
DETAIL: /var/log/httpd/access_log : Permission denied
A temporary fix until the next apache update, which are few and far between, is to ‘chmod 0755 /var/log/httpd’. Then ensure the current access logs are readable to the urchin user, 0644 should work. A permanent work around is to specify a log directory that will not be touched by the httpd rpm and give urchin sufficient permissions to access it.
Remove default domain from IP in Plesk
by sudo on Dec.01, 2009, under Plesk
Of all the things Plesk does well, this which would seem like common sense to include within the interface, cannot be done. To rectify this issue, you must update the default_domain field within psa.IP_Addresses.
mysql -uadmin -p`cat etc/psa/.psa.shadow` -Dpsa -e "UPDATE IP_Addresses SET default_domain_id = 0 WHERE ip_address = 'IPGOESHERE';"
Remove the WHERE statement if you wish to do a blanket default domain removal.
mysql -uadmin -p`cat etc/psa/.psa.shadow` -Dpsa -e "UPDATE IP_Addresses SET default_domain_id = 0;"
Display Physical Memory in Server
by sudo on Nov.13, 2009, under Linux, Server
The following is useful in the event that the wrong version (32 vs 64bit) of linux or non-SMP/PAE kernel is installed and you’d like to verify how much RAM physically is in the server.
dmidecode | awk '/\tSize: [0-9]+ MB/ {SUM=SUM+$2} END {print SUM}'
Force SSL with mod_rewrite
by sudo 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.
Parse single table from mysqldump
by sudo 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.