<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>The Standard Output (bash)</title><link>http://thestandardoutput.com/</link><description></description><atom:link href="http://thestandardoutput.com/tag/bash.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 12 Oct 2015 07:59:00 GMT</lastBuildDate><generator>https://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Tracking down where disk space has gone on Linux</title><link>http://thestandardoutput.com/posts/tracking-down-where-disk-space-has-gone-on-linux/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;When administering Linux systems I often find myself struggling to track down
the culprit after a partition goes full. Here's a solution which relies on
standard Linux commands to find where all that disk space is being consumed.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;du -h / | grep '[0-9\.]\+G'
&lt;/pre&gt;


&lt;p&gt;One caveat: Don't go straight to &lt;code&gt;du /&lt;/code&gt;. Use &lt;code&gt;df&lt;/code&gt; to find the partition that's
hurting you, and then try &lt;code&gt;du&lt;/code&gt; commands.&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>linux</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/tracking-down-where-disk-space-has-gone-on-linux/</guid><pubDate>Tue, 23 Sep 2014 20:03:26 GMT</pubDate></item><item><title>Basic WGET usage examples</title><link>http://thestandardoutput.com/posts/basic-wget-usage-examples/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;If you have ever used a relatively modern flavor of UNIX, you likely used a tool
called &lt;code&gt;wget&lt;/code&gt;. It comes as a standard piece of almost every single UNIX variant,
Linux included. Here are some ways that I use it on a daily basis:&lt;/p&gt;
&lt;h3&gt;Download file&lt;/h3&gt;
&lt;pre class="code literal-block"&gt;wget http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
&lt;/pre&gt;


&lt;h3&gt;Downloading files with different names&lt;/h3&gt;
&lt;pre class="code literal-block"&gt;wget http://ftp.gnu.org/gnu/wget/{wget-1.15.tar.gz,wget-1.15.tar.gz.sig}
&lt;/pre&gt;


&lt;h3&gt;Multiple downloads using different protocols&lt;/h3&gt;
&lt;pre class="code literal-block"&gt;wget http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz ftp://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz.sig
&lt;/pre&gt;


&lt;h3&gt;Using an input file&lt;/h3&gt;
&lt;p&gt;You can use an input file that contains a list of URLs to download, like so:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;wget -i ~/Downloads/urls-for-wget.txt
&lt;/pre&gt;


&lt;h3&gt;Resume incomplete download&lt;/h3&gt;
&lt;p&gt;Sometimes a download is interrupted in the middle. To resume a partial download
use the &lt;code&gt;-c&lt;/code&gt; option, like so:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;wget -c http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
&lt;/pre&gt;


&lt;h3&gt;Download files in the background&lt;/h3&gt;
&lt;p&gt;Using the option &lt;code&gt;-b&lt;/code&gt; sends &lt;code&gt;wget&lt;/code&gt; to the background and also saves the output
to a log file:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;wget -b ~/Downloads/wget-log.txt http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
&lt;/pre&gt;


&lt;h3&gt;Throttling download speeds&lt;/h3&gt;
&lt;p&gt;To limit the download speed, use the &lt;code&gt;--limit-rate&lt;/code&gt; option:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;wget --limit-rate=100k http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
&lt;/pre&gt;


&lt;h3&gt;Performing downloads with authentication&lt;/h3&gt;
&lt;p&gt;Some sites restrict access to content by requiring a username and
password. &lt;code&gt;wget&lt;/code&gt; can handle that:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;wget --user=joeschmoe --password=p4sswOrd! http://ftp.gnu.org/gnu/wget/
&lt;/pre&gt;


&lt;h3&gt;More information&lt;/h3&gt;
&lt;p&gt;Of course, you can mix and match all of these options into a single command,
like so:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;wget -c -b -a ./wget-log --limit-rate=100k http://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
&lt;/pre&gt;


&lt;p&gt;You can also go much further than what I described above. The script below will
check the web page for the latest listed version of wget and then download it
and its signature file if the online version is newer than the local one.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;wget -qN $(wget -qO- http://ftp.gnu.org/gnu/wget/ \
          | grep tar | cut -d\" -f6 \
          | tail -n4 | grep gz \
          | sed "s|^|http://ftp.gnu.org/gnu/wget/|")
&lt;/pre&gt;


&lt;p&gt;For more information, check online or use &lt;code&gt;man&lt;/code&gt; or &lt;code&gt;info&lt;/code&gt;.&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>linux</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/basic-wget-usage-examples/</guid><pubDate>Mon, 24 Feb 2014 08:13:49 GMT</pubDate></item><item><title>Resume interrupted downloads with cURL in Linux</title><link>http://thestandardoutput.com/posts/resume-interrupted-downloads-with-curl-in-linux/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;I have recently been trying to download an ISO of a certain Linux distro, but I
find myself at the wrong end of a crappy connection. I tried downloading it with
both Firefox and Chrome but both choked very early in the process and current
speed would go down to 0 and after a while the connection would just cutoff with
no way to resume the download from where I left off.&lt;/p&gt;
&lt;p&gt;Fear not because [cURL][curl] comes to the rescue. After typing &lt;code&gt;Up-Arrow&lt;/code&gt; and
&lt;code&gt;Enter&lt;/code&gt; more time than I care to admit, I decided to let the computer do the
hard work and automate this thing. So I created a small Bash script called
&lt;code&gt;acurl.sh&lt;/code&gt; (for Automated cURL) that looks like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="x"&gt;export ec=1;&lt;/span&gt;

&lt;span class="x"&gt;while [ &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="nv"&gt;ec&lt;/span&gt;&lt;span class="x"&gt; -gt 0 ]; do&lt;/span&gt;
&lt;span class="x"&gt;    /usr/bin/curl -O -C - &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="x"&gt;1;&lt;/span&gt;
&lt;span class="x"&gt;    export ec=&lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="x"&gt;?;&lt;/span&gt;
&lt;span class="x"&gt;done&lt;/span&gt;

&lt;span class="x"&gt;if [ &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="nv"&gt;ec&lt;/span&gt;&lt;span class="x"&gt; -eq 0 ]; then&lt;/span&gt;
&lt;span class="x"&gt;    echo "Downloaded &lt;/span&gt;&lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="x"&gt;1";&lt;/span&gt;
&lt;span class="x"&gt;fi&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;What's going on above is that I have a while loop that is checking the exit code
of &lt;code&gt;curl&lt;/code&gt;. This exit code is captured by assigning the value of &lt;code&gt;$?&lt;/code&gt; to the
variable &lt;code&gt;$ec&lt;/code&gt;. If &lt;code&gt;curl&lt;/code&gt; exit code is larger than 0 then continue trying to
download the file, which is represented by parameter &lt;code&gt;$1&lt;/code&gt;, from where we left
off, which is accomplished by passing the parameter &lt;code&gt;-C&lt;/code&gt; to &lt;code&gt;curl&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Assuming that the script above is located somewhere in the &lt;code&gt;$PATH&lt;/code&gt;, then using
it is as simple as this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;acurl.sh http://distrodomain.org/downloads/linux-distro-version-platform.iso
&lt;/pre&gt;


&lt;p&gt;This is definitely a brute force approach, but it does the work.&lt;/p&gt;
&lt;p&gt;[curl]: http://curl.haxx.se/ "cURL"&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>debian</category><category>linux</category><category>programming</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/resume-interrupted-downloads-with-curl-in-linux/</guid><pubDate>Mon, 14 Oct 2013 04:59:23 GMT</pubDate></item><item><title>Grepping Multiple Files Recursively</title><link>http://thestandardoutput.com/posts/grepping-multiple-files-recursively/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Recently I was faced with the task of looking for the occurences of a variable
name in all files in a directory recursively. Here is a quick bash incantation
that accomplishes that:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;find . -type f -print0 &lt;span class="p"&gt;|&lt;/span&gt; xargs -0 grep -l variable-name
&lt;/pre&gt;


&lt;p&gt;The above can be understood better if we break it down at the pipe character. To
the left of the pipe we use the &lt;code&gt;find&lt;/code&gt; command to generate a list of file names
recursively starting at the current directory. We use &lt;code&gt;find&lt;/code&gt; with the &lt;code&gt;-print0&lt;/code&gt;
action because we are passing the output to another program via a pipe and this
way the list of file names come out delimited by a null character. Next, we feed
the output of &lt;code&gt;find&lt;/code&gt; to the input of &lt;code&gt;xargs&lt;/code&gt; which will split the long list of
file names into sublists and calls &lt;code&gt;grep&lt;/code&gt; once for every sublist. The &lt;code&gt;grep&lt;/code&gt;
command then filters the list of file names and returns only the ones that
contain the &lt;code&gt;variable-name&lt;/code&gt; string in them.&lt;/p&gt;
&lt;p&gt;Pretty cool, eh?&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>debian</category><category>linux</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/grepping-multiple-files-recursively/</guid><pubDate>Thu, 18 Apr 2013 04:26:25 GMT</pubDate></item><item><title>Quick Note on Bash History Substitution</title><link>http://thestandardoutput.com/posts/quick-note-on-bash-history-substitution/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Expanding the last argument (&lt;code&gt;!$&lt;/code&gt;):&lt;/p&gt;
&lt;pre class="code literal-block"&gt;$&amp;gt; cat .emacs
$&amp;gt; cat !$
&lt;/pre&gt;


&lt;p&gt;Expanding the last command (&lt;code&gt;!!&lt;/code&gt;):&lt;/p&gt;
&lt;pre class="code literal-block"&gt;$&amp;gt; ls -alF /etc
$&amp;gt; !! | less
&lt;/pre&gt;&lt;/div&gt;</description><category>bash</category><category>linux</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/quick-note-on-bash-history-substitution/</guid><pubDate>Sat, 02 Jul 2011 21:01:49 GMT</pubDate></item><item><title>Changing the hostname of a Debian server</title><link>http://thestandardoutput.com/posts/changing-the-hostname-of-a-debian-server/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;I am doing web development using Python on a Linux environment and the plan for
the final product is to be hosted at &lt;a href="http://www.linode.com/," title="Linode"&gt;Linode&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As such, I want to setup a integration test environment that looks a little like
the stuff at Linode and namely, the cheap VM specs that they offer.  So I
created a default VM in &lt;a href="http://www.virtualbox.org/," title="VirtualBox"&gt;VirtualBox&lt;/a&gt;
on my development workstation that looks like the Linode 512 VM. This default VM
is a template whose purpose is to be cloned into other VMs and moved into the
test server for execution. I will go into the software specs (what's installed
in it) some other time.&lt;/p&gt;
&lt;p&gt;Suffice it to say that moving the VM to the test server has 2 caveats that I
haven't quite addressed in a graceful manner yet. One of the issues happens when
I boot the new VM in the test server using the cloned VDI file and it loses the
eth0 network interface. The other issue is related to the hostname of the VM and
I will discuss this here today.&lt;/p&gt;
&lt;p&gt;When I created the default VM on the workstation I chose the hostname
&lt;em&gt;change-hostname&lt;/em&gt; for it in an effort to thwart any inclinations of not changing
such setting. I use debian-based operating systems exclusively and in the case
of the VM, it is a Ubuntu server 10.04. In order to change the hostname in such
machines, you need to follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the &lt;em&gt;/etc/hostname&lt;/em&gt; file with your favorite editor. On Debian-based
    systems this file constains the hostname of the current machine.&lt;/li&gt;
&lt;li&gt;Delete the current name and change it to whatever you like&lt;/li&gt;
&lt;li&gt;Save the file and exit your editor&lt;/li&gt;
&lt;li&gt;Reset the hostname by running the following command:&lt;pre class="code literal-block"&gt;sudo /etc/init.d/hostname start
&lt;/pre&gt;


&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is it... Pretty easy, but I want to automate it a little more; Too many
steps to do manually.&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>debian</category><category>linux</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/changing-the-hostname-of-a-debian-server/</guid><pubDate>Mon, 30 May 2011 17:54:45 GMT</pubDate></item><item><title>How to resize a VirtualBox VDI file</title><link>http://thestandardoutput.com/posts/how-to-resize-a-virtualbox-vdi-file/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;I am running Ubuntu Lucid on my workstation at home, but sometimes I still need
to go back to Windows to get something done that I haven't quite figured out
how to do in Linux yet. For that I am running VirtualBox on the workstation
from which I spin up a Windows 7 VM.&lt;/p&gt;
&lt;p&gt;I initially created the VM with 32 GB of hard drive space. That turned out to
be too little and after the base Win7 OS and a few applications I was using
over 15 GB. So I figured that I needed more hard disk space and I thought that
I could just enlarge the pesky VDI file for the Win7 VM (it stands for Virtual
Desktop Image and that's the default VM image file format used by VBox).&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/gorauskas/5767015885/" title="Win7 VBox VM Before Resize"&gt;&lt;img alt="Win7 VBox VM Before Resize" src="http://farm4.static.flickr.com/3270/5767015885_22f73b1714_m.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Before&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Well, it turns out that &lt;em&gt;in nature&lt;/em&gt; you can't really pick up a hard disk, open
it up, and throw in a new platter. In a &lt;em&gt;virtual&lt;/em&gt; world, however, you get to
play &lt;em&gt;God&lt;/em&gt; and manipulate it any way you choose. All you have to do is clone
and modify your original VDI file. Here's what you need:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;VirtualBox. &lt;a href="http://thestandardoutput.com/2011/05/virtualbox-on-debian-based-distros/," title="Install VBox"&gt;Read this&lt;/a&gt; to install it on a Debian-based Linux distro.&lt;/li&gt;
&lt;li&gt;Windows 7... But any other OS ISO image or disk will do.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://gparted.sourceforge.net/," title="GParted"&gt;GParted&lt;/a&gt;, the Gnome partition
    editor.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Assuming that you already downloaded the GParted ISO, installed VirtualBox and
created some VM of which you want to resize the VDI file, here's how you do it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open a terminal (we'll be using the command line for this).&lt;/li&gt;
&lt;li&gt;Find the VDI file you want to resize. This is usually under &lt;code&gt;~/VirtualBox VMs&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now clone the VDI by issuing the following command:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;VBoxManage clonevdi Win7_64bit.vdi Win7_64bit_Larger.vdi
&lt;/pre&gt;


&lt;p&gt;Where the first file name is the input file and the second file name the
output.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then resize the VDI (I grew mine from 32 to 64 GB):&lt;/p&gt;
&lt;pre class="code literal-block"&gt;VBoxManage modifyvdi Win7_64bit_Larger.vdi --resize 65536
&lt;/pre&gt;


&lt;p&gt;Where the first parameter is the input file name and the resize parameter
takes the new size in megabytes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the graphical VirtualBox manager, create a new VM using the cloned and
    expanded VDI file. I would pay special attention to use the same setting as
    the original VM that you cloned from.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;Now boot the new VM using the GParted ISO image that you downloaded
    earlier. We will use it to resize the partition inside the VDI.&lt;/li&gt;
&lt;li&gt;On the boot screen you will want to choose to boot using the Live GParted
    instance. We will use it to resize the partition in the VDI.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Once the live CD has booted up and the GParted application is running,
    select the partition you want to resize by clicking on it and then click the
    resize button.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/gorauskas/5767015957/" title="GParted Step 1"&gt;&lt;img alt="GParted Step 1" src="http://farm4.static.flickr.com/3332/5767015957_9f81947a7f_m.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then select the handle at the end of the partition and slide it to fill up
    the entire unused space area. Click the resize button.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/gorauskas/5767558446/" title="GParted Step 2"&gt;&lt;img alt="GParted Step 2" src="http://farm4.static.flickr.com/3602/5767558446_cb91feb79a_m.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next click the apply button on the GParted toolbar and watch the magic
    happen. Once done, click close and reboot the VM.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/gorauskas/5767558500/" title="GParted Step 3"&gt;&lt;img alt="GParted Step 3" src="http://farm4.static.flickr.com/3251/5767558500_ac1e56e8ed_m.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The first time you boot after performing the steps above, Windows will
    likely want to check the disk for consistency. Let it happen and Windows
    will reboot itself.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/gorauskas/5767016165/" title="Win7 VBox VM After Resize"&gt;&lt;img alt="Win7 VBox VM After Resize" src="http://farm3.static.flickr.com/2716/5767016165_e390a0ea15_m.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;After&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;After this process, my Windows 7 VM was able to see a much larger drive. Let me
know in the comments if you have questions or suggestions about how to improve
this process.&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>debian</category><category>linux</category><category>virtualbox</category><guid>http://thestandardoutput.com/posts/how-to-resize-a-virtualbox-vdi-file/</guid><pubDate>Sat, 28 May 2011 09:32:29 GMT</pubDate></item><item><title>VirtualBox on Debian-based distros</title><link>http://thestandardoutput.com/posts/virtualbox-on-debian-based-distros/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;There is
&lt;a href="http://www.virtualbox.org/wiki/linux_Downloads" title="Oracle
VirtualBox Install"&gt;a really great write up&lt;/a&gt; on how to install and maintain the latest Oracle VirtualBox
package on a Debian-based Linux distribution.&lt;/p&gt;
&lt;p&gt;Here are the steps in a nutshell:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Add a line to the &lt;code&gt;/etc/apt/sources.list&lt;/code&gt; file:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="k"&gt;deb&lt;/span&gt; &lt;span class="s"&gt;http://download.virtualbox.org/virtualbox/debian&lt;/span&gt; &lt;span class="kp"&gt;lucid&lt;/span&gt; &lt;span class="kp"&gt;contrib&lt;/span&gt; &lt;span class="kp"&gt;non-free&lt;/span&gt;
&lt;/pre&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Download and add the Oracle public key:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
&lt;/pre&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install VirtualBox:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;sudo apt-get update
sudo apt-get install virtualbox-4.0
&lt;/pre&gt;


&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That's basically it... Do refer to the link above for extra details and some
caveats.&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>debian</category><category>linux</category><category>virtualbox</category><category>virtualization</category><guid>http://thestandardoutput.com/posts/virtualbox-on-debian-based-distros/</guid><pubDate>Sat, 28 May 2011 06:35:42 GMT</pubDate></item><item><title>Restoring Installed Packages in Debian</title><link>http://thestandardoutput.com/posts/restoring-installed-packages-in-debian/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;I have an older laptop that runs Ubuntu Linux and one of the issues that comes
up regularly is that Ubuntu releases a new version every 6 months and I usually
flatten the disks on that machine and do a fresh install. The base system is
great and very usable, but there are several packages that I install manually
after the fact, most of them being programming tools. There is a quick way for
you to list out all installed packages and then restore them after upgrading
and I will cover that technique here.&lt;/p&gt;
&lt;p&gt;Note: The instructions listed here are for Debian based distributions that use
.deb based packages.&lt;/p&gt;
&lt;h3&gt;Backing up a list of installed packages&lt;/h3&gt;
&lt;p&gt;In order to list out all installed packages and save them to a text file, you
can do this from the shell:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;dpkg --get-selections &amp;gt; installed-packages.txt
&lt;/pre&gt;


&lt;p&gt;Let's deconstruct the above command:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dpkg&lt;/code&gt; is the Debian package manager&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--get-selections&lt;/code&gt; is the parameter or action that lists all the currently
    installed packages. You can also pass a pattern to this action to generate
    different types of package lists. Look at the man pages for details.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;gt; textfilename.txt&lt;/code&gt; will redirect the standard output to the text file
    specified.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Restoring the list of installed packages&lt;/h3&gt;
&lt;p&gt;When you need to restore the installed packages from a previous state, you can
run the following command from the shell:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;dpkg --set-selections &amp;lt; installed-packages.txt
&lt;/pre&gt;


&lt;p&gt;The command above is a little different and those differences mean:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--set-selections&lt;/code&gt; is the action that sets the package selections using a file
    read in from standard in.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt; textfilename.txt&lt;/code&gt; will read the contents of the file and send them to
    standard in.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Backing up and restoring your package installation list is a really simple
procedure in Debian based distributions. You can even script it out and run it
on a schedule and then save it to a cloud storage service such as Dropbox. Let
me know what you think and if you have a better process.&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>cool stuff</category><category>debian</category><category>linux</category><category>package</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/restoring-installed-packages-in-debian/</guid><pubDate>Thu, 19 May 2011 23:15:40 GMT</pubDate></item><item><title>Mounting a USB Stick in Linux</title><link>http://thestandardoutput.com/posts/mounting-a-usb-stick-in-linux/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;Here is a quick way to mount a USB thumb drive in Linux. Most distros will
recognize the USB stick when you plug it in, but it case they don't then this
command comes in handy:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;sudo mount -t vfat /dev/sdf1 /mnt/cruzer/
&lt;/pre&gt;


&lt;p&gt;Now you can access and browse the contents of the usb stick by change the
current directory to &lt;code&gt;/mnt/cruzer/&lt;/code&gt;. Your mileage may vary and your Linux distro
may have a different file system hierarchy.&lt;/p&gt;&lt;/div&gt;</description><category>bash</category><category>linux</category><guid>http://thestandardoutput.com/posts/mounting-a-usb-stick-in-linux/</guid><pubDate>Thu, 22 Jul 2010 21:50:00 GMT</pubDate></item><item><title>Automating Emacs Build and Install from Source</title><link>http://thestandardoutput.com/posts/automating-emacs-build-and-install-from-source/</link><dc:creator>Jonas Gorauskas</dc:creator><description>&lt;div&gt;&lt;p&gt;A little while back I
&lt;a href="http://blog.theblinkingcursor.org/2010/02/building-and-installing-emacs-from.html"&gt;wrote up my notes&lt;/a&gt;
on how to build and install Emacs from souce on Ubuntu.&lt;/p&gt;
&lt;p&gt;I have now automated the task in the form of the crude script provided
below. The script takes one parameter: &lt;code&gt;gui&lt;/code&gt;. This parameter tells the build
whether you intend to do a GUI or command line only build of Emacs. It also
writes out some messages to a file called &lt;code&gt;emacs-build.log&lt;/code&gt; ... Enjoy!&lt;/p&gt;
&lt;table class="codehilitetable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Building @`date`"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
mkdir ~/emacs-src
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/emacs-src

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Installing pre-requisites"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
apt-get -q -y install build-essential gcc git-core texinfo libncurses5-dev

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; gui &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Installing GUI pre-requisites"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
    apt-get -q -y install libgtk2.0-dev libtiff4-dev libgif-dev libjpeg62-dev libpng12-dev libxpm-dev
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Cloning Emacs Git Repo"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
git clone git://git.savannah.gnu.org/emacs.git

&lt;span class="nb"&gt;cd&lt;/span&gt; ./emacs

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Configuring build"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; gui &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    ./configure
&lt;span class="k"&gt;else&lt;/span&gt;
    ./configure --without-x
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Building source code"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
make
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Installing emacs"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
make install
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Clean up"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/
rm -rf ~/emacs-src
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"All Done!"&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; tee -a ~/emacs-build.log
&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;</description><category>bash</category><category>cool stuff</category><category>emacs</category><category>linux</category><category>programming</category><category>quick hacks</category><guid>http://thestandardoutput.com/posts/automating-emacs-build-and-install-from-source/</guid><pubDate>Fri, 14 May 2010 15:15:00 GMT</pubDate></item></channel></rss>