Rsync Commands

rsync -avnh source target

#Use rsync to sync to remote system as user over remote shell compressing transfer and without crossing filesystem boundaries
rsync -avzx -e ssh /var/www/ user@remote_host:/var/www/

#Use rsync to sync to remote system as user over remote shell skipping files that are newer on the remote server
rsync -avzxu -e ssh /var/www/ user@remote_host:/var/www/

Pushing files with rsync
rsync -a ~/dir1 user@remote_host:/var/www/

Pulling files with rsync
rsync -a user@remote_host:/home/user/dir1 /var/www

#To see which files need to be synced:
rsync -n –dry-run -av /var/www/vhosts/domain.com/. remote_host:/var/www/vhosts/domain.com/.

 

-a = archive which basically means use recursion and preserve symbolic links, devices, attributes, permissions, ownerships, etc.(not hard links)
-v = verbose
-z = compression
-n = dry run
-h = human readable
-P = progress bar for the transfers and allows you to resume interrupted transfers
-u = skip files that are newer on the receiver
–delete option allows deletions from destination if not in source
–dry-run
–exclude=pattern_to_exclude excludes items matching the pattern (Good practice to run with –dry-run first to be sure)

* By default, rsync does not delete anything from the destination directory.
 

Posted in Linux | Comments Off on Rsync Commands

Using grub

It is relatively easy to boot GNU/Linux from GRUB, because it somewhat resembles to boot a Multiboot-compliant OS.

Set GRUB’s root device to the same drive as GNU/Linux’s. The command search –set=root –file /vmlinuz or similar may help you (see search).
Load the kernel using the command linux (see linux):

grub> linux /vmlinuz root=/dev/sda1

If you need to specify some kernel parameters, just append them to the command. For example, to set acpi to ‘off’, do this:

grub> linux /vmlinuz root=/dev/sda1 acpi=off

See the documentation in the Linux source tree for complete information on the available options.

With linux GRUB uses 32-bit protocol. Some BIOS services like APM or EDD aren’t available with this protocol. In this case you need to use linux16

grub> linux16 /vmlinuz root=/dev/sda1 acpi=off

If you use an initrd, execute the command initrd (see initrd) after linux:

grub> initrd /initrd

If you used linux16 you need to use initrd16:

grub> initrd16 /initrd

Finally, run the command boot (see boot).

**Totally stolen from http://www.gnu.org/software/grub/manual/grub.html#Loading-an-operating-system-directly

Posted in Linux | Comments Off on Using grub

Stuff to review

http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html

rpm -V output:
S file Size differs
M Mode differs (includes permissions and file type)
5 MD5 sum differs
D Device major/minor number mismatch
L readLink(2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs

Posted in Linux | Comments Off on Stuff to review

Best Practices for WordPress sites

Best practice from my experience when it comes to WordPress and permissions is:
• Owner: SFTP/site user
• Group: apache
• Directory Permissions: 02775 (drwxrwsr-x)
• File Permissions: 0664 (-rw-rw-r–)
• Directory ACLs: default:user:siteUser:rwx, default:user:apache:rwx, user:siteUser:rwx, user:apache:rwx
• File ACLs: user:siteUser:rw-, user:apache:rw-

The following lines added to wp-config.php help as well:
define(‘FS_METHOD’,’direct’);
will allow you to update any part of the WordPress installation from within the control panel without having to log in manually
define(‘FS_CHMOD_DIR’,02775);
define(‘FS_CHMOD_FILE’,0664);

The reason for the ACLs are that new files are created with a umask of 0022 on CentOS5 when utilizing SFTP (SSH FTP) so Apache would slowly lose write capability on these files as you created new ones via SFTP otherwise. This is also the optimum configuration for allowing WordPress to update itself via the control panel. If that is unnecessary or undesired, you can remove the group write and ACL write fields for Apache on files and directories that should not be able to be modified by the PHP code.

The allow_url_fopen option does not need to be set to enabled for fopen()s on files, by the way. Only if you need to do something along the lines of fopen(http://…) to pull in a resource from another site (and this is strongly deprecated as it builds a dependency on that other resource that can cause timeouts in rendering your page if the site that resource exists on goes down or such.)

Posted in Linux | Comments Off on Best Practices for WordPress sites

Verifying port 443

openssl s_client -connect localhost:443

CONNECTED(00000003)
4504:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:588:

Posted in Linux, OPENSSL and TLS | Comments Off on Verifying port 443

w3 total cache

Disabling w3 total cache:

edit the wp-config.php file

define (WP_CACHE’, true);
from true to false (i.e. define (‘WP_CACHE’,false);

Command line method of clearing w3 total cache:

delete files form the wp-contentw3tc/pgcache/ directory

http://www.frandimore.com/blog-setup/how-to-delete-w3-total-cache-properly/

Posted in Linux | Comments Off on w3 total cache

Add openstack.compute

git clone git://github.com/jacobian/openstack.compute
cd openstack.compute 
python setup.py build 

sudo python

Posted in Linux | Comments Off on Add openstack.compute

Find largest apache process

ps -ylC apache2 | awk ‘{s+=$8} END {print s/1024/(NR – 1)}’
ps -ylC httpd | awk ‘{s+=$8} END {print s/1024/(NR – 1)}’

To calculate mysql usage:

Calculate MySQL Memory Usage – Quick Stored Procedure

Posted in Linux | Comments Off on Find largest apache process

check for mod_pagespeed

curl -D- http://example.com | grep X-Mod-Pagespeed

shows all zeros if it isn’t installed

if it is installed,

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 966 0 966 0 0 723 0 –:–:– 0:00:01 –:–:– 1618

or alternately curl -D- http://example.com |less

should show something like:

Date: Fri, 07 Sep 2012 21:51:06 GMT
Server: Apache/2.2.3 (CentOS)

X-Mod-Pagespeed: 0.10.22.4-1633

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 966 0 966 0 0 723 0 –:–:– 0:00:01 –:–:– 1618

Posted in Linux | Comments Off on check for mod_pagespeed

subsys is locked

If you get this error when doing service {servicename} status:

{servicename} dead but subsys is locked

You need to remove the {servicename} lock file

rm /var/lock/subsys/{servicename}

Posted in Linux | Comments Off on subsys is locked