<?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/"
	>

<channel>
	<title>Index of /andrejciho &#187; Linux</title>
	<atom:link href="http://www.andrejciho.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andrejciho.com</link>
	<description>Personal blog of a webdeveloper</description>
	<lastBuildDate>Sat, 04 Feb 2012 01:52:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Nightly File Backup</title>
		<link>http://www.andrejciho.com/linux/nightly-file-backup/</link>
		<comments>http://www.andrejciho.com/linux/nightly-file-backup/#comments</comments>
		<pubDate>Sun, 11 Feb 2007 19:03:34 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.andrejciho.com/linux/nightly-file-backup/</guid>
		<description><![CDATA[In a fashion similar to how I described <a href="http://www.andrejciho.com/linux/nightly-mysql-backup/">nightly mysql backup</a>, you can also do nightly file backup.]]></description>
			<content:encoded><![CDATA[<p>In a fashion similar to how I described <a href="http://www.andrejciho.com/linux/nightly-mysql-backup/">nightly mysql backup</a>, you can also do nightly file backup. In this particular example, I used tar with gzip compression because I like to keep the last 7 backups of a website. If I was looking for a script that just backs up one location to another, using <em>rsync</em> with publick key authentication would have been more appropriate and I might talk about that in another post.</p>
<p>As with majority of my posts, I offer nothing new or unique. This is just a script that has been useful to me and if you find it useful, my time and effort in writing this up have been validated.</p>
<pre><code>&lt;code&gt;
#!/bin/sh

#Define your variables here:
SOURCE_DIR=     # e.g. /home/andrej/documents
TARGET_DIR=     # e.g. /mnt/hda7/docbackups
BACKUP_FILENAME=     # e.g. andrejdocs

#  Make sure output directory exists.
if [ ! -d $TARGET_DIR ]; then
    mkdir -p $TARGET_DIR
fi

#  Rotate backups
for j in  6 5 4 3 2 1 0; do
    for i in $TARGET_DIR/$BACKUP_FILENAME.tgz.$j; do
        if [ -e $i ]; then
            mv $i ${i/.$j/}.$(( $j + 1 ));
        fi
    done
done

cd $SOURCE_DIR
tar -cvzf $TARGET_DIR/$BACKUP_FILENAME.tgz.0 *

chmod 600 $TARGET_DIR/$BACKUP_FILENAME.tgz.0

&lt;/code&gt;</code></pre>
<p>In the <a href="http://www.andrejciho.com/linux/nightly-mysql-backup/">Nightly MySQL Backup</a> I briefly talk about how to use cron in scheduling scripts to run periodically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/nightly-file-backup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nightly MySQL Backup</title>
		<link>http://www.andrejciho.com/linux/nightly-mysql-backup/</link>
		<comments>http://www.andrejciho.com/linux/nightly-mysql-backup/#comments</comments>
		<pubDate>Sat, 23 Dec 2006 19:43:05 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.andrejciho.com/linux/nightly-mysql-backup/</guid>
		<description><![CDATA[Simple script to nightly backup your DB and keep last 7 backups.]]></description>
			<content:encoded><![CDATA[<p>For a long time I thought it would be nice to have some kind of automatic regular backup procedure of all of my and my clients&#8217; MySQL databases. I just never quite found the time to research it. Then&#8230; the other day, I REALLY wished I would have had a backup.</p>
<p>Either way, after <em>the</em> other day, I did some research and found out how simple it was. So this post isn&#8217;t really anything new, just a short compilation of what I found online.</p>
<p>(You will need shell access to the hosting server and your hosting company will need to allow you to run scripts and use cron.)</p>
<p><strong>Backup Script</strong></p>
<p>First you&#8217;ll need a backup script that will dump (export, <em>not</em> destroy) the database. I found <a href="http://www.debian-administration.org/articles/218">this one</a> on <a href="http://www.debian-administration.org">www.debian-administration.org</a> and really liked it because it keeps last seven backups &#8211; every time you run it, it adds a new backup and gets rid of the oldest one. I had to add the <em>&#8211;host=</em> part, because my hosting company has the databases spread across multiple servers. So here&#8217;s what I have:</p>
<pre><code>&lt;code&gt;
#!/bin/sh

#Define your variables here:
BACKUP_DIR=
BMYSQL_HOST=
BMYSQL_DBNAME=
BMYSQL_USER=
BMYSQL_PWD=

#  Make sure output directory exists.
if [ ! -d $BACKUP_DIR ]; then
    mkdir -p $BACKUP_DIR
fi

#  Rotate backups
for j in  6 5 4 3 2 1 0; do
    for i in $BACKUP_DIR/$BMYSQL_DBNAME.gz.$j; do
        if [ -e $i ]; then
            mv $i ${i/.$j/}.$(( $j + 1 ));
        fi
    done
done

mysqldump --host=$BMYSQL_HOST --user=$BMYSQL_USER --pass=$BMYSQL_PWD $BMYSQL_DBNAME | gzip &gt; $BACKUP_DIR/$BMYSQL_DBNAME.gz.0
&lt;/code&gt;</code></pre>
<p>Once you have this script in place, make sure it has the right permissions &#8211; my hosting company requires this: -rwx&#8211;x&#8212; with the default group.</p>
<p><strong>Schedule your script to run</strong></p>
<p>I found <a href="http://wiki.dreamhost.com/index.php/Crontab">this helpful wiki article</a> at Dreamhost. So I did the following:</p>
<p><code>crontab -e</code></p>
<p>Borrowing from Dreamhost&#8217;s Handy Crontab Header and adding a line that will run my script at 1:15am every day, this is what I have:</p>
<pre><code>&lt;code&gt;
# minute (0-59),
# |      hour (0-23),
# |      |       day of the month (1-31),
# |      |       |       month of the year (1-12),
# |      |       |       |       day of the week (0-6 with 0=Sunday).
# |      |       |       |       |       commands
15       1       *       *       *       /home/path/to/your/script
&lt;/code&gt;</code></pre>
<p>Save the file (don&#8217;t forget to leave the last line blank). To see if the file saved correctly, just list the crontab file by this command:</p>
<p><code>crontab -l</code></p>
<p>and you should see it printed on the screen. That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/nightly-mysql-backup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Changing permissions on a directory structure</title>
		<link>http://www.andrejciho.com/linux/batch-changing-permissions/</link>
		<comments>http://www.andrejciho.com/linux/batch-changing-permissions/#comments</comments>
		<pubDate>Tue, 27 Jun 2006 15:32:17 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dev.ciho.net/posts/batch-changing-permissions/</guid>
		<description><![CDATA[Mass update permissions on a folder and subfolders]]></description>
			<content:encoded><![CDATA[<p>If you want to change permissions on all files in a directory structure, but leave the folder permissions untouched, here&#8217;s how you would go about it.<br />
<code>find . -type f -exec chmod 640 {} \;</code><br />
Similarly, changing permissions on all folders, but leave the files untouched&#8230;<br />
<code>find . -type d -exec chmod 750 {} \;</code><br />
Or to run anything on the results of <em>find</em>&#8230;<br />
<code>find . -type f -exec <em>any_script</em> {} \;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/batch-changing-permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide comments in conf files and scripts</title>
		<link>http://www.andrejciho.com/linux/no-comment/</link>
		<comments>http://www.andrejciho.com/linux/no-comment/#comments</comments>
		<pubDate>Fri, 23 Jun 2006 00:05:46 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dev.ciho.net/posts/no-comment/</guid>
		<description><![CDATA[Not the beautifulest, but works for me.]]></description>
			<content:encoded><![CDATA[<p>Sometimes when I look at different .conf files or scripts, comments cluttering up my terminal bother me &#8211; I just want to see the real stuff. So I perled myself a little script, added to a pathed folder and now I can just type for example:<br />
<code>nocomment /etc/smb.conf</code><br />
and voila &#8211; no junk in my terminal. And if I want to output that to a file instead of terminal&#8230;<br />
<code>nocomment /etc/smb.conf > /etc/smb.conf.new</code><br />
Here&#8217;s the simple script called <a id="p62" href="http://www.andrejciho.com/wp-content/uploads/2006/06/nocomment.txt">nocomment</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/no-comment/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Printing to network printers in Linux</title>
		<link>http://www.andrejciho.com/linux/network-printing/</link>
		<comments>http://www.andrejciho.com/linux/network-printing/#comments</comments>
		<pubDate>Tue, 06 Jun 2006 13:28:42 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dev.ciho.net/posts/network-printing/</guid>
		<description><![CDATA[Specifically, to a Windows-administered network printer]]></description>
			<content:encoded><![CDATA[<p>First, you have to figure out the IP address of the printer, which you can do by either looking it up in Windows printer properties or walking to the printer and printing the printer configuration from the menu.</p>
<p>If you use the CUPS printer manager at localhost:631, then select the LPD/LPR connection, and print to socket://ipaddress:9100 (e.g. socket://192.168.0.100:9100)</p>
<p>If you use the Gnome printer manager, select the HP JetDirect and type the IP address of the printer in the Host field and 9100 in the Port field</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/network-printing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reimaging your computer with Partimage</title>
		<link>http://www.andrejciho.com/linux/reimaging-with-partimage/</link>
		<comments>http://www.andrejciho.com/linux/reimaging-with-partimage/#comments</comments>
		<pubDate>Fri, 02 Jun 2006 15:04:41 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://dev.ciho.net/posts/reimaging-with-partimage/</guid>
		<description><![CDATA[At your own risk, as always when tinkering with stuff]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="http://www.partimage.org">Partimage</a> is an Open Source software for capturing an image of a drive and restoring it later. It works with ext2/ext3, reiserfs, fat16/32, jfs, xfs, ufs, hpfs, hfs and <strong>ntfs</strong> file systems. You can create/restore images of hard drives, usb memory keys, floppy disks etc. So without further introduction, here&#8217;s how I prefer to use partimage:</p>
<p>I either boot from Knoppix live CD or into one of my Linux installs</p>
<p>Then I make sure that the partition I want to capture into an image file is NOT mounted and the partition where I want to save the image file IS mounted.</p>
<p>Then I open partimage by typing <em>partimage</em></p>
<p>In the top of the screen that comes up&#8230;</p>
<ul>
<li>I choose the partition to save/restore</li>
<li>In the &#8220;Image file to create/use&#8221; field I type in the path of the image file to create or use&#8221; e.g. /mnt/home/andrej/images/XPinstalled.gz</li>
<li>Then I select the action that I want to take &#8211; save or restore &#8211; and hit Next or F5.</li>
</ul>
<p>When saving an image, in the next screen&#8230;</p>
<ul>
<li>I select Gzip compression level</li>
<li>Tell it to split the image files into files whose size is 2037MB</li>
<li>Hit Next or F5</li>
</ul>
<p>When saving an image, in the next screen I sometimes enter description of what I&#8217;m capturing. When I&#8217;m restoring an image I just confirm the image file I&#8217;ve selected.</p>
<p>When I&#8217;m in a command-line mood, to save a partition I type<br />
<code>partimage -z1 -d save /dev/sda2 /mnt/home/andrej/images/XPinstalled.gz</code><br />
&#8230;and to restore it, I type<br />
<code>partimage restore /dev/sda2 /mnt/home/andrej/images/XPinstalled.gz</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/reimaging-with-partimage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repairing Grub (distro independent)</title>
		<link>http://www.andrejciho.com/linux/repairing-grub/</link>
		<comments>http://www.andrejciho.com/linux/repairing-grub/#comments</comments>
		<pubDate>Wed, 03 May 2006 12:24:25 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dev.ciho.net/posts/repair-grub/</guid>
		<description><![CDATA[6 steps, 10 minutes (if you have a Linux Live CD)]]></description>
			<content:encoded><![CDATA[<p>More often than not, whenever I installed grub into my MBR, it got corrupted. Sometimes after 1st reboot, sometimes after 10th. Either way, I stopped putting it there and have written about how to put it elsewhere in a <a href="http://www.andrejciho.com/linux/mbrsafe-dual-boot/">previous post</a>. Here I offer simple instructions how to repair/reinstall grub when it gets corrupted (wherever it&#8217;s installed). It should work in any distro.</p>
<p><strong>1. Boot from a linux liveCD</strong>, such as Knoppix or Gentoo minimal install CD.</p>
<p><strong>2. Mount your file system</strong> (you can substitute &#8220;mylinux&#8221; for whatever you want, just stay consistent)<br />
<code>mkdir /mnt/mylinux<br />
mount /dev/hda5 /mnt/mylinux</code><br />
If you have your file system spread out across more partitions, mount it all inside the /mnt/mylinux. For example:<br />
<code>mount /dev/hda3 /mnt/mylinux/boot</code><br />
<strong>3. Mount the /dev and /proc.</strong> These are dynamically generated by your liveCD and need to be present in your file system in a second &#8211; so don&#8217;t skip this step.<br />
<code>mount -t proc none /mnt/mylinux/proc<br />
mount -o bind /dev /mnt/mylinux/dev</code><br />
<strong>4. Chroot to your file system</strong><br />
<code>chroot /mnt/mylinux /bin/bash</code><br />
<strong>5. Generate /etc/mtab</strong> (dynamically generated list of mounted file systems)<br />
<code>grep -v rootfs /proc/mounts > /etc/mtab</code><br />
<strong>6. Reinstall grub</strong> to your boot partition<br />
<code>grub-install /dev/hda3</code><br />
or to your MBR but I don&#8217;t recommend it:<br />
<code>grub-install /dev/hda</code><br />
or manually&#8230;<br />
<code>grub</code><br />
NOTE: If you&#8217;re using Windows&#8217; boot.ini to load your linux, you&#8217;re going to have to re-dd your 512-byte bootsector file (see my <a href="http://www.andrejciho.com/linux/fix-bootloader/">previous post</a> if you need instructions)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/repairing-grub/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>High-pitch Noise on Laptop</title>
		<link>http://www.andrejciho.com/linux/high-pitch-laptop/</link>
		<comments>http://www.andrejciho.com/linux/high-pitch-laptop/#comments</comments>
		<pubDate>Sat, 25 Mar 2006 15:18:52 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dev.ciho.net/posts/high-pitch-laptop/</guid>
		<description><![CDATA[Some older latitude models have the noise]]></description>
			<content:encoded><![CDATA[<p>Do you hear a high pitch noise when your laptop is Linux, but not when it&#8217;s in Windows? Fix is easy &#8211; you just need to add another kernel variable you pass to your kernel in your bootloader .conf file: <strong>idle=halt</strong></p>
<p>So my grub.conf now looks something like this:<br />
<code>timeout 3<br />
default 0<br />
title Gentoo 2.6.13-r3<br />
root(hd0,2)<br />
kernel /boot/kernel-2.6.13-gentoo-r3 root=/dev/sda3 idle=halt<br />
title Gentoo 2.6.14-r5<br />
root (hd0,8)<br />
kernel /boot/kernel-2.6.14-gentoo-r5 root=/dev/sda9 idle=halt<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/high-pitch-laptop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mounting a CD iso</title>
		<link>http://www.andrejciho.com/linux/mount-iso/</link>
		<comments>http://www.andrejciho.com/linux/mount-iso/#comments</comments>
		<pubDate>Thu, 23 Mar 2006 16:01:13 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://dev.ciho.net/2006/03/mount-iso/</guid>
		<description><![CDATA[Read an ISO as if it was a CD in your drive]]></description>
			<content:encoded><![CDATA[<p><strong>In Linux</strong><br />
<code>mount -o loop -t iso9660 filename.iso /mnt/iso</code><br />
<strong>For Windows (XP)</strong>&#8230;</p>
<p>&#8230;you&#8217;ll need to download a tool that does this :) There&#8217;s an <a href="http://download.microsoft.com/download/7/b/6/7b6abd84-7841-4978-96f5-bd58df02efa2/winxpvirtualcdcontrolpanel_21.exe">unofficial one</a> from Microsoft that I&#8217;ve been using and it works well. Make sure you read the Readme file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/mount-iso/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Duplicating a CD using dd</title>
		<link>http://www.andrejciho.com/linux/cd-copying/</link>
		<comments>http://www.andrejciho.com/linux/cd-copying/#comments</comments>
		<pubDate>Thu, 23 Mar 2006 14:20:16 +0000</pubDate>
		<dc:creator>Andrej</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://dev.ciho.net/2006/03/cd-copying/</guid>
		<description><![CDATA[No more unusable old disks - make a copy while new]]></description>
			<content:encoded><![CDATA[<p>This works beautifully no matter what kind of protection a CD might have. I&#8217;m not suggesting this for breaking copyright laws, just so that you can play your favorite game from a CD forever, without ruining the original disk. So here&#8217;s the complicated process explained step-by-step:</p>
<p>Create an ISO file:<br />
<code>dd if=/dev/hdc1 of=$HOME/yourcd.iso</code><br />
And then burn another CD using this ISO file using your favorite CD-burning software.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andrejciho.com/linux/cd-copying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

