Monday, November 26, 2012

How to add gist to blogger

  1. Create a gist e.g.
  2. Create the blog post
  3. switch to html view
  4. Embed a script tag where src attribute is url of the git with .js extension like this
    <script src=""></script>

Create EC2 instance with name

Here's a small bash script to launch an EC2 instance with a particular name. The idea is to launch an instance and get its id from stdout, then apply the name tag to instance. Pretty simple.

instance_id=`ec2-run-instances -n $num_instances -g default -k keyname -t m1.medium -z us-east-1d ami-3d4ff254 | sed -n 2p | awk '{print $2}' `
echo "Created instance with id $instance_id"
ec2addtag $instance_id --tag Name=$instance_name
echo "Renamed instance $instance_id to $instance_name"

Monday, November 19, 2012

apt-get commands

The concept behind apt-get is simple. Repositories are websites that provides access to a bunch of software. Each software is called a package and has a distinct name. To be able to download and install a software(package) you need to know of at least one repo(repository) that provides that software. For this purpose you need to add repositories to your local apt-get sources list. Once you have the repos set up installing software is a piece of cake. Not only can you install software with a single command line but also ensure that it's well set up. apt-get figures out the dependencies of the software and installs them automatically. It manages all the various dependencies of all the software on your machine, letting you concentrate on what you really want which is using the software. Sounds neat doesn't it, its almost too good to be true. Let's see the commands that the above workflow boils down to.

I've borrowed as it is from the following webpage:

Repo addresses are stored in list at /etc/apt/sources.list. This is where apt-get looks for repos to find the software you ask it for. Entries look like this:
deb  [web address] [distribution name][maincontribnon-free]

deb breezy main restrcted

If you add a  repo make you call the following command to update the local apt database with all the available software on the new repo:
apt-get update

To search for a software in local database:
apt-cache search baseutils

Now, to the most important command. Here is how you install stuff:

apt-get install baseutils

Sometimes you may need to install deb packages directly for those times:
dpkg -i gedit-2.12.1.deb

Another useful command is one to list packages on the machine
dpkg -l gcc*

It's also very useful to know what files actually got installed for a particular package, for that: