<?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>KarkomaOnline &#187; Tips and Tricks</title>
	<atom:link href="http://www.karkomaonline.com/index.php/tag/tips-and-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.karkomaonline.com</link>
	<description>a Blog for SysAdmins and Unix stuff in general</description>
	<lastBuildDate>Fri, 30 Jul 2010 17:38:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>How to disable IPv6 in Debian</title>
		<link>http://www.karkomaonline.com/index.php/2009/04/how-to-disable-ipv6-in-debian/</link>
		<comments>http://www.karkomaonline.com/index.php/2009/04/how-to-disable-ipv6-in-debian/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 17:08:32 +0000</pubDate>
		<dc:creator>karkoma</dc:creator>
				<category><![CDATA[Linux Debian]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[IPv6]]></category>

		<guid isPermaLink="false">http://www.karkomaonline.com/?p=259</guid>
		<description><![CDATA[Disable IPv6 in Debian]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently installed a new <a href="http://www.openldap.org/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.openldap.org/?referer=');">LDAP</a> server on <a href="http://www.debian.org/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.debian.org/?referer=');">Debian</a> Lenny and I wanted to disable <a href="http://en.wikipedia.org/wiki/IPv6" target="_blank" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/IPv6?referer=');">IPv6</a> as it is unnecessary for me in this moment. With <em>netstat</em> I checked the listening processes:</p>
<blockquote><p>netstat -tunlp</p></blockquote>
<p><code>Active Internet connections (only servers)<br />
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name<br />
tcp        0      0 0.0.0.0:389             0.0.0.0:*               LISTEN      2226/slapd<br />
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2215/sshd<br />
tcp6       0      0 :::389                  :::*                    LISTEN      2226/slapd<br />
tcp6       0      0 :::22                   :::*                    LISTEN      2215/sshd</code></p>
<p>and <em>lsmod</em> showed something like this:</p>
<p><code>Module                  Size  Used by<br />
ipv6                  235364  12<br />
...</code></p>
<p>So, to disable IPv6 I changed <em>/etc/modprobe.d/aliases</em>:<br />
<code>...<br />
# alias net-pf-10 ipv6<br />
# Disable ipv6<br />
alias net-pf-10 off<br />
alias ipv6 off<br />
...</code></p>
<p>I also disabled these lines in <em>/etc/hosts</em> to avoid confusions:</p>
<p><code>...<br />
## The following lines are desirable for IPv6 capable hosts<br />
#::1     localhost ip6-localhost ip6-loopback<br />
#fe00::0 ip6-localnet<br />
#ff00::0 ip6-mcastprefix<br />
#ff02::1 ip6-allnodes<br />
#ff02::2 ip6-allrouters<br />
#ff02::3 ip6-allhosts</code></p>
<p>Finally I restarted the server.</p>
<blockquote><p>shutdown -r now</p></blockquote>
<p>Now the situation is like this:</p>
<blockquote><p>netstat -tunlp</p></blockquote>
<p><code>Active Internet connections (only servers)<br />
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name<br />
tcp        0      0 0.0.0.0:389             0.0.0.0:*               LISTEN      2233/slapd<br />
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2216/sshd</code></p>
<blockquote><p>lsmod|grep ipv6</p></blockquote>
<p><code>...</code></p>
<p>No IPv6.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.karkomaonline.com/index.php/2009/04/how-to-disable-ipv6-in-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSSH: simplifying logins</title>
		<link>http://www.karkomaonline.com/index.php/2007/12/openssh-simplifying-logins/</link>
		<comments>http://www.karkomaonline.com/index.php/2007/12/openssh-simplifying-logins/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 04:21:09 +0000</pubDate>
		<dc:creator>karkoma</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[OpenSSH]]></category>

		<guid isPermaLink="false">http://www.karkomaonline.com/index.php/2007/12/06/openssh-simplifying-logins/</guid>
		<description><![CDATA[OpenSSH provides a per-user configuration file usually located in ~/.ssh/config. This file can help ease your life as Sysadmin. Let&#8217;s say that you frequently connect to a server in this way: ssh admin@boring-servername.boring-domain.com With OpenSSH there is an easy way to do the job. Edit or create a config file: vi ~/.ssh/config and then add [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.openbsd.org/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.openbsd.org/?referer=');">OpenSSH</a> provides a per-user configuration file usually located in ~/.ssh/config. This file can help ease your life as Sysadmin. Let&#8217;s say that you frequently connect to a server in this way:</p>
<blockquote><p>ssh admin@boring-servername.boring-domain.com</p></blockquote>
<p>With OpenSSH there is an easy way to do the job. Edit or create a <em>config</em> file:</p>
<blockquote><p>vi ~/.ssh/config</p></blockquote>
<p>and then add the following:</p>
<blockquote><p> Host servername<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;User admin<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HostName boring-servername.boring-domain.com</p></blockquote>
<p>Where Host is the alias for the remote server you want to connect to, HostName is the full name of the remote server and User is the login name.</p>
<p><strong>References</strong>:</p>
<ul>
<li>man <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.openbsd.org/cgi-bin/man.cgi?query=ssh_config&amp;referer=');">ssh_config </a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.karkomaonline.com/index.php/2007/12/openssh-simplifying-logins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl on the command line</title>
		<link>http://www.karkomaonline.com/index.php/2007/05/perl-on-the-command-line/</link>
		<comments>http://www.karkomaonline.com/index.php/2007/05/perl-on-the-command-line/#comments</comments>
		<pubDate>Sun, 27 May 2007 10:55:59 +0000</pubDate>
		<dc:creator>karkoma</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.karkoma.info/index.php/2007/05/27/perl-on-the-command-line/</guid>
		<description><![CDATA[Perl, you know perl, is not just a jewel for scripting, it &#8216;s also a potent onliner. The magic trick is the diamond: perl -e &#8216;while (){print}&#8217; file1 says perl &#8220;keep on as long as you read something in the standard in&#8221;, in the case of the example above, &#8220;print the line&#8221; &#8230; and each [...]]]></description>
			<content:encoded><![CDATA[<p>Perl, you know perl, is not just a jewel for scripting, it &#8216;s also a potent onliner.</p>
<p>The magic trick is the diamond:</p>
<blockquote><p>perl -e &#8216;while (){print}&#8217; file1</p></blockquote>
<p>says perl &#8220;keep on as long as you read something in the standard in&#8221;, in the case of the example above, &#8220;print the line&#8221; &#8230; and each line goes in the memory but not the whole file: you have a powerful stream editor.</p>
<p>The &#8221; -e&#8221; switch says to perl that what follows in the command line between the single quotations is a script and not a script file name.</p>
<p>But you can have it quicklier :</p>
<blockquote><p>perl -ane &#8216;print&#8217; file1</p></blockquote>
<p>The switches &#8220;-ane&#8221; do the &#8220;while stuff&#8221; for you. It says &#8220;do a while () loop&#8221; (-n) &#8220;and split each record in the @F array&#8221; (-a), I haven&#8217;t used the array yet.<br />
Perl has a difficulty : you can implicit everything. Some guys abuse of it in scripting, like spirits, but it&#8217;s good for an onliner.</p>
<p>This line will print file1. Great (in fact implicit in &#8220;print $_&#8221; ; $_ is the variable where perl puts what you do not explicit). Printing is great but let do some awkish things :</p>
<blockquote><p>perl -ane &#8216;/$m[aiy]/ &amp;&amp; print $_&#8217;</p></blockquote>
<p>That will print the lines that contain $ma, $mi or $my, (have a look at the article from karkoma about sed), patterns in perl are like sed&#8217;s ones but larger. Take a look at the <a href="http://perldoc.perl.org/perlreftut.html" target="_blank" onclick="pageTracker._trackPageview('/outgoing/perldoc.perl.org/perlreftut.html?referer=');">tutorial of perl for pattern</a> or type &#8220;perldoc perlreftut&#8221; if you have installed perldoc.</p>
<p>Well, just let do some sedish thinks :</p>
<blockquote><p>perl -ane &#8216;s/</p>
<p>]*)&gt;//; s/<br />
/<br />
/;print&#8217; file1.html</p></blockquote>
<p>replaces the paragraph in html( by newline () but keeps the options of the paragraph ($1, first match, here the parenthesis are not optional) in an html comment.</p>
<blockquote><p>perl -F&#8221;:&#8221; -ane &#8216;/pascal/ &amp;&amp; print $F[2]&#8216; /etc/passwd</p></blockquote>
<p>will print the UID of user pascal (third field), the field separator is &#8220;:&#8221; (-F$-1òý:òý)</p>
<blockquote><p>perl -ane &#8216;/$m[aiy][^ s]*/ &amp;&amp; print &#8220;line : $. variable : $&amp;n&#8221;&#8216;</p></blockquote>
<p>will print the number of line ($.) where the variables that begin with &#8220;$ma&#8221;, &#8220;$mi&#8221; o &#8220;$my&#8221; and the variables that have matched the description ($&amp;)</p>
<p>bad news, you received this bad MS file with carriage return (r) and newline and you want only the newline :</p>
<blockquote><p>perl -pi.old -ane &#8216;s/rn$/n/;print;&#8217; file1</p></blockquote>
<p>and I obtain directly a file1 without carriage return and I have a backup of the original in file1.old (-pi.old)<br />
you can have a look to a <a href="http://www.unixguide.net/unix/perl_oneliners.shtml" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.unixguide.net/unix/perl_oneliners.shtml?referer=');">quick look at some useful perl onliners</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.karkomaonline.com/index.php/2007/05/perl-on-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing MAC address</title>
		<link>http://www.karkomaonline.com/index.php/2006/10/changing-mac-address/</link>
		<comments>http://www.karkomaonline.com/index.php/2006/10/changing-mac-address/#comments</comments>
		<pubDate>Sun, 22 Oct 2006 09:09:31 +0000</pubDate>
		<dc:creator>karkoma</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.karkoma.info/index.php/2006/10/22/changing-mac-address/</guid>
		<description><![CDATA[The acronym MAC stands for Media Access Control and it is a unique number that identifies your network interface. In an interconnected computer network a so called ARP table relates your IP address to your network interface card&#8217;s MAC. Despite the fact that physical MAC addresses are permanent, it is possible to change this address. [...]]]></description>
			<content:encoded><![CDATA[<p>The acronym MAC stands for Media Access Control and it is a unique number that identifies your network interface. In an interconnected computer network a so called ARP table relates your IP address to your network interface card&#8217;s MAC.</p>
<p>Despite the fact that physical MAC addresses are permanent, it is possible to change this address. In Linux proceed as follows:</p>
<blockquote><p>ifconfig eth0 down<br />
ifconfig eth0 hw ether 01:01:02:02:03:03</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.karkomaonline.com/index.php/2006/10/changing-mac-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatisation of telnet, ftp or ssh</title>
		<link>http://www.karkomaonline.com/index.php/2006/06/automatisation-of-telnet-ftp-or-ssh/</link>
		<comments>http://www.karkomaonline.com/index.php/2006/06/automatisation-of-telnet-ftp-or-ssh/#comments</comments>
		<pubDate>Mon, 12 Jun 2006 02:30:26 +0000</pubDate>
		<dc:creator>karkoma</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.karkoma.info/index.php/2006/06/12/automatisation-of-telnet-ftp-or-ssh/</guid>
		<description><![CDATA[For ftp you have a quick and dirty trick : $ ftp -n yourhost &#60;&#60;-here > quote USER youruser > quote PASS yourpassword > ls > quit > here (you can do a put, get, whatever you want instead of &#8220;ls&#8221;) For telnet similar idea: $ (echo -e &#8220;open yourhostr&#8221;; sleep 2;echo -e &#8220;youruserr&#8221;; sleep [...]]]></description>
			<content:encoded><![CDATA[<p>For ftp you have a quick and dirty trick :</p>
<blockquote><p>$ ftp -n yourhost &lt;&lt;-here<br />
> quote USER youruser<br />
> quote PASS yourpassword<br />
> ls<br />
> quit<br />
> here</p></blockquote>
<p>(you can do a put, get, whatever you want instead of &#8220;ls&#8221;)</p>
<p>For telnet similar idea:</p>
<blockquote><p>$ (echo -e &#8220;open yourhostr&#8221;; sleep 2;echo -e &#8220;youruserr&#8221;; sleep 1; echo -e &#8220;yourpassword&#8221;; sleep 1; echo -e &#8220;unamer&#8221;; sleep 1; echo -e &#8220;exit&#8221;) | telnet
</p></blockquote>
<p>That sound pretty good but &#8230; it does not work on solaris (ok on Linux), and no way for ssh <img src='http://www.karkomaonline.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>So if this shoddy doesn&#8217;t meet your expectations&#8230;</p>
<p>Expect is what you are looking for. Available for GNU-linux, solaris&#8230; MSwindows&#8230;  at http://expect.nist.gov/<br />
For debian do it cool:</p>
<blockquote><p>apt-get install expect</p></blockquote>
<p>I do it with 2 scripts. I&#8217;m sure that you can do better, but that&#8217;s work <img src='http://www.karkomaonline.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<blockquote><p>&#8211; script to call the expect and to make things good looking:<br />
host=$1<br />
psswd=$2<br />
cmd=$3<br />
os=$( ./expectaTion.tcl $host $psswd $cmd| awk &#8220;/$cmd/ &#8220;&#8216;{getline; print}&#8217;|tr -d &#8216;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.karkomaonline.com/index.php/2006/06/automatisation-of-telnet-ftp-or-ssh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux: skip or force fsck on reboot</title>
		<link>http://www.karkomaonline.com/index.php/2006/04/linux-skip-or-force-fsck-on-reboot/</link>
		<comments>http://www.karkomaonline.com/index.php/2006/04/linux-skip-or-force-fsck-on-reboot/#comments</comments>
		<pubDate>Tue, 11 Apr 2006 12:42:20 +0000</pubDate>
		<dc:creator>karkoma</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.karkoma.info/index.php/2006/04/11/linux-skip-or-force-fsck-on-reboot/</guid>
		<description><![CDATA[shutdown is the typical way to bring your system down in a Unix environment. It takes care of notifying logged in users that the system is going down, takes care of sending SIGTERM to processes and more. One interesting feature of shutdown is the ability to force or skip the check and repair of the [...]]]></description>
			<content:encoded><![CDATA[<p><em>shutdown</em> is the typical way to bring your system down in a Unix environment. It takes care of notifying logged in users that the system is going down, takes care of sending SIGTERM to processes and more.</p>
<p>One interesting feature of <em>shutdown</em> is the ability to force or skip the check and repair of the filesystem after a reboot. This is done by two flags that could be passed to the command. According to the man pages:</p>
<p><code>The -f flag means 'reboot fast'. This only creates an advisory file /fastboot which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide not to run fsck(1) since the system has been shut down in the proper way.  After that, the boot  process should remove /fastboot.<br />
</code><br />
<code>The  -F flag means 'force fsck'. This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and  decide to run fsck(1)  with  a  special 'force' flag so that even properly unmounted file systems get checked. After that, the boot process should remove /forcefsck.</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.karkomaonline.com/index.php/2006/04/linux-skip-or-force-fsck-on-reboot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
