<?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>Sérgio's blog &#187; Shell</title>
	<atom:link href="http://www.smachado.com/category/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.smachado.com</link>
	<description>About computers, software, gadgets, programming and more....</description>
	<lastBuildDate>Sun, 16 May 2010 20:40:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Windows: checking file integrity with sha1 and/or md5</title>
		<link>http://www.smachado.com/2009/08/windows-checking-file-integrity-with-sha1-andor-md5/</link>
		<comments>http://www.smachado.com/2009/08/windows-checking-file-integrity-with-sha1-andor-md5/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 16:16:12 +0000</pubDate>
		<dc:creator>smachado</dc:creator>
				<category><![CDATA[Shell]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.smachado.com/?p=112</guid>
		<description><![CDATA[Some Internet available software, normally free software, provides a checksum for file integrity testing.
What is this for? By checking that the checksum of the downloaded file matches the checksum provided on the source web site you&#8217;ll have a guarantee that the file was not modified (hacked) &#8211; unless the web site checksum was too..
So on [...]]]></description>
			<content:encoded><![CDATA[<p>Some Internet available software, normally free software, provides a checksum for file integrity testing.</p>
<p>What is this for? By checking that the checksum of the downloaded file matches the checksum provided on the source web site you&#8217;ll have a guarantee that the file was not modified (hacked) &#8211; unless the web site checksum was too..</p>
<p>So on windows how do you verify this?</p>
<p>There&#8217;s a tool (fciv.exe) provided by Microsoft(r) that can compute sha1 and md5 checksums. You can download it at <a title="http://support.microsoft.com/kb/841290" href="http://support.microsoft.com/kb/841290" target="_blank">http://support.microsoft.com/kb/841290</a>.</p>
<p>After downloading it, you can extract it to c:\windows\ to make the command widely available.</p>
<p>Next you can verify the checksum of a downloaded file, say for example the <a title="http://www.gnupg.org/download/index.en.html" href="http://www.gnupg.org/download/index.en.html" target="_blank">gnupg installation package for windows</a>. On the web site the sha1 checksum was published. Let&#8217;s verify it:</p>
<pre>C:\external\Software\gnupg&gt;fciv gnupg-w32cli-1.4.9.exe -sha1
//
// File Checksum Integrity Verifier version 2.05.
//
c2efad983dfe50e6d8007257bad2c76604be389a gnupg-w32cli-1.4.9.exe</pre>
<p>Great, it matches it so the file has it&#8217;s integrity intact.</p>
<p>To make things easier we can create the commands sha1sum and md5sum which are normally the standard command names to check sha1 and md5.</p>
<p>Let&#8217;s create 2 batch files, for sha1 let&#8217;s put the following contents and save it as c:\windows\sha1sum.bat:</p>
<pre>@echo off
fciv %1 -sha1</pre>
<p>and for md5 let&#8217;s put the following contents and save it as c:\windows\md5sum.bat:</p>
<pre>@echo off
fciv %1</pre>
<p>Now we can compute the checksums by calling these commands:</p>
<pre>C:\external\Software\gnupg&gt;sha1sum gnupg-w32cli-1.4.9.exe
//
// File Checksum Integrity Verifier version 2.05.
//
c2efad983dfe50e6d8007257bad2c76604be389a gnupg-w32cli-1.4.9.exe

C:\external\Software\gnupg&gt;md5sum gnupg-w32cli-1.4.9.exe
//
// File Checksum Integrity Verifier version 2.05.
//
d90854104edcb72149472a99a9392d4e gnupg-w32cli-1.4.9.exe</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.smachado.com/2009/08/windows-checking-file-integrity-with-sha1-andor-md5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash: window size is too short, how do I change it?</title>
		<link>http://www.smachado.com/2009/08/bash-window-size-is-too-short-how-do-i-change-it/</link>
		<comments>http://www.smachado.com/2009/08/bash-window-size-is-too-short-how-do-i-change-it/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 15:56:42 +0000</pubDate>
		<dc:creator>smachado</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.smachado.com/?p=106</guid>
		<description><![CDATA[So I&#8217;m logged on to a Linux server using Bash shell over an ssh connection using Poderosa client.
When I time a long command for some reason the cursor at some point moves over to the beginning of the same line overwriting the command and everything becomes a mess. This is specially annoying while typing something [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;m logged on to a Linux server using Bash shell over an ssh connection using Poderosa client.</p>
<p>When I time a long command for some reason the cursor at some point moves over to the beginning of the same line overwriting the command and everything becomes a mess. This is specially annoying while typing something you would like to cut and paste on an email for example.</p>
<p>So, what&#8217;s going on?</p>
<p>Bash has a variable that reports the number of columns setup:</p>
<pre>$ echo $COLUMNS
80</pre>
<p>Interesting, it is configured for 80 columns but my terminal window has 137 columns. Why is that?</p>
<p>There&#8217;s a Bash setting that will adapt the window size after each command:</p>
<dl>
<blockquote><dt><code>checkwinsize</code> </dt>
<dd>If set, Bash checks the window size after each command and, if necessary, updates the values of     <code>LINES</code> and <code>COLUMNS</code>. </dd>
</blockquote>
</dl>
<p>Let&#8217;s see what is it&#8217;s current value:</p>
<pre>$ shopt -p | grep checkwinsize
shopt -u checkwinsize</pre>
<p>That means it is disabled&#8230; Let&#8217;s enable it:</p>
<pre>$ shopt -s checkwinsize</pre>
<p>Now it is enable. Let&#8217;s check the COLUMNS value now:</p>
<pre>$ echo $COLUMNS
137</pre>
<p>Great!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smachado.com/2009/08/bash-window-size-is-too-short-how-do-i-change-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash: send a running process to background</title>
		<link>http://www.smachado.com/2009/02/bash-send-a-running-process-to-background/</link>
		<comments>http://www.smachado.com/2009/02/bash-send-a-running-process-to-background/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 10:03:31 +0000</pubDate>
		<dc:creator>smachado</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.smachado.com/?p=19</guid>
		<description><![CDATA[Say you start a process and you forget to add the &#38; character at the end of the line to send it to the background. You don&#8217;t need to restart the process if you&#8217;re using bash (and probably other shells &#8211; check the documentation of the one you&#8217;re using).
To send the running process to the [...]]]></description>
			<content:encoded><![CDATA[<p>Say you start a process and you forget to add the &amp; character at the end of the line to send it to the background. You don&#8217;t need to restart the process if you&#8217;re using bash (and probably other shells &#8211; check the documentation of the one you&#8217;re using).</p>
<p>To send the running process to the background so that you get the shell prompt back to enter more commands you have to press CTRL+Z while the process is running. The process will be temporarily suspended until you send it to the foreground with the <em>bg [jobspec]</em> command.</p>
<p>Let&#8217;s see an example:</p>
<p>[root@localhost log]# tail -f cron<br />
Feb 26 11:01:01 localhost CROND[5731]: (root) CMD (run-parts /etc/cron.hourly)<br />
Feb 26 12:01:01 localhost CROND[5743]: (root) CMD (run-parts /etc/cron.hourly)<br />
Feb 26 13:01:01 localhost CROND[5836]: (root) CMD (run-parts /etc/cron.hourly)<br />
Feb 26 14:01:01 localhost CROND[6097]: (root) CMD (run-parts /etc/cron.hourly)<br />
Feb 26 15:01:01 localhost CROND[6132]: (root) CMD (run-parts /etc/cron.hourly)<br />
Feb 27 04:26:15 localhost crond[2844]: (CRON) STARTUP (1.2)<br />
Feb 27 04:26:16 localhost crond[2844]: (CRON) INFO (running with inotify support)<br />
Feb 27 04:26:20 localhost anacron[2912]: Anacron 2.3 started on 2009-02-27<br />
Feb 27 04:26:20 localhost anacron[2912]: Will run job `cron.daily&#8217; in 65 min.<br />
Feb 27 04:26:20 localhost anacron[2912]: Jobs will be executed sequentially<br />
^Z<br />
[1]+  Stopped                 tail -f cron<br />
[root@localhost log]# jobs -l<br />
[1]+  4107 Stopped                 tail -f cron<br />
[root@localhost log]# bg 1<br />
[1]+ tail -f cron &amp;<br />
[root@localhost log]# jobs -l<br />
[1]+  4107 Running                 tail -f cron &amp;<br />
[root@localhost log]# fg 1<br />
tail -f cron<br />
^C<br />
[root@localhost log]# jobs -l<br />
[root@localhost log]#</p>
<p>As you see when you press CTRL+Z (or ^Z) the process is suspended (stopped). You can see the list of jobs and their state by running <em>jobs -l</em>. This job was given the number <em>1</em>. We can then send it to the background with <em>bg 1</em> or bring it back to the foreground with <em>fg 1</em>. At the end I kill the process by pressing CTRL+C (^C).</p>
<p>You can stop the job with ^Z and then send it to the background using <em>bg </em>with no additional argument<em>s.</em> Actually you can use the character % as a job name. Let&#8217;s see the following example:</p>
<p># tail -f test1<br />
line 1<br />
line 2<br />
^Z<br />
[1]+  Stopped                 tail -f test1<br />
# %1 &amp;<br />
[1]+ tail -f test1 &amp;<br />
# jobs -l<br />
[1]+  3855 Running                 tail -f test1 &amp;<br />
# tail -f test2<br />
file 2 line 1<br />
file 2 line 2<br />
^Z<br />
[2]+  Stopped                 tail -f test2<br />
# %% &amp;<br />
[2]+ tail -f test2 &amp;<br />
#<br />
# jobs -l<br />
[1]-  3855 Running                 tail -f test1 &amp;<br />
[2]+  3857 Running                 tail -f test2 &amp;<br />
# %-<br />
tail -f test1<br />
^Z<br />
[1]+  Stopped                 tail -f test1<br />
# jobs -l<br />
[1]+  3855 Stopped                 tail -f test1<br />
[2]-  3857 Running                 tail -f test2 &amp;<br />
# kill %1</p>
<p>[1]+  Stopped                 tail -f test1<br />
# kill %2<br />
[1]+  Terminated              tail -f test1<br />
# jobs -l<br />
[2]+  3857 Terminated              tail -f test2<br />
# jobs -l</p>
<p>The + flag on the output of <em>jobs -l</em> indicates the <em>current</em> job and the &#8211; flag indicates the <em>previous</em> job. The %% and %+ <em>names</em> refer to the <em>current</em> job while %- refers to the <em>previous</em> job. So instead of <em>fg 1</em> you can use <em>%1.</em> And instead of <em>bg 1</em> you can use <em>%1 &amp;</em>. And so on&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.smachado.com/2009/02/bash-send-a-running-process-to-background/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
