Linux stuff

From Dw0rm's Wiki

Table of contents

Linux shell settings

set autolist (TAB autocomplete)
set autocorrect

Static table lookup for host names

/etc/hosts - contains mapping of IP addresses to host names and aliases - one mapping per line. e.g.:
127.0.0.1 localhost.localdomain dummyhostname localhost
192.168.1.3 www.paraglider.co.nz paraglider
- this allows for internal network name-IP resolution - request does not need to go to router to resolve.
- requires etc/hosts file on every machine on network where this is needed.

Multiple webservers behind a firewall How-To

how to setup two webserver behind a firewall using Virtual Hosts and mod_proxy with one IP.

   1. make sure that DNS is setup correctly: www IN A 1.1.1.1 and www2 IN A 1.1.1.1
      1.1.1.1 should be your REAL public IP number.
   2. on my local network I have two computers, foo and bar, foo will handle the www requests and bar will 
      handle www2 requests. foo has a private ip of 192.168.253.2 and bar has an IP of 192.168.253.19
   3. forward port 80 on the firewall (which has the public ip number 1.1.1.1) to 192.168.253.2 port 80
   4. on foo's httpd.conf, BindAddress should be set to 192.168.253.2 and LoadModule vhost_alias_module 
      and LoadModule proxy_module should be the modules loaded. ServerName should be set as www.domain.com
   5. Now we set NameVirtualHost to 192.168.253.2 and setup a Virtual Host entry like this:

<VirtualHost 192.168.253.2>
DocumentRoot    /location/www
ServerAdmin	root@domain.com
ServerName      www.domain.com
ErrorLog        /location/log/apache/www.domain.com-error.log
TransferLog     /location/log/apache/www.domain.com-access.log
</VirtualHost>

   6. Next, is a virtual host entry for www2.domain.com

<VirtualHost 192.168.253.2>
ServerAdmin admin@domain.com
ServerName  www2.domain.com
ErrorLog  /location/log/apache/www2.domain.com-error.log
TransferLog /location/log/apache/www2.domain.com-access.log
ProxyRequests On
ProxyRemote * http://192.168.253.19
<Directory proxy:http://192.168.253.19>
Order Allow,Deny
Allow from all
</Directory>
  ProxyPass / http://192.168.253.19/
  ProxyPassReverse / http://192.168.253.19/
  ProxyVia On
</VirtualHost>

   Note: If there are multiple websites being run off the same proxied host then the following line is 
   also required (this option will pass the Host: line from the incoming request to the proxied host, 
   instead of the hostname specified in the proxypass line.):
   
   ProxyPreserveHost On
       
   7. The second VirtualHost entry proxies out any www2.domain.com requests to 192.168.253.19 . 
      The only change in bar's httpd.conf needed is setting the ServerName entry to www2.domain.com

Ddclient

ddclient installation notes: http://linux.cudeso.be/linuxdoc/ddclient.php

scp usage

scp <filename> <user>@<hostname>:<targetdir on host> e.g.:
scp database.dmp.Z tomg@romario:/tmp
  • The lukasr account must be setup on host romario and you must be able to provide password when asked.

windows/dos to unix file conversion

  • Windows saves text files with carriage return + line feed
  • Unix/Linux saves text files with line feed only.
To get rid of the carriage return (^M) open the file in gvim and
%s/[ctrl-v][ctrl-m]/[ctrl-v][Enter]/g
Should also check file format for the file to make sure it is "unix" : 'set ff' to check what it is and 'set ff=unix' to change.

linux rescue

  • When rescue mode comes up, linux will tell us which dir is corrupted
  • Running fsck /dir has for me fixed the issue.

Linux bootloaders - Lilo vs. Grub

Boot loader showdown: Getting to know LILO and GRUB (http://www-128.ibm.com/developerworks/library/l-bootload.html?ca=dgr-lnxw01LILOandGRUB) from IBM DeveloperWorks