<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>
<channel>
	<title>G-Loaded Journal &#187; HOWTO</title>
	<atom:link href="http://www.g-loaded.eu/tag/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.g-loaded.eu</link>
	<description>An open-source software and technology related journal</description>
	<lastBuildDate>Mon, 05 Dec 2011 19:55:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
		<item>
		<title>Caching Nameserver using dnsmasq</title>
		<link>http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/</link>
		<comments>http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 21:44:25 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Service]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=1907</guid>
		<description><![CDATA[dnsmasq is a lightweight, open-source DNS forwarder and DHCP server. In this article we go through how to prepare the system in order to run dnsmasq and also how to configure the latter as a caching-only DNS server. A configuration file is also provided as a drop-in replacement for the default dnsmasq.conf that ships with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq</a> is a lightweight, open-source DNS forwarder and DHCP server. In this article we go through how to prepare the system in order to run <em>dnsmasq</em> and also how to configure the latter as a <strong>caching-only</strong> <abbr title="Domain Name System">DNS</abbr> server. A configuration file is also provided as a drop-in replacement for the default <code>dnsmasq.conf</code> that ships with your system. dnsmasq is available in most Linux distributions. This article was written while using CentOS, so it is safe to say that it also fully covers RHEL, Fedora and generally the whole Red Hat family of operating systems and possibly Novell&#8217;s SLES and OpenSUSE. Small modifications of the invoked commands may be needed for Debian, Ubuntu and other systems.<br />
<span id="more-1907"></span></p>
<h4>Is a caching nameserver really important?</h4>
<p>There is some controversy about the real benefits of using a caching name server in a system, either desktop or server. In this article we keep controversy out of the discussion and focus on the performance improvement the caching of DNS information can offer to a system while performing specific tasks. For instance, a caching nameserver allows a web browser to acquire DNS information from the local DNS cache, provided that this information has already been cached, without the need to access any public DNS servers, which results in faster web browsing. Similarly, in a server environment, services like spam filters often need to perform many DNS queries for the same hostnames. The latency of the communication with the remote nameserver may add up to the total time of email processing.</p>
<h4>BIND vs dnsmasq</h4>
<p><em>BIND</em> is the flagship of DNS servers with large deployments around the globe. I have used BIND for many years as  a <strong>caching nameserver</strong>, even on my desktop, until I realized it is overkill to use BIND this way. There are lighter solutions, even all-in-one software like <strong>dnsmasq</strong>, that seem to be more suitable for setting up local DNS caching.</p>
<h4>System preparation</h4>
<p>So, let&#8217;s get started with the system preparation before going into the details of the dnsmasq configuration.</p>
<p>First of all, we need to install dnsmasq:</p>
<pre class="console">yum install dnsmasq</pre>
<p>dnsmasq, when run as <code>root</code>, is designed to <em>drop privileges</em> and run as an unprivileged user. By default, this user is <code>nobody</code>. We use a dedicated system user to run dnsmasq.</p>
<p>Run the following commands as <code>root</code> to create such an unprivileged system user and group named <em>dnsmasq</em>:</p>
<pre class="console">
groupadd -r dnsmasq
useradd -r -g dnsmasq dnsmasq
</pre>
<p>The above should be enough.</p>
<h4>Configuration</h4>
<p>All dnsmasq configuration options go into <code>/etc/dnsmasq.conf</code>. Here we write this file from scratch, so if you need to keep a copy of the original that ships with your distribution, do so with:</p>
<pre class="console">
cp /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
</pre>
<p>Now, let&#8217;s get started with adding our own dnsmasq configuration in <code>/etc/dnsmasq.conf</code>.</p>
<p>First of all, we set some options regarding the <strong>basic server operation</strong> like the interface and port on which it should bind, the unprivileged user that should run the service and a <abbr title="Process ID">PID</abbr> file:</p>
<pre class="codesnp">
listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid
</pre>
<p>The <strong>bind-interfaces</strong> directive instructs dnsmasq to bind only to the network interface specified in the <strong>listen-address</strong> directive.</p>
<p>Next comes <strong>logging</strong>.</p>
<p>By default, dnsmasq sends its log messages to the <em>DAEMON</em> syslog facility (<em>LOCAL0</em> when operating in debug mode). We go with the defaults here, but keep in mind that a separate log file can be set as it is shown in the configuration snippet below (currently commented out):</p>
<pre class="codesnp">
#log-facility=/var/log/dnsmasq.log
#log-queries
</pre>
<p>Logging to file requires some extra configuration for proper log rotation. For more information, please read <a href="#LoggingToFile">Appendix II</a>.</p>
<p>Finally, we set the options that configure dnsmasq&#8217;s <strong>name resolution</strong> and <strong>caching</strong> operations.</p>
<p>The following directives prevent dnsmasq from forwarding plain names (without any dots) or addresses in the non-routed address space to the parent nameservers.</p>
<pre class="codesnp">
domain-needed
bogus-priv
</pre>
<p>The <strong>no-hosts</strong> directive also instructs dnsmasq not to read any hostnames from <code>/etc/hosts</code>. In most systems, <code>/etc/hosts</code> is queried before a DNS service is used by the system for name lookups. So, all plain name to private IP mappings should normally be added in <code>/etc/hosts</code>. If this is not what you want, then take a look at the <em>expand-hosts</em> and <em>domain</em> directives.</p>
<pre class="codesnp">
no-hosts
</pre>
<p>Set the maximum number of <strong>concurrent DNS queries</strong>. The default value is 150. Adjust to your needs.</p>
<pre class="codesnp">
dns-forward-max=150
</pre>
<p>Set the <strong>size</strong> of the dnsmasq cache. The default is to keep 150 hostnames. By setting the cache size to 0 disables the feature (this is not what we really want). Again, adjust this value according to your needs.</p>
<pre class="codesnp">
cache-size=1000
</pre>
<p>The following directive controls whether negative caching should be enabled or not. Negative caching allows dnsmasq to remember &#8220;<em>no such domain</em>&#8221; answers from the parent nameservers, so it does not query for the same non-existent hostnames again and again. This is probably useful for spam filters or MTA services. By default, negative caching is enabled. To disable, un-comment the following directive.</p>
<pre class="codesnp">
#no-negcache
</pre>
<p>The <strong>neg-ttl</strong> directive sets a default <abbr title="Time-To-Live">TTL</abbr> value to add to negative replies from the parent nameservers, in case these replies do not contain TTL information. If neg-ttl is not set and a negative reply from a parent DNS server does not contain TTL information, then dnsmasq will not cache the reply. Here we set the default TTL to 3600 seconds. Again, adjust to your specific needs.</p>
<pre class="codesnp">
neg-ttl=3600
</pre>
<p>Here we use a separate file where dnsmasq reads the IPs of the parent nameservers from. The syntax is the same as in <code>/etc/resolv.conf</code>. We do this to facilitate the manipulation of the parent nameservers that should be used by dnsmasq by using, for example, an external script. The filename we use here is <code>resolv.dnsmasq</code>, but this can be changed to your liking. We also set the <strong>no-poll</strong> directive here to prevent dnsmasq from polling the &#8216;resolv&#8217; file for changes.</p>
<pre class="codesnp">
resolv-file=/etc/resolv.dnsmasq
no-poll
</pre>
<p>A full configuration file containing all the above configuration, which can can be used as a drop-in replacement of the default <code>/etc/dnsmasq.conf</code>, can be found in <a href="#FullConfigurationFile">Appendix I</a>.</p>
<h4>Upstream Nameservers</h4>
<p>We have used a separate file to store the IPs of the parent nameservers; that is <code>/etc/resolv.dnsmasq</code>. Using the same syntax as in <code>/etc/resolv.conf</code> add the nameserver IP addresses in resolv.dnsmasq. For example:</p>
<pre class="codesnp">
nameserver 192.168.0.252
nameserver 192.168.0.253
nameserver 192.168.0.254
</pre>
<p>Note that we still need to make a change in <code>/etc/resolv.conf</code> before the system starts using dnsmasq for domain name lookups. Read on&#8230;</p>
<h4>Starting dnsmasq</h4>
<p>In order to start dnsmasq, run as root:</p>
<pre class="console">
/etc/init.d/dnsmasq start
</pre>
<p>Check the syslog or the dnsmasq logfile (if used) for any error messages.</p>
<p>If everything seems to be OK, set the dnsmasq service to start on boot:</p>
<pre class="console">
chkconfig dnsmasq on
</pre>
<p>This command might be Red-Hat specific, so consult your distribution&#8217;s documentation about how to set services to start on boot.</p>
<h4>Switch name resolution to dnsmasq</h4>
<p>What we have done so far is set up the dnsmasq service. For hostnames that do not exist in <code>/etc/hosts</code> the system still uses the nameserver inside <code>/etc/resolv.conf</code> for name resolution.</p>
<p>To start using dnsmasq, edit <code>/etc/resolv.conf</code>, remove all nameservers and add only the IP of our dnsmasq service:</p>
<pre class="codesnp">
nameserver 127.0.0.1
</pre>
<p>From now on, the system will use dnsmasq for domain name resolution. You can un-comment the <strong>log-queries</strong> option in order to confirm the dnsmasq operation.</p>
<h4 id="FullConfigurationFile">Appendix I &#8211; Full configuration file</h4>
<p>This is the complete configuration file containing the configuration that has been discussed in this article. Note that it can be used as is to replace the default <code>/etc/dnsmasq.conf</code>.</p>
<pre class="codesnp">
#
# Configuration file for dnsmasq acting as a caching nameserver.
#
# Format is one option per line, legal options are the same
# as the long options legal on the command line. See
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
#
# Updated versions of this configuration file may be available at:
#
#   http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/
#
#
# Basic server configuration
#
listen-address=127.0.0.1
port=53
bind-interfaces
user=dnsmasq
group=dnsmasq
pid-file=/var/run/dnsmasq.pid
#
# Logging
#
#log-facility=/var/log/dnsmasq.log
#log-queries
#
# Name resolution options
#
domain-needed
bogus-priv
no-hosts
dns-forward-max=150
cache-size=1000
#no-negcache
neg-ttl=3600
resolv-file=/etc/resolv.dnsmasq
no-poll
</pre>
<p>This file is meant to be used both on servers and desktops.</p>
<h4 id="LoggingToFile" >Appendix II &#8211; Logging to file</h4>
<p>Before dnsmasq starts logging to file it is required to set the path to the logfile in the <strong>log-facility</strong> option inside <code>/etc/dnsmasq.conf</code>.</p>
<pre class="codesnp">
log-facility=/var/log/dnsmasq.log
</pre>
<p>To ensure proper rotation of the log file you should use the following logrotate configuration:</p>
<pre class="codesnp">
/var/log/dnsmasq.log {
    monthly
    missingok
    notifempty
    delaycompress
    sharedscripts
    postrotate
        [ ! -f /var/run/dnsmasq.pid ] || kill -USR2 `cat /var/run/dnsmasq.pid`
    endscript
    create 0640 dnsmasq dnsmasq
}
</pre>
<p>Save the above configuration in <code>/etc/logrotate.d/dnsmasq</code>. Also, adjust the log filename or the path to the PID file in case you have used custom names, but make sure you do not change the <strong>USR2</strong> signal that is sent to the dnsmasq process in the post-rotation script.</p>
<h4>Final Thoughts</h4>
<p><strong>dnsmasq</strong> is a very lightweight service. Therefore, you can run it on any system, either server or desktop without any noticeable impact on system resources. In this guide we used it as an internal system service bound to the loopback interface, without permitting direct access from the outside. This along with the fact that dnsmasq is mature software that has been around for several years makes our setup rather secure.</p>
<p>Several people might argue that the performance improvement a local caching nameserver offers in terms of name lookup speed is insignificant. This might be true in some cases, but there are times that this performance improvement is noticeable, especially when the quality of the network connectivity between the current machine and the upstream nameserver is an issue, or when the upstream name server is overloaded. On the other hand, it is almost certain that a local caching DNS server can in no way make name resolution slower, unless perhaps a huge cache is being used. Generally, I find keeping such a service operational a good idea.</p>
<p>In this article we discussed about one of the dnsmasq features: DNS caching. dnsmasq is a lot more than just that. Check the whole feature set in the <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq homepage</a>. Perhaps, in the future, more guides covering other features of this software are published. Until then, enjoy local DNS caching!!!</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/">Caching Nameserver using dnsmasq</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2008/12/02/set-up-an-anonymous-ftp-server-with-vsftpd-in-less-than-a-minute/" rel="bookmark">Set up an anonymous FTP server with vsftpd in less than a minute</a></li>
<li><a href="http://www.g-loaded.eu/2006/09/25/how-to-integrate-seaudit-report-in-logwatch/" rel="bookmark">How to integrate seaudit-report in logwatch</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/05/assign-virtual-ips-to-your-nic/" rel="bookmark">Assign Virtual IPs to your NIC</a></li>
<li><a href="http://www.g-loaded.eu/2007/09/15/use-wget-or-curl-to-download-from-rapidshare-premium/" rel="bookmark">Use wget or curl to download from RapidShare Premium</a></li>
<li><a href="http://www.g-loaded.eu/2007/08/10/ssl-enabled-name-based-apache-virtual-hosts-with-mod_gnutls/" rel="bookmark">SSL-enabled Name-based Apache Virtual Hosts with mod_gnutls</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Set up an anonymous FTP server with vsftpd in less than a minute</title>
		<link>http://www.g-loaded.eu/2008/12/02/set-up-an-anonymous-ftp-server-with-vsftpd-in-less-than-a-minute/</link>
		<comments>http://www.g-loaded.eu/2008/12/02/set-up-an-anonymous-ftp-server-with-vsftpd-in-less-than-a-minute/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 09:34:47 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Filesharing]]></category>
		<category><![CDATA[Filesystem]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=706</guid>
		<description><![CDATA[This small HOWTO describes how to configure vsftpd for an anonymous FTP site in order to make files available across your local network or the internet. The scenario this guide is based on is to quickly make a linux distribution&#8217;s installation tree available across the local network in order to be used for a network [...]]]></description>
			<content:encoded><![CDATA[<p>This small HOWTO describes how to configure <a href="http://vsftpd.beasts.org/">vsftpd</a> for an <strong>anonymous FTP site</strong> in order to make files available across your local network or the internet. The scenario this guide is based on is to quickly make a linux distribution&#8217;s installation tree available across the local network in order to be used for a <em>network installation</em>. In this example, I run an anonymous FTP service on my desktop computer making the CentOS installation tree available directly from its installation DVD. This should give you an idea about how to share files or directories that do not physically exist in the root directory of the FTP site.<br />
<span id="more-706"></span></p>
<h4>vsftpd Configuration</h4>
<p>Assuming vsftpd has already been installed in the standard location, the directory <code>/etc/vsftpd/</code>, which contains its configuration files, should exist. You can edit vsftpd&#8217;s default configuration file (<code>/etc/vsftpd/vsftpd.conf</code>), but in this example, we will create a <strong>new configuration file</strong> from scratch.</p>
<p>Create a new configuration file named <code>/etc/vsftpd/vsftpd-anon.conf</code> and open it in your favourite text editor and write down the directives that follow:</p>
<p>Set the server to run in <strong>standalone mode</strong>. This means that vsftpd will run into the background and handle the incoming requests on its own. The alternative method (listen=NO) would require you to set up a xinetd service. This would not be a bad idea, but for the sake of this example, it would be a waste of time.</p>
<pre class="codesnp">
listen=YES
</pre>
<p>The following directives prevent local users from logging in and enables anonymous access respectively.</p>
<pre class="codesnp">
local_enable=NO
anonymous_enable=YES
</pre>
<p>The following directive <strong>disables write access</strong> to the ftp server&#8217;s filesystem. This is a global switch, so noone will be able to upload or modify any files on your ftp site.</p>
<pre class="codesnp">
write_enable=NO
</pre>
<p>Sets the root directory for anonymous connections. By default, this is /var/ftp/.</p>
<pre class="codesnp">
anon_root=/var/ftp
</pre>
<p>The following configuration directives are <strong>optional</strong> and can be safely omitted.</p>
<p>Limit the rate at which anonymous users can retrieve files.</p>
<pre class="codesnp">
anon_max_rate=2048000
</pre>
<p>Enable logging information about user logins an file transfers. The log file is located at <code>/var/log/vsftpd.log</code>.</p>
<pre class="codesnp">
xferlog_enable=YES
</pre>
<p>Set the interface and port the service will listen on. By default, vsftpd will bind to all local network interfaces on port 21, which is the standard port of the File Transfer Protocol. Note that listen_address accepts only numeric IP addresses (no hostnames).</p>
<pre class="codesnp">
listen_address=192.168.0.100
listen_port=21
</pre>
<h5>The entire <code>vsftpd-anon.conf</code> file</h5>
<pre class="codesnp">
#
# Sample anonymous FTP server configuration
#
# Mandatory directives
#
listen=YES
local_enable=NO
anonymous_enable=YES
write_enable=NO
anon_root=/var/ftp
#
# Optional directives
#
anon_max_rate=2048000
xferlog_enable=YES
listen_address=192.168.0.100
listen_port=21
</pre>
<h5>Start or Stop the FTP server</h5>
<p>Assuming you have created the supplementary <code>vsftpd-anon.conf</code> configuration file, run as user root:</p>
<pre class="console">
vsftpd /etc/vsftpd/vsftpd-anon.conf
</pre>
<p>To stop the service run:</p>
<pre class="console">
killall vsftpd
</pre>
<p>Alternatively, you can send the SIGTERM signal to a specific vsftpd process.</p>
<p>On the other hand, if you had edited vsftpd&#8217;s default configuration file, you could start/stop the service using the <code>/etc/init.d/vsftpd</code> initscript.</p>
<h4>Sharing files and directories</h4>
<p>An FTP server without any files is like having a swimming pool without any water in it. In order to make some files and directories available through your FTP service you have two options:</p>
<ol>
<li><strong>Copy</strong> or <strong>move</strong> the files or directories inside the <em>anon_root</em> directory.</li>
<li>Create <strong>bind mounts</strong> of the directories you want to share in the <em>anon_root</em> directory.</li>
</ol>
<p>You may wonder why you cannot just create some <em>symbolic links</em> inside <em>anon_root</em> pointing to the directories you want to share. Even if you created those symlinks and connected to the service using an FTP client, you would notice that you are not permitted to reach the linked location. This happens because anonymous users are restricted (<strong>chrooted</strong>) to <em>anon_root</em> and, therefore, no location outside this directory is accessible using symlinks.</p>
<p><strong>Bind mounts</strong> are the solution to this problem. When <em>bind-mounting</em>, you mount a directory (<em>A</em>) to another directory (<em>B</em>) on the same or different filesystem, so that the contents of directory A appear as contents of directory B. It&#8217;s like a symlink, but at a lower level of the filesystem and that&#8217;s why you can reach locations outside the <em>chroot jail</em>.</p>
<p>In our scenario, the <strong>installation tree</strong> of a Linux distribution is shared through the FTP service. It is assumed that the installation medium has been inserted into the drive and either the system or you have mounted it, for example, to the directory <code>/media/CentOS/</code>. We want the contents of the DVD to be accessible through the FTP server, so we need to bind-mount the DVD contents to a directory inside <code>anon_root</code>. As user &#8216;<em>root</em>&#8216; issue the following command:</p>
<pre class="console">
mount --bind /media/CentOS /var/ftp/pub
</pre>
<p>Now, connecting to the FTP service you will notice that the contents of the <code>pub/</code> directory is the CentOS installation tree.</p>
<p>It is quite obvious that, despite the fact that <em>vsftpd</em> does not support the creation of a virtual filesystem (mainly a virtual directory structure) internally, one can be easily implemented with bind-mounts.</p>
<h4>Do not forget the firewall</h4>
<p>When we run a server temporarily on the desktop computer, we tend to forget to open the necessary ports on the filewall. In the case of vsftpd, you should open port 21 or the port number you have assigned to the <code>listen_port</code> configuration directive. Please consult the documentation of your firewall management application about how to perform this action.</p>
<h4>Further Reading</h4>
<ul>
<li>All the supported <a href="http://vsftpd.beasts.org/vsftpd_conf.html">configuration directives</a> for vsftpd.</li>
</ul>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/12/02/set-up-an-anonymous-ftp-server-with-vsftpd-in-less-than-a-minute/">Set up an anonymous FTP server with vsftpd in less than a minute</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/07/29/when-it-comes-to-error-messages/" rel="bookmark">When it comes to error messages&#8230;</a></li>
<li><a href="http://www.g-loaded.eu/2010/09/18/caching-nameserver-using-dnsmasq/" rel="bookmark">Caching Nameserver using dnsmasq</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/ssh-with-keys/" rel="bookmark">Setup the SSH server to use keys for authentication</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/configure-vnc-server-in-fedora/" rel="bookmark">Set up the VNC Server in Fedora</a></li>
<li><a href="http://www.g-loaded.eu/2008/12/09/making-a-directory-writable-by-the-webserver/" rel="bookmark">Making a directory writable by the webserver</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/12/02/set-up-an-anonymous-ftp-server-with-vsftpd-in-less-than-a-minute/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Use the Alternatives System to switch to a custom Firefox release</title>
		<link>http://www.g-loaded.eu/2008/06/18/use-the-alternatives-system-to-switch-to-a-custom-firefox-release/</link>
		<comments>http://www.g-loaded.eu/2008/06/18/use-the-alternatives-system-to-switch-to-a-custom-firefox-release/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 05:46:25 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Customization]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=496</guid>
		<description><![CDATA[From a user&#8217;s perspective, having to use an old beta version of Firefox in my primary desktop, while, at the same time, a final stable release of the browser has been released, is a bit annoying. But, the fact that this happens due to technical issues makes it partially acceptable. The following article aims to [...]]]></description>
			<content:encoded><![CDATA[<p>From a user&#8217;s perspective, having to use an old beta version of <a href="http://www.mozilla.org/">Firefox</a> in <a href="http://www.g-loaded.eu/2008/05/16/desktop-now-uses-fedora-9/">my primary desktop</a>, while, at the same time, a final stable release of the browser has been released, is a bit annoying. But, the fact that this happens due to technical issues makes it partially acceptable. The following article aims to provide step-by-step instructions about how to use the <strong>alternatives system</strong> to set a custom Firefox release, downloaded from mozilla.org, to be the system&#8217;s default. Using this method the user is relieved from having to go through all the firefox launchers and menu entries in order to edit the paths to the firefox executable. Moreover, this post should also be a good example of how to use the alternatives system in the Linux distributions that support it.</p>
<p><strong><em>Update</em></strong>: Firefox 3.0 final has become available from the official fedora updates repository. It seems that the technical issues of the past do not exist any more! Kudos! This tutorial will still give you an idea though about how to <em>quickly</em> and <em>easily</em> switch between the default and custom versions of the same software in your system.<br />
<span id="more-496"></span><br />
Fedora 9 has been used as the desktop system for this article. The provided information will certainly work in CentOS and RHEL, but might also work for other linux distributions which use the alternatives system, such as Debian, Ubuntu, OpenSUSE etc. As far as I know, Gentoo and its derivatives use their own system.</p>
<p>In order to check if &#8220;alternatives&#8221; is available in your system, try one of the following commands:</p>
<pre class="console">
which alternatives
which update-alternatives
</pre>
<h4>Firefox Installation</h4>
<p>First of all, we install a <em>precompiled</em> (binary) Firefox distribution, downloaded from mozilla.org, in the <strong>/opt</strong> directory. All the following commands should be issued by &#8216;<code>root</code>&#8216; or by your regular user using &#8216;<code>sudo</code>&#8216;.</p>
<p><em>Change</em> to the <strong>/opt</strong> directory, <em>download</em> and <em>extract</em> the firefox package:</p>
<pre class="console">
cd /opt/
wget ftp://ftp.mozilla.org/pub/firefox/releases/3.0/linux-i686/en-US/firefox-3.0.tar.bz2
tar -xjf firefox-3.0.tar.bz2
</pre>
<p>Now <em>change</em> to the <strong>/opt/firefox/</strong> directory, <em>delete</em> the <strong>plugins/</strong> subdirectory and create a <em>symlink</em> to the system&#8217;s directory containing the firefox plugins (<code>/usr/lib/mozilla/plugins/</code> in Fedora).</p>
<pre class="console">
cd firefox/
rm -fr plugins
ln -s /usr/lib/mozilla/plugins/ plugins
</pre>
<p>The installation of the custom Firefox version is complete.</p>
<h4>Set the system-wide default Firefox version</h4>
<p>In this section we will use the <strong>alternatives system</strong> in order to provide us with two options:</p>
<ol>
<li>Use Fedora&#8217;s default Firefox release. This means that <strong>/usr/bin/firefox</strong> should be executed whenever we issue the &#8216;<code>firefox</code>&#8216; command.</li>
<li>Set our custom Firefox release as the system&#8217;s default. This means that <strong>/opt/firefox/firefox</strong> should be executed whenever we issue the &#8216;<code>firefox</code>&#8216; command.</li>
</ol>
<p><strong><em>Note</em></strong>: Describing the details of the alternatives system is out of the scope of this article, so it is highly recommended that you study the <em>alternatives manual page</em> (<code>man 8 alternatives</code>)</p>
<p>In the following steps we will add a <strong>group</strong>, named &#8220;<em>firefox</em>&#8220;, of alternative options for the location of the <strong>firefox executable</strong>. These options are actually <em>filesystem locations</em> which will be linked by the <strong>/usr/local/bin/firefox</strong> symlink. Note that we use the <strong>/usr/local/bin/&#8230;</strong> path for our symlink, because <strong>/usr/bin/firefox</strong> is occupied by fedora&#8217;s firefox executable. The latter will not be called directly any more, as the executables located in <strong>/usr/local/bin/</strong> override the ones located in <strong>/usr/bin/</strong>, so whenever the command &#8216;<code>firefox</code>&#8216; is invoked, <strong>/usr/local/bin/firefox</strong> will actually be used. The latter is a symlink, which links to either fedora&#8217;s firefox executable or our custom firefox executable.</p>
<p>So, we add the &#8216;<em>firefox</em>&#8216; group of options:</p>
<pre class="console">
/usr/sbin/alternatives --install /usr/local/bin/firefox firefox /usr/bin/firefox 10
/usr/sbin/alternatives --install /usr/local/bin/firefox firefox /opt/firefox/firefox 20
</pre>
<p>Now we can manually set which firefox executable to use as the system&#8217;s default. In other words, the following command links <strong>/usr/local/bin/firefox</strong> to the desired executable (<strong>/opt/firefox/firefox</strong> in our case):</p>
<pre class="console">
/usr/sbin/alternatives --set firefox /opt/firefox/firefox
</pre>
<p><strong>Instead of the <code>--set</code> option as shown above</strong>, we can use the <strong>&#8211;config</strong> option, so that a list of the available <em>alternatives</em> is displayed and we are prompted to make a selection:</p>
<pre class="console">
# /usr/sbin/alternatives --config firefox
There are 2 programs which provide 'firefox'.
  Selection    Command
-----------------------------------------------
   1           /usr/bin/firefox
*+ 2           /opt/firefox/firefox
Enter to keep the current selection[+], or type selection number: 2
</pre>
<p>Finally, we can issue the following command to get an overview of our current configuration for the group &#8216;<em>firefox</em>&#8216;:</p>
<pre class="console">
# /usr/sbin/alternatives --display firefox
firefox - status is manual.
 link currently points to /opt/firefox/firefox
/usr/bin/firefox - priority 10
/opt/firefox/firefox - priority 20
Current `best' version is /opt/firefox/firefox.
</pre>
<h4>Revert to the original state</h4>
<p>If for any reason you need to revert things back to the default state, all you have to do in order to remove all the &#8220;<em>alternatives</em>&#8221; we had configured in the previous section is the following:</p>
<pre class="console">
/usr/sbin/alternatives --remove firefox /opt/firefox/firefox
/usr/sbin/alternatives --remove firefox /usr/bin/firefox
</pre>
<p>No other configuration is required. From now on, whenever the &#8216;<code>firefox</code>&#8216; command is invoked, fedora&#8217;s old <strong>/usr/bin/firefox</strong> is executed.</p>
<h4>Final Thoughts</h4>
<p>Technical issues in the linux distribution preparation process might limit the user to certain software versions. The alternatives system provides users with the choice to configure the system in a way that it is extremely <strong>easy to switch</strong> between <strong>default</strong> and <strong>custom</strong> versions of the same software.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/06/18/use-the-alternatives-system-to-switch-to-a-custom-firefox-release/">Use the Alternatives System to switch to a custom Firefox release</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2011/09/28/the-new-amateuristic-release-strategy-of-firefox/" rel="bookmark">The new amateuristic release strategy of Firefox</a></li>
<li><a href="http://www.g-loaded.eu/2009/10/30/selinux-setenforce-mode/" rel="bookmark">Using setenforce to switch SELinux mode wisely</a></li>
<li><a href="http://www.g-loaded.eu/2008/11/26/using-a-switch-to-prevent-system-shutdownrebootsuspend/" rel="bookmark">Using a switch to prevent system shutdown/reboot/suspend</a></li>
<li><a href="http://www.g-loaded.eu/2005/12/11/local-yum-repository/" rel="bookmark">Local YUM Repository</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/08/the-use-of-the-uppercase-x-in-chmod/" rel="bookmark">The use of the uppercase X in chmod</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/06/18/use-the-alternatives-system-to-switch-to-a-custom-firefox-release/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Using SSH for networking</title>
		<link>http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/</link>
		<comments>http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/#comments</comments>
		<pubDate>Fri, 16 May 2008 00:13:02 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=474</guid>
		<description><![CDATA[This is mainly a note to myself about two patches, just in case I ever decide to use OpenSSH for networking, in addition to remote administration. First, is the cipler-none patch that adds none as a valid argument to the -c command line option. By using it, the transferred data is not encrypted. Pros: eliminates [...]]]></description>
			<content:encoded><![CDATA[<p>This is mainly a note to myself about two patches, just in case I ever decide to use <a href="http://www.openssh.org/">OpenSSH</a> for networking, in addition to remote administration.</p>
<p><strong>First</strong>, is the <strong>cipler-none</strong> patch that adds <code>none</code> as a valid argument to the <strong>-c</strong> command line option. By using it, the transferred data is not encrypted. <em>Pros</em>: eliminates the data encryption overhead. <em>Cons</em>: totally insecure method of transferring sensitive data.</p>
<p><a href="http://arctic.org/~dean/patches/openssh-3.8.1p1-cipher-none.patch">cipher-none-patch</a></p>
<p><em>Note</em>: the OpenSSH server, even if it has been patched with this code, does not accept unencrypted connections by default. This has to be enabled explicitly in the sshd configuration (<code>sshd_config</code>) by adding the <em>none</em> &#8220;cipher&#8221; to the list of the accepted ciphers:</p>
<pre class="codesnp">Ciphers aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,none</pre>
<p><em>Note2</em>: here is <em>step-by-step</em> guide how to configure the <em><a href="http://www.g-loaded.eu/2005/11/10/ssh-with-keys/">SSH authentication using public keys</a></em>.</p>
<p><strong>Second</strong>, is a set of patches, created at the <a href="http://www.psc.edu/">Pittsburgh Supercomputing Center</a>, which eliminate the bottlenecks caused by some of the internal buffers that control data flow in network connections through OpenSSH. This project is called <a href="http://www.psc.edu/networking/projects/hpn-ssh/">High Performance SSH/SCP</a> (aka <em>HPN-SSH</em>). Benchmarks show that even encrypted network connections using HPN-SSH perform extraordinarily better than the usual encrypted OpenSSH connections.</p>
<p>OK, this info exists here for completeness, as those HPN-SSH patches <em>have not been designed for home networks</em>! Possibly it might make no difference if you use the regular OpenSSH or HPN-SSH in your home LAN.</p>
<p><em>Note</em>: the HPN-SSH patches also contain code that adds the <em>none</em> cipher, similar to the <em>cipher-none patch</em>, so, if you intend to use HPN-SSH, it is not required to apply both on the OpenSSH source.</p>
<p>Finally, apart from all these, if you ever decide to use SSH for networking seriously consider using <a href="http://fuse.sourceforge.net/sshfs.html">SSHfs</a> (see also <a href="http://fuse.sourceforge.net/wiki/index.php/SshfsFaq">SSHfsFAQ</a>).</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/">Using SSH for networking</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2011/09/27/mod_gnutls-rc4-cipher-beast/" rel="bookmark">How to configure mod_gnutls to use the RC4 cipher to mitigate the SSL/TLS vulnerability</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/05/assign-virtual-ips-to-your-nic/" rel="bookmark">Assign Virtual IPs to your NIC</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/ssh-with-keys/" rel="bookmark">Setup the SSH server to use keys for authentication</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/encrypt-devices-using-dm-crypt-and-luks/" rel="bookmark">Encrypt devices using dm-crypt and LUKS</a></li>
<li><a href="http://www.g-loaded.eu/2006/11/05/truecrypt-on-2618-kernels/" rel="bookmark">TrueCrypt on 2.6.18 kernels</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/05/16/using-ssh-for-networking/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>How to Disable IPv6 in Fedora and CentOS</title>
		<link>http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/</link>
		<comments>http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/#comments</comments>
		<pubDate>Mon, 12 May 2008 19:31:41 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Fedora]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=477</guid>
		<description><![CDATA[They say that by disabling IPv6 things get a bit smoother and faster regarding networking. I don&#8217;t really know if this is true, but I guess, if you&#8217;ve decided to disable this feature, you probably care to do it the Right Way&#8482;. As far as I know, trying to disable IPv6 through anaconda during the [...]]]></description>
			<content:encoded><![CDATA[<p>They say that by disabling <a href="http://en.wikipedia.org/wiki/Ipv6">IPv6</a> things get a bit smoother and faster regarding networking. I don&#8217;t really know if this is true, but I guess, if you&#8217;ve decided to disable this feature, you probably care to do it the Right Way&trade;. As far as I know, trying to disable IPv6 through anaconda during the installation of Fedora or CentOS does not turn off the IPv6 functionality completely, but it just disables it for the configured network interface. This is not actually a problem, but, why should this network layer be enabled system-wide, if you do not use it at all? This small article assists you in disabling IPv6 in the latest <a href="http://fedoraproject.org/">Fedora</a> and <a href="http://centos.org/">CentOS</a> releases in an <em>aggressive</em> and <em>unforgiving</em> way.<br />
<span id="more-477"></span></p>
<h4>Check if the module is loaded</h4>
<p>IPv6 functionality is being made available to the system by the <strong>ipv6</strong> <em>kernel module</em>. To check if this module is currently loaded in your system, issue the following command as <em>root</em>:</p>
<pre class="console">
lsmod | grep ipv6
</pre>
<p>If you see <code>ipv6</code> in its output, then the module is loaded.</p>
<p>Performing this check is <em>absolutely not necessary</em>. It is included in this article for completeness.</p>
<h4>Disable IPv6</h4>
<p>You can prevent a module from being inserted into the kernel by either <strong>blacklisting</strong> it <em>or</em> by completely <strong>disabling</strong> it.</p>
<p>In this case, since you will most probably turn off the IPv6 firewall (<em>ip6tables</em>) as well, it is highly recommended to completely disable the ipv6 module, to avoid any accidental loading of the IPv6 stack without any firewall protection at the same time.</p>
<h5>How the module blacklist works</h5>
<p>This information about blacklisting a kernel module exists here for educational purposes. It has been mentioned above that for ipv6 it is important to completely disable it.</p>
<p>From the <code>modprobe.conf</code> man page:</p>
<blockquote><p>
Modules can contain their own aliases: usually these are aliases describing the devices  they  support,  such  as  &#8220;pci:123&#8230;&#8221;.   These  &#8220;internal&#8221; aliases  can  be  overridden  by  normal  &#8220;alias&#8221; keywords, but there are cases where two or more modules both support the same devices, or a module invalidly claims to support a device: the blacklist keyword indicates that all of that particular module’s internal aliases are to be ignored.
</p></blockquote>
<p>So, <strong>blacklist</strong> indicates that a module&#8217;s aliases should be ignored. But, what happens if an application requires to load that specific module or if root uses <code>modprobe</code> to load it on demand? Let&#8217;s test it&#8230;</p>
<p>To blacklist the module, simply save the following line in a file inside <code>/etc/modprobe.d</code>:</p>
<pre class="codesnp">
blacklist ipv6
</pre>
<p>Next, disable any services that use IPv6, eg <code>ip6tables</code> or any IPv6-enabled network interfaces and <strong>reboot</strong> (mandatory).</p>
<p>After you&#8217;ve logged-in again, try, for example, to load the ipv6 module with the <code>modprobe</code> command (as root):</p>
<pre class="console">
[root@centos]# modprobe -v ipv6
insmod /lib/modules/2.6.18-53.1.14.el5/kernel/net/ipv6/ipv6.ko
[root@centos]# lsmod | grep v6
ipv6                  251393  8
</pre>
<p>The blacklisted module has been loaded. This is what happens if it is needed by a system service, regardless of the fact that it has been blacklisted. In the case of <code>ipv6</code> this could be a security risk, provided that the ipv6 firewall has been turned off but some network interfaces still use IPv6. So, frankly, it is suggested to read on how to disable the module more aggressively&#8230;</p>
<h5>Completely disable the ipv6 module</h5>
<p>To completely disable IPv6 in your system, all you have to do is save the following line in a file inside <code>/etc/modprobe.d/</code>.</p>
<pre class="codesnp">
install ipv6 /bin/true
</pre>
<p>The above line means: whenever the system needs to load the <strong>ipv6</strong> kernel module, it is forced to execute the command <code>true</code> instead of actually loading the module. Since <code>/bin/true</code>, does absolutely nothing, the module <strong>never</strong> gets loaded.</p>
<p>Again, it is required to <strong>reboot</strong> for the changes to take effect.</p>
<p>It is obvious that this is an <em>aggressive</em> method to disable kernel modules, but it <strong>guarantees</strong> that the module never gets loaded.</p>
<p>This is the <strong>recommended</strong> way to <em>disable IPv6</em>.</p>
<h4>Other Configuration Tasks</h4>
<p>Since the IPv6 functionality has been disabled, you can disable the <strong>ip6tables</strong> service (IPv6 Firewall). Issue the following command as <em>root</em>:</p>
<pre class="console">
chkconfig ip6tables off
</pre>
<p>It is also a good idea, since the ip6tables service has been turned off, to disable any IPv6-related functionality in the network interface configuration. Even if you do not do this, the IPv6 stack will not be initialized because the <em>ipv6 module</em> cannot be loaded. But, generally, you could set the following options to &#8220;<strong>no</strong>&#8221; inside your network interface scripts, for example: <code>/etc/sysconfig/network-scripts/ifcfg-eth0</code></p>
<pre class="codesnp">
IPV6INIT=no
IPV6_AUTOCONF=no
</pre>
<p>Finally, In fedora 8 or newer you can safely remove the following option from the /etc/sysconfig/network file, if it exists:</p>
<pre class="codesnp">
NETWORKING_IPV6=no
</pre>
<h4>Final Thoughts</h4>
<p>Using the instructions above, you can completely disable IPv6 in your system. On the other hand, you should understand that IPv6 is not an evil thing&#8230; It exists in order to address certain issues. If you ever think about actually trying to configure and use it instead of just disabling it every time you install your Linux operating system, here is a <a href="http://fedoraproject.org/wiki/IPv6Guide">good place to start</a>&#8230;</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/">How to Disable IPv6 in Fedora and CentOS</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2009/10/05/fedora-server-vs-centos/" rel="bookmark">Fedora Server vs CentOS</a></li>
<li><a href="http://www.g-loaded.eu/2005/12/14/the-complete-fedora-kernel-headers/" rel="bookmark">The Complete Fedora Kernel Headers</a></li>
<li><a href="http://www.g-loaded.eu/2008/12/08/creative-pc-cam-750-on-fedora-10/" rel="bookmark">Creative PC-CAM 750 on Fedora 10</a></li>
<li><a href="http://www.g-loaded.eu/2009/12/18/high-cpu-usage-centos-guest-virtualbox-vmware/" rel="bookmark">High CPU usage while running CentOS as guest on Virtualbox or VMware</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/10/configure-vnc-server-in-fedora/" rel="bookmark">Set up the VNC Server in Fedora</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/05/12/how-to-disable-ipv6-in-fedora-and-centos/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Use mod_deflate to Compress Web Content delivered by Apache</title>
		<link>http://www.g-loaded.eu/2008/05/10/use-mod_deflate-to-compress-web-content-delivered-by-apache/</link>
		<comments>http://www.g-loaded.eu/2008/05/10/use-mod_deflate-to-compress-web-content-delivered-by-apache/#comments</comments>
		<pubDate>Sat, 10 May 2008 00:09:24 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Compression]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Servers]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/?p=492</guid>
		<description><![CDATA[One of the most efficient methods to reduce the usage of bandwidth by the web server and, at the same time, increase the speed of the content delivery is to compress your web pages and, generally, all output that is returned to the clients. The compression of the web content can be done using several [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most efficient methods to reduce the usage of bandwidth by the web server and, at the same time, increase the speed of the content delivery is to <strong>compress</strong> your web pages and, generally, all output that is returned to the clients. The compression of the <strong>web content</strong> can be done using several methods. This article describes how to use the <em>mod_deflate</em> module to compress Apache&#8217;s output <em>on-the-fly</em>.<br />
<span id="more-492"></span></p>
<h4>Introducing mod_deflate</h4>
<p>Apache prepares the response that will be sent back to the client in several stages. One of those stages involves the modification or conversion of the data using <strong>output filters</strong>. <em>mod_deflate</em>, once loaded and activated, inserts such a filter, named <strong>DEFLATE</strong>, in Apache&#8217;s chain of <em>output filters</em>, which compresses all data that goes through it according to some rules the web server administator has defined. For instance, one can set the compression level, restrict the compression to particular MIME types or prevent some problematic web browsers or other HTTP clients from receiving compressed data from the server.</p>
<p><em>mod_deflate</em> also offers an input filter which can be used to decompress compressed HTTP requests, but this feature is outside of the scope of the current document.</p>
<p>Here follow some instructions on how to configure <em>mod_deflate</em>. Most of it can be found inside HTTPd&#8217;s official documentation, so you&#8217;d better read this resource as well.</p>
<p>Note that all of the following configuration directives can be inserted in Apache&#8217;s <em>main server context</em> or can be saved to a file that will be loaded from within the main server or any other <em>virtual host context</em>. If the configuration directives are inserted in the main server context, then <strong>they will be inherited by all virtual hosts</strong>.</p>
<h4>Load mod_deflate</h4>
<p><em>mod_deflate</em> can be loaded like any other Apache module:</p>
<pre class="codesnp">
LoadModule deflate_module modules/mod_deflate.so
</pre>
<p>Please note that <strong>this directive can only exist in the main server configuration</strong>.</p>
<h4>Enable Compression</h4>
<p>The compression of the data can be enabled <strong>for all data</strong> that goes through the <em>DEFLATE</em> filter or <em>selectively</em> depending on its <strong>MIME type</strong>.</p>
<p>To enable the compression <strong>for any type of content</strong>, insert the following directive:</p>
<pre class="codesnp">
 SetOutputFilter DEFLATE
</pre>
<p>Alternatively, to define which filetypes should pass through the <em>DEFLATE</em> output filter use the  <strong>AddOutputFilterByType</strong> directive. The following is an example:</p>
<pre class="codesnp">
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</pre>
<h4>Set the Compression Level</h4>
<p>Generally, the <a href="http://en.wikipedia.org/wiki/DEFLATE_(algorithm)">deflate compression algorithm</a> is fast enough, so setting the compression level to the maximum (9) will not cause any noticeable trouble, even to relatively old hardware.</p>
<pre class="codesnp">
DeflateCompressionLevel 9
</pre>
<h4>Custom Rules for problematic browsers</h4>
<p>The compression can be turned-off or be restricted to files of type <code>text/html</code> for known problematic web browsers. These are taken from the official documentation.</p>
<pre class="codesnp">
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</pre>
<h4>Keep track of the compression</h4>
<p>Finally you can keep track of the compression in order to evaluate the effectiveness of the use of <em>mod_deflate</em> in your server.</p>
<p>The following directives define some variables, such as:</p>
<ul>
<li><strong>instream</strong> : the size in bytes of the data as received by the <em>DEFLATE</em> filter.</li>
<li><strong>outstream</strong> : the size in bytes of the compressed data as returned from the <em>DEFLATE</em> filter.</li>
<li><strong>ratio</strong> : the compression ratio, <code>(Output/Input)x100</code></li>
</ul>
<pre class="codesnp">
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
</pre>
<p>Finally, you can define a custom <em>logformat</em> so to be able to record the aforementioned values to a logfile:</p>
<pre class="codesnp">
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
</pre>
<p>The deflate logformat can be used for the main server&#8217;s or for any vhost;s logfile.</p>
<h4>Effectiveness of Compression</h4>
<p>It is well known that not all document types can benefit the same from compression. Generally, the <em>deflate algorithm</em> can compress <strong>text</strong> surprisingly fast and with a very high efficiency ratio. On the other hand, it is almost useless when used to compress <strong>images</strong> which have been prepared for the web such as PNG, JPEG, GIF and generally all other image types in which the data has already been compressed. The same goes for compressed <strong>audio</strong> files, such as MP3, AAC, OGG, <strong>videos</strong>, <strong>PDF</strong> documents and all other already compressed files.</p>
<p>So, the benefits of using <em>mod_deflate</em> to reduce the bandwidth usage and speed up the content delivery are heavily dependent on the type of files your web server delivers.</p>
<h4>Browser Support</h4>
<p>A web server that sends compressed data to clients would be completely useless if the HTTP clients couldn&#8217;t decompress that data. All modern and popular web browsers support accepting content that has been compressed using the <em>gzip</em> or <em>deflate</em> algorithms, so there should be no problem at all.</p>
<h4>Appendix I</h4>
<p>Here is the complete <em>mod_deflate</em> configuration as described in this <span style="color:black;text-decoration:none;"><a href="http://www.g-loaded.eu/2008/05/10/use-mod_deflate-to-compress-web-content-delivered-by-apache/">article</a></span>. Save it in a file, named <strong>deflate.conf</strong> and import it in the main server&#8217;s configuration using the <strong>Include</strong> directive</p>
<p>(<code>Include /path/to/deflate.conf</code>):</p>
<pre class="codesnp">
#
# mod_deflate configuration
#
LoadModule deflate_module modules/mod_deflate.so
&lt;IfModule mod_deflate.c&gt;
        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/xml
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE application/xhtml+xml
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/x-javascript
        DeflateCompressionLevel 9
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        DeflateFilterNote Input instream
        DeflateFilterNote Output outstream
        DeflateFilterNote Ratio ratio
        LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
&lt;/IfModule&gt;
</pre>
<p>This configuration will be <strong>inherited by all virtual hosts</strong>.</p>
<p>To <strong>disable</strong> it just comment out the line that loads the mod_deflate module (<code>#LoadModule ...</code>).</p>
<p>To record <em>mod_deflate</em>&#8216;s specific variable (<em>instream</em>, <em>outstream</em>, <em>ratio</em>) values for a virtual host, just add a new log file of type <em>deflate</em>:</p>
<pre class="codesnp">
CustomLog /path/to/vhost/logs/deflate_log deflate
</pre>
<p>This will give you an idea of how efficient is the use of mod_deflate in that particular vhost.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/05/10/use-mod_deflate-to-compress-web-content-delivered-by-apache/">Use mod_deflate to Compress Web Content delivered by Apache</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/12/04/optimize-and-compress-css-files/" rel="bookmark">Optimize and Compress CSS Files</a></li>
<li><a href="http://www.g-loaded.eu/2007/08/10/ssl-enabled-name-based-apache-virtual-hosts-with-mod_gnutls/" rel="bookmark">SSL-enabled Name-based Apache Virtual Hosts with mod_gnutls</a></li>
<li><a href="http://www.g-loaded.eu/2010/03/28/script-apache-error-report/" rel="bookmark">Script for Apache Error Report</a></li>
<li><a href="http://www.g-loaded.eu/2011/11/28/speed-up-apache-by-including-htaccess-files-into-httpd-conf/" rel="bookmark">Speed up Apache by including htaccess files into httpd.conf</a></li>
<li><a href="http://www.g-loaded.eu/2006/10/06/check-server-http-headers-with-curl/" rel="bookmark">Check Server HTTP Headers with CURL</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/05/10/use-mod_deflate-to-compress-web-content-delivered-by-apache/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>How to extract RPM or DEB packages</title>
		<link>http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/</link>
		<comments>http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/#comments</comments>
		<pubDate>Mon, 28 Jan 2008 00:30:32 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[DEB]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Packaging]]></category>
		<category><![CDATA[RPM]]></category>
		<category><![CDATA[Shell]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/</guid>
		<description><![CDATA[RPM and DEB packages are both containers for other files. An RPM is some sort of cpio archive. On the other hand, a DEB file is a pure ar archive. So, it should be possible to unpack their contents using standard archiving tools, regardless of your distribution&#8217;s package format. Under normal conditions, you should use [...]]]></description>
			<content:encoded><![CDATA[<p>RPM and DEB packages are both containers for other files. An RPM is some sort of <strong>cpio</strong> archive. On the other hand, a DEB file is a pure <strong>ar</strong> archive. So, it should be possible to unpack their contents using standard archiving tools, regardless of your distribution&#8217;s package format. Under normal conditions, you should use your distribution&#8217;s standard package manager, <strong>rpm</strong> or <strong>dpkg</strong> and their frontends, to manage those files. But, if you need to be more generic, here is how to do it.<br />
<span id="more-482"></span></p>
<h4>RPM</h4>
<p>For RPMs you need two command line utilities, <strong>rpm2cpio</strong> and <strong>cpio</strong>. Extracting the contents of the RPM package is a <em>one step</em> process:</p>
<pre class="console">rpm2cpio mypackage.rpm | cpio -vid</pre>
<p>If you just need to list the contents of the package without extracting them, use the following:</p>
<pre class="console">rpm2cpio mypackage.rpm | cpio -vt</pre>
<p>The <strong>-v</strong> option is used in order to get verbose output to the stdout. If you don&#8217;t need it, you can safely omit this switch. For more information about the <code>cpio</code> options, please refer to the <code>cpio(1)</code> manual page.</p>
<h4>DEB</h4>
<p>DEB files are <em>ar archives</em>, which contain three files:</p>
<ul>
<li>debian-binary</li>
<li>control.tar.gz</li>
<li>data.tar.gz</li>
</ul>
<p>As you might have already guessed, the needed archived files exist in <code>data.tar.gz</code>. It is also obvious that unpacking this file is a <em>two-step</em> process.</p>
<p>First, extract the aforementioned three files from the DEB file (<strong>ar</strong> archive):</p>
<pre class="console">ar vx mypackage.deb</pre>
<p>Then extract the contents of <code>data.tar.gz</code> using <strong>tar</strong>:</p>
<pre class="console">tar -xzvf data.tar.gz</pre>
<p>Or, if you just need to get a <em>listing</em> of the files:</p>
<pre class="console">tar -tzvf data.tar.gz</pre>
<p>Again the <strong>-v</strong> option in both <strong>ar</strong> and <strong>tar</strong> is used in order to get verbose output. It is safe not to use it. For more information, read the man pages: <code>tar(1)</code> and <code>ar(1)</code>.</p>
<p><strike>If anyone knows a <em>one step process</em> to extract the contents of the <code>data.tar.gz</code>, I&#8217;d be very interested in it!</strike></p>
<p><strong>Update</strong></p>
<p>As Jon <a href="http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/comment-page-1/#comment-11671">suggested</a> in the comment area, the contents of data.tar.gz can be extracted from the DEB package in a one step process as shown below:</p>
<pre class="console">
ar p mypackage.deb data.tar.gz | tar zx
</pre>
<p>That will do it.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/">How to extract RPM or DEB packages</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/12/01/choosing-a-format-for-data-backups-tar-vs-cpio/" rel="bookmark">Choosing a format for data backups &#8211; tar vs cpio</a></li>
<li><a href="http://www.g-loaded.eu/2006/04/05/how-to-build-rpm-packages-on-fedora/" rel="bookmark">How To Build RPM Packages on Fedora</a></li>
<li><a href="http://www.g-loaded.eu/2007/12/01/veritar-verify-checksums-of-files-within-a-tar-archive/" rel="bookmark">VeriTAR &#8211; Verify checksums of files within a TAR archive</a></li>
<li><a href="http://www.g-loaded.eu/2006/10/07/verify-a-burned-cddvd-image-on-linux/" rel="bookmark">Verify a burned CD/DVD image on Linux</a></li>
<li><a href="http://www.g-loaded.eu/2006/04/08/linux-tips-pack-i/" rel="bookmark">Linux Tips &#8211; Pack I</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Viceo Backend for SANE with libusb support</title>
		<link>http://www.g-loaded.eu/2008/01/24/viceo-backend-for-sane-with-libusb-support/</link>
		<comments>http://www.g-loaded.eu/2008/01/24/viceo-backend-for-sane-with-libusb-support/#comments</comments>
		<pubDate>Thu, 24 Jan 2008 15:00:43 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Imaging]]></category>
		<category><![CDATA[SANE]]></category>
		<category><![CDATA[Scanner]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2008/01/24/viceo-backend-for-sane-with-libusb-support/</guid>
		<description><![CDATA[After many years of failure, countless hours of digging into the World Wide Web for information, numerous failed attempts due to lack of knowledge to modify the v0.6 E3 driver for USB scanners (Viceo backend) and add support for libusb, yesterday I was sent a patch, which contained the Viceo backend for SANE with libusb [...]]]></description>
			<content:encoded><![CDATA[<p>After many years of failure, countless hours of digging into the World Wide Web for information, numerous failed attempts due to lack of knowledge to modify the v0.6 <a href="http://viceo.orcon.net.nz/">E3 driver</a> for USB scanners (Viceo backend) and add support for <a href="http://libusb.sourceforge.net/">libusb</a>, yesterday I was sent a patch, which contained the <em>Viceo</em> backend for <a href="http://www.sane-project.org/">SANE</a> with libusb support. My old <strong>Primax Colorado 19200 USB</strong> scanner worked for the first time under Linux. If you own such an old scanner and care to make it work under a modern Linux distribution, read on for instructions and files.<br />
<span id="more-481"></span><br />
It all happened when I stumbled upon Pat&#8217;s <a href="http://www.engsoc.org/~pat/log/index.cgi/2004/05/25#1085543907">blog post</a> a couple of days ago, which gave me hope that someone had cared to modify the E3 USB scanner driver and make it work with libusb. I sent an email to Pat and received a patch (<em>thanks a million</em>!) for <em>sane-backends-1.0.14</em>. The patch did not work initially with today&#8217;s <em>sane-backends-1.0.18</em>, but this would not stop a determined soul from fixing it. Adding support for libusb was completely out of my league, but fixing that particular patch was definitely something I could deal with. It took me some hours, but, finally, I, not only had a patch that could be applied succesfully into the sane-backends-1.0.18 source, but also had a working Viceo backend for SANE, which means&#8230; a working scanner under Linux. I admit that I use the scanner rather rarely, but knowing that this piece of hardware can work under Linux is good.</p>
<h4>Driver History</h4>
<p>Here goes some brief history about the driver.</p>
<p>The E3 driver was initially developed by Steven Ellis (<a href="http://viceo.orcon.net.nz/">http://viceo.orcon.net.nz/</a>). 0.6 was the last released version (2002), which lacked support for libusb. It seems that Steven abandoned the development of the driver at that point. Until a few days ago, the 0.6 release was what I had considered as the latest available version of the E3 driver.</p>
<p>What I missed, was the fact that Jimmy Nguyen had modified the 0.6 driver and had added support for libusb. I had spent countless hours searching the web in the past but I could not locate such a release of the driver. Anyhow, Jimmy&#8217;s patch was released in 2004 for sane-backends-1.0.14.</p>
<p>The rest has been already described above.</p>
<h4>Supported Devices</h4>
<p>This driver works with <strong>USB scanners</strong> equipped with the <strong>E3 chipset</strong>. Some of these scanner models (if not all) are the following:</p>
<ul>
<li>Genius Vivid Pro USB</li>
<li>Primax Colorado USB 19200</li>
<li>Visioneer OneTouch 7600</li>
<li>Visioneer OneTouch 6100</li>
<li>IBM IdeaScan 2000 USB</li>
<li>LG Electronics Scanworks 600U</li>
</ul>
<h4>Download</h4>
<p>I have modified the original patch in order to make it work with <code>sane-backends-1.0.18</code> and also wrote a <em>SPEC</em> file for RPM packaging. Using a package will greatly simplify the installation procedure.</p>
<p>Here follows a list of files you can download:</p>
<dl>
<dt>RPM &#8211; <a href="http://www.codetrax.org/attachments/download/42/sane-backends-viceo-1.0.18-0.7-rcnst.1.i386.rpm">sane-backends-viceo-1.0.18-0.7-rcnst.1.i386.rpm</a></dt>
<dd>RPM package of Viceo backend. <strong>Requires sane-backends-1.0.18</strong>. Installs the Viceo backend only and will not touch any other files. Please read the <em>Installation</em> and <em>Configuration</em> sections for instructions.</dd>
<dt>DEB &#8211; TODO</dt>
<dd>A DEB file for debian-based distributions is not currently available. You can still generate a deb package from the RPM using <strong>alien</strong>. In order to convert the the RPM package to a DEB, use alien like: <code>alien -k sane-backends-viceo-1.0.18-0.7-rcnst.1.i386.rpm</code> and a deb package will be generated for you. You can install the DEB package with: <code>dpkg -i sane-backends-viceo-1.0.18-0.7-rcnst.1.i386.deb</code>. Please note that this procedure <strong>has not been tested</strong>.</dd>
<dt>SPEC &#8211; <a href="http://www.codetrax.org/attachments/download/44/viceo.spec">viceo.spec</a></dt>
<dd>Required if you need to build the RPM package.</dd>
<dt>Patch &#8211; <a href="http://www.codetrax.org/attachments/download/41/sane-backends-1.0.18-viceo.diff.gz">sane-backends-1.0.18-viceo.diff.gz</a></dt>
<dd><strong>New</strong> Viceo backend patch for <strong>sane-backends 1.0.18</strong>. Note, that in addition to the required modifications in order to make this patch suitable for sane-backends-1.0.18, this diff does not include the modifications of the core SANE file <code>sanei/sanei_usb.c</code>. Everything seems to work just fine without having to patch any core SANE file.</dd>
<dt>Patch &#8211; <a href="http://www.codetrax.org/attachments/download/45/viceoDriver4Sane1.0.14.tar.gz">viceoDriver4Sane1.0.14.tar.gz</a></dt>
<dd><strong>Old</strong> package with Viceo patch for <em>sane-backends 1.0.14</em> and some notes by Jimmy Nguyen about the release. Reading them is recommended.</dd>
</dl>
<p>All versions are available from the development web site&#8217;s <a href="http://www.codetrax.org/projects/viceo-sane-backend/files">download area</a>.</p>
<h4>Installation</h4>
<p>Using the RPM or DEB package (see above for info) is the recommended method of installing. This package has been built in Fedora 8, but, since it is rather generic and does not contain any Fedora-specific information, it should work on any RPM-based distribution.</p>
<h5>Using the RPM</h5>
<p>The package <strong>sane-backends-1.0.18</strong> is a <em>dependency</em>. Make sure you have installed it.</p>
<pre class="console">
# wget http://www.codetrax.org/attachments/download/42/sane-backends-viceo-1.0.18-0.7-rcnst.1.i386.rpm
# rpm -ivh sane-backends-viceo-1.0.18-0.7-rcnst.1.i386.rpm
</pre>
<p>Please make sure you read the Configuration section for instructions on how to setup the scanner.</p>
<h5>Manual installation</h5>
<p>This information has been written with as much detail as possible, if you still have questions, please use the forums.</p>
<p>Note: The compilation of the backend should be performed by a regular user and not root.</p>
<p>First, download and extract the required packages. Although the sane-backends-1.0.18 package is used, we will only use it in order to build the Viceo backend.</p>
<pre class="console">
$ wget ftp://ftp.sane-project.org/pub/sane/sane-backends-1.0.18/sane-backends-1.0.18.tar.gz
$ tar -xzf sane-backends-1.0.18.tar.gz
$ wget http://www.codetrax.org/attachments/download/41/sane-backends-1.0.18-viceo.diff.gz
$ gunzip sane-backends-1.0.18-viceo.diff.gz
</pre>
<p>Patch the sane-backends source code:</p>
<pre class="console">
$ patch -p1 -b -d sane-backends-1.0.18/ < sane-backends-1.0.18-viceo.diff
</pre>
<p>Change to the sane-backends source code top-directory:</p>
</pre>
<pre class="console">
$ cd sane-backends-1.0.18/
</pre>
<p>We only care to build the Viceo backend, so set the <code>BACKENDS</code> environment variable to &#8220;<em>viceo</em>&#8220;.</p>
<pre class="console">
$ export BACKENDS=viceo
</pre>
<p>Compile the backend:</p>
<pre class="console">
$ ./configure --prefix=/usr --sysconfdir=/etc
$ make
</pre>
<p>We perform an installation in a temporary directory (<code>1_test_install</code>). This will help you pick up the correct files for the manual installation later. Also, you do not need root privileges for this.</p>
<pre class="console">
$ mkdir 1_test_install
$ make DESTDIR="$PWD/1_test_install" install
</pre>
<p>Now, SANE and the viceo backend have been temporarily installed in the 1_test_install/ directory.</p>
<p>The following actions need to be performed by root or you can use sudo.</p>
<p>Make sure that <strong>sane-backends</strong> has been installed using your distribution&#8217;s package manager. Then copy the following files to the proper locations:</p>
<pre class="console">
# cp 1_test_install/etc/sane.d/{e1.ini,lut.plg,viceo.conf} /etc/sane.d/
# cp 1_test_install/usr/lib/sane/libsane-viceo.so.1.0.18 /usr/lib/sane/
</pre>
<p>Finally, create a needed symbolic link to libsane-viceo.so.1.0.18.</p>
<pre class="console">
# ln -s /usr/lib/sane/libsane-viceo.so.1.0.18 /usr/lib/sane/libsane-viceo.so.1
</pre>
<p>Update the library database. Run:</p>
<pre class="console">
# ldconfig
</pre>
<p>That will be it.</p>
<h4>SANE Configuration</h4>
<p>The scanner configuration needs to be performed by root or you need to use sudo<br />
The first thing to do is to add the viceo backend in <code>/etc/sane.d/dll.conf</code>. Note that the RPM will not do this, so you need to perform this step manually. Either add the work &#8220;<strong>viceo</strong>&#8221; (without quotes) at the end of <code>/etc/sane.d/dll.conf</code> or use the following command:</p>
<pre class="console">
# echo "viceo" &gt;&gt; /etc/sane.d/dll.conf
</pre>
<p>If your scanner is not connected, please do so now.</p>
<p>Run the following command:</p>
<pre class="console">
# sane-find-scanner
</pre>
<p>Your scanner should be identified:</p>
<pre class="codesnp">
[...]
found USB scanner (vendor=0x0461 [Primax], product=0x0360 [Colorado USB 19200]) at libusb:002:003
[...]
</pre>
<p>Take a note of the vendor and product codes and add a line using the following format to <code>/etc/sane.d/viceo.conf</code>:</p>
<pre class="codesnp">
usb &lt;vendor&gt; &lt;product&gt;
</pre>
<p>For me, that line inside <strong>/etc/sane.d/viceo.conf</strong> should be:</p>
<pre class="codesnp">
usb 0x0461 0x0360
</pre>
<p>Now list the available imaging devices. You scanner should be listed:</p>
<pre class="console">
# scanimage -L
</pre>
<p>And this was the device listing:</p>
<pre class="codesnp">
device `viceo:usb 0x0461 0x0360' is a Visioneer Genius ColorPage-Vivid Pro USB flatbed scanner
</pre>
<h4>Scanning</h4>
<p>You can use the scanner either from the command-line or from within GIMP, provided that you have installed the <strong>xsane-gimp</strong> package.</p>
<p>If you use the scanner from the <strong>command line</strong>, wherever a device name is needed, use the device name that scanimage -L lists. For example:</p>
<pre class="console">
# scanimage -d "viceo:usb 0x0461 0x0360" --mode Color --format=tiff --resolution 200 > z_out.tiff
</pre>
<p>Alternatively, you can set the following environment variable:</p>
<pre class="console">
# export SANE_DEFAULT_DEVICE="viceo:usb 0x0461 0x0360"
</pre>
<p>Please read the SANE documentation for more information.</p>
<h4>Licensing</h4>
<p>The viceo backend is accompanied by two files which were included in the drivers for Windows, <code>e1.ini</code> and <code>lut.plg</code>. Although, you, as the owner of the hardware may use these files since you have paid for them, it is unclear whether there is a problem or not with distributing these files separately from the Windows driver package. The fact that these files are available from the home of the E3 driver v0.6, and are also included in <code>sane-backends-1.0.14-viceo.diff</code>, has led me to the conclusion that there is no problem in distributing these files. So, they are included in the my modified patch and RPM package. Please note that the aforementioned files <code>e1.ini</code> and <code>lut.plg</code> have neither been released nor distributed under the terms of a free license, eg GPL, so <strong>they are not free software</strong>.</p>
<h4>Conclusion</h4>
<p>Although the scanner is pretty old, it performs quite well. The driver won&#8217;t let you use resolutions over 600dpi, but I guess this is acceptable.</p>
<p>This article has been written in a fast pace. I have tried to provide as much detail as possible. If you still need help, please use our forums for your questions.</p>
<p>Happy scanning!</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2008/01/24/viceo-backend-for-sane-with-libusb-support/">Viceo Backend for SANE with libusb support</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2006/12/03/pdf2email-cups-backend/" rel="bookmark">pdf2email CUPS Backend</a></li>
<li><a href="http://www.g-loaded.eu/2005/11/06/meld/" rel="bookmark">Meld&#8230;</a></li>
<li><a href="http://www.g-loaded.eu/2005/10/30/creative-pc-cam-750/" rel="bookmark">Creative PC-CAM Series webcams in linux</a></li>
<li><a href="http://www.g-loaded.eu/2011/03/28/dd-wrt-support-for-wireless-n-routers/" rel="bookmark">DD-WRT support for Wireless N Routers</a></li>
<li><a href="http://www.g-loaded.eu/2006/09/09/kernel-2617-and-lirc_gpio-driver/" rel="bookmark">Kernel 2.6.17 and lirc_gpio driver</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2008/01/24/viceo-backend-for-sane-with-libusb-support/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Email Notifications from a Linux System</title>
		<link>http://www.g-loaded.eu/2007/12/07/email-notifications-from-a-linux-system/</link>
		<comments>http://www.g-loaded.eu/2007/12/07/email-notifications-from-a-linux-system/#comments</comments>
		<pubDate>Fri, 07 Dec 2007 15:07:20 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Notifications]]></category>
		<category><![CDATA[System]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/12/07/email-notifications-from-a-linux-system/</guid>
		<description><![CDATA[This post is not an article about how to receive email notifications from your system, but rather a tip about what should be your very first (No.1) action after a clean installation of a Linux system. It is well known that Linux &#8211; and obviously many other *nix systems, if not all &#8211; are pre-configured [...]]]></description>
			<content:encoded><![CDATA[<p>This post is <strong>not</strong> an article about <em>how to receive email notifications from your system</em>, but rather a <strong>tip</strong> about <em>what should be your very first (No.1) action after a clean installation of a Linux system</em>. It is well known that Linux &#8211; and obviously many other *nix systems, if not all &#8211; are pre-configured to send <strong>email notifications</strong> about various system events. That is <em>errors</em> by default, but if you have installed any log analysis and reporting software, like <a href="http://www2.logwatch.org:81/">logwatch</a> or <a href="http://linux.duke.edu/projects/epylog/">epylog</a> (and others), those notifications might include lengthy <em>security reports</em> or reports about <em>resource usage analysis</em> as well. By default, the recipient of all those messages is <code>root@localhost</code>, as it should be. But, since the <em>root</em> account is not for everyday use, it is one the best practices to <strong>redirect</strong> all root&#8217;s email messages to your everyday user&#8217;s mailbox.<br />
<span id="more-469"></span><br />
Recently, I had cleanly installed Fedora 7 on one of my desktop systems and upgraded to Fedora 8 after a few weeks. The last time I had performed a clean installation must have been 2-2.5 years ago, so I forgot to set the email redirection, but I was almost certain that I had done it, so I never checked. The worst thing is that, during my <a href="http://www.g-loaded.eu/2007/11/18/problems-using-libnotify-for-user-to-user-notifications/">libnotify notification tests</a>, I had set some cronjobs to run <em>every minute</em>. The commands that cron was set to run produced an error and normally the system emailed the output to <em>root</em> after each cron-run. Since I was certain that the email redirection had been set, I never checked root&#8217;s mailbox. The result was 19000+ unread messages inside root&#8217;s <em>mbox file</em> and <em>email spool</em>.</p>
<p>So, since email notifications are preconfigured, the first thing to do after a clean Linux system installation is to set the email redirection. This can be done with the following:</p>
<pre class="console">
# echo "root:   youruser" >> /etc/aliases
# newaliases
</pre>
<p>If it happens that you find root&#8217;s or any other user&#8217;s mailbox with tons of email notifications from your system, you can delete them by entering the console mail client &#8220;<em>mail</em>&#8220;:</p>
<pre class="console">
# mail
</pre>
<p>&#8230;and enter the following command at its prompt:</p>
<pre class="console">
&#038; delete *
</pre>
<p>I guess there are many desktop users out there with their root account&#8217;s mailbox full of system notifications. At least, for desktop systems, there should a note about setting up the redirection of root&#8217;s email to your user&#8217;s mailbox.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/12/07/email-notifications-from-a-linux-system/">Email Notifications from a Linux System</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/11/18/problems-using-libnotify-for-user-to-user-notifications/" rel="bookmark">Problems using libnotify for User to User Notifications</a></li>
<li><a href="http://www.g-loaded.eu/2007/03/05/organizing-mailing-list-messages-with-evolution/" rel="bookmark">Organizing Mailing List messages with Evolution</a></li>
<li><a href="http://www.g-loaded.eu/2006/12/20/selinux-audit-reports-script/" rel="bookmark">SELinux audit reports script</a></li>
<li><a href="http://www.g-loaded.eu/2009/10/12/free-personal-email-certificates-program-discontinued-by-thawte/" rel="bookmark">Free Personal Email Certificates Program discontinued by Thawte</a></li>
<li><a href="http://www.g-loaded.eu/2007/06/23/high-traffic-on-the-email-server/" rel="bookmark">High traffic on the email server</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/12/07/email-notifications-from-a-linux-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Move comments to another post in WordPress</title>
		<link>http://www.g-loaded.eu/2007/11/06/move-comments-to-another-post-in-wordpress/</link>
		<comments>http://www.g-loaded.eu/2007/11/06/move-comments-to-another-post-in-wordpress/#comments</comments>
		<pubDate>Tue, 06 Nov 2007 08:23:18 +0000</pubDate>
		<dc:creator>George Notaras</dc:creator>
				<category><![CDATA[Web Applications]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[Publishing]]></category>
		<category><![CDATA[Resolved]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">http://www.g-loaded.eu/2007/11/06/move-comments-to-another-post-in-wordpress/</guid>
		<description><![CDATA[Moving the comments your readers have submitted under one of your blog posts to another one might sound like a horrible idea at first, but there are times, especially when the number of comments has increased too much, that such an action is required in order to reduce the page loading time. I am aware [...]]]></description>
			<content:encoded><![CDATA[<p>Moving the comments your readers have submitted under one of your blog posts to another one might sound like a horrible idea at first, but there are times, especially when the number of comments has increased too much, that such an action is required in order to reduce the page loading time. I am aware of plugins that can arrange comments in multiple pages, but I am against such solutions because they usually add lots of javascript to the HEAD section of the page, so in the end the page does not load any faster at all. On the other hand, it&#8217;s not that bad after all to kindly point your readers to a secondary blog post, which has been set up in order to host the discussions about the main post. This obviously should not happen at the release time of the post when the discussion might get hot, but rather at a later time, maybe after several months. Anyway, I am not here trying to convince anyone about the pros and cons of such an action. What I care about, as usual, is the technical part: which would be the most efficient way to move the comments from one post to another?<br />
<span id="more-458"></span><br />
There are <strong>two ways</strong> that can make this happen. Each one has its advantages ant disadvantages as outlined below:</p>
<ul>
<li>By directly <strong>manipulating the WordPress database</strong>. This is the quickest and most professional way, but running SQL statements is not everyone&#8217;s cup of tea.</li>
<li>The second way is not actually about moving the comments, but rather about <strong>moving the post itself out of its comments</strong>. This is the simplest of the ways and requires zero knowledge of SQL.</li>
</ul>
<p><strong>Both ways are very safe.</strong></p>
<h4>The SQL Way</h4>
<p>First of all, create a new post as usual and add any amount of content in it. What you will do is to attach the comments from the old page to the new one.</p>
<p>You will <strong>need to know the IDs</strong> of your new and old posts. It might not be possible to determine the post ID from the post&#8217;s URL as it might not be included in the permalink structure you use. In that case, examine the hyperlinks of the posts in question under the &#8220;<em>Manage menu</em>&#8221; in the WordPress administration panel.</p>
<p>In the following SQL queries, substitute <strong>OLD_ID</strong> and <strong>NEW_ID</strong> according to your posts&#8217; IDs.</p>
<p>Transfer the comments with the following statement:</p>
<pre class="codesnp">
UPDATE wp_comments SET comment_post_ID=NEW_ID WHERE comment_post_ID=OLD_ID;
</pre>
<p>That&#8217;s it. The comments have been transfered, but we are not done yet.</p>
<p>WordPress keeps the number of each post&#8217;s comments hard-coded into the post&#8217;s record. This probably serves as a performance booster, but it is necessary to take care of it as well.</p>
<p>Run the following query and take a note of the number in the output. This represents the number of comments under the old post.</p>
<pre class="codesnp">
SELECT comment_count FROM wp_posts WHERE ID=OLD_ID;
</pre>
<p>Assume that the numeric result is <strong>COMCOUNT</strong>.</p>
<p>Then adjust the hardcoded number of comments under the two posts by substituting <strong>COMCOUNT</strong>, <strong>NEW_ID</strong>, <strong>OLD_ID</strong> in the following statements as appropriate:</p>
<pre class="codesnp">
UPDATE wp_posts SET comment_count=comment_count+COMCOUNT WHERE ID=NEW_ID;
UPDATE wp_posts SET comment_count=comment_count-COMCOUNT WHERE ID=OLD_ID;
</pre>
<p>You are set.</p>
<h4>The WordPress Way</h4>
<p>This is called the &#8220;<em>WordPress way</em>&#8221; because everything takes place within the WordPress administration panel. The general idea is to create a new post identical to the old one and change the old post, which actually has the comments, appropriately so that it is considered as a new post by WordPress.</p>
<ol>
<li>First of all, create the new post and add content as appropriate.</li>
<li>Second and <strong>most important</strong>, take a good note of the old post&#8217;s &#8220;<strong>Title</strong>&#8220;, &#8220;<strong>Post Slug</strong>&#8221; and &#8220;<strong>Post Timestamp</strong>&#8220;.</li>
<li><strong>Edit the old post</strong>&#8216;s &#8220;<strong>Title</strong>&#8220;, &#8220;<strong>Post Slug</strong>&#8221; and &#8220;<strong>Post Timestamp</strong>&#8221; (make sure the &#8220;<em>Edit timestamp</em>&#8221; checkbox is checked) to some new values and save it.</li>
<li><strong>Edit the new post</strong>&#8216;s &#8220;<strong>Title</strong>&#8220;, &#8220;<strong>Post Slug</strong>&#8221; and &#8220;<strong>Post Timestamp</strong>&#8221; to the exact values of the old post (remember the <em>note</em> you had taken?) and publish it.</li>
</ol>
<p>Done.</p>
<h4>Conclusion</h4>
<p>This is not a task WordPress users have to accomplish everyday. But, when there is need for it, you will know how to do it. Both ways are safe and complete. Use the one that suits you better.</p>
<div class="cc-block"><em><a href="http://www.g-loaded.eu/2007/11/06/move-comments-to-another-post-in-wordpress/">Move comments to another post in WordPress</a></em>, unless otherwise expressly stated, is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a>. Terms and conditions beyond the scope of this license may be available at <a href="http://www.g-loaded.eu/about/disclaimer-and-license/">www.g-loaded.eu</a>.</div>
<h4>Related Articles</h4>
<ul><li><a href="http://www.g-loaded.eu/2007/02/02/wordpress-tip-schedule-the-publishing-of-a-post/" rel="bookmark">WordPress Tip: Schedule the publishing of a post</a></li>
<li><a href="http://www.g-loaded.eu/2006/05/05/modifying-your-name-in-the-wordpress-comments/" rel="bookmark">Modifying Your Name In The WordPress Comments</a></li>
<li><a href="http://www.g-loaded.eu/2006/01/15/simple-recent-comments-wordpress-plugin/" rel="bookmark">Simple-Recent-Comments WordPress Plugin</a></li>
<li><a href="http://www.g-loaded.eu/2007/02/21/more-themes-using-the-simple-recent-comments-plugin/" rel="bookmark">More Themes using the Simple Recent Comments plugin</a></li>
<li><a href="http://www.g-loaded.eu/2007/11/04/backslashes-inside-pre-html-tags-in-wordpress/" rel="bookmark">Backslashes inside pre HTML tags in WordPress</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.g-loaded.eu/2007/11/06/move-comments-to-another-post-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

