Linux(Ubuntu14.04LTS)にAndroid Studio 2.1をインストールして、 HelloWorldプロジェクトを作るまでの記録です。
1. ダウンロードとインストール
https://developer.android.com/studio/index.html
へ行きます。
DOWNLOAD ANDROID STUDIO 2.1
をクリックします。

I have read and agree with the above terms and conditions
にチェックを入れるとリンクが活性化するので、
すかさずアドレスをコピーしてwget
で取得します。

wget https://dl.google.com/dl/android/studio/ide-zips/2.1.2.0/android-studio-ide-143.2915827-linux.zip
で、適当なディレクトリで展開
unzip ../tmp/android-studio-ide-143.2915827-linux.zip
android-studio
というディレクトリができ、その中に展開されます。
2. セットアップ
cd android-studio/bin
./studio.sh
以前の環境を引き継ぐか聞かれるので、どちらでもいいです。

Welcome Android Studio
ということでnext

カスタムを選択するほどよく知っていないのでStandardを選択しました。
そしてnext

Verify中
next押すしか無い

エミュレータの設定です KVMがあるのでエミュレータが爆速になるよ!とのことですが、とりえあえずFinishを押します。

インストールが始まりました。

しばらく待つと終わります。

3. Android Studioの起動
3.1. プロジェクト情報の設定
右上に邪魔なものが出ていますが気にせず、
Start a new Android Studio project
を選択します。

プロジェクト情報を入れていきます。
Company Domainですが、パッケージ名ではありませんので注意。
パッケージ名にcom.github.tamurashingo
を使いたい場合は、tamurashingo.github.com
を入れなくてはいけません。(下にパッケージ名が出てますね)

3.2. ターゲットのAndroidデバイスの設定
携帯電話・タブレットの他にいろいろあります。 ここでは携帯電話・タブレットを選択します。
Minimum SDKは使いたいAPIに応じて決定すればいいと思います。
ここでは家にあるAndroidの一番バージョンが低いものに合わせてます。

3.3. Activityの設定
Activityを自動生成して追加するかどうかです。 今回はHelloWorldプロジェクトなので空のActivityを追加します。
他にもいろいろなActivityがあるので、初めて作るときには画面構成など参考になります。

追加したActivityの情報を入れていきます。

すべて完了するとプロジェクトの生成が走ります。

4. エミュレータ
4.1. AVD Managerの起動
プロジェクトを開くとこんな感じの画面になります。

画面上のアイコンを押してAVD Manager(Android Virtual Device Manager)を起動します。

4.2. Virtual Deviceの作成
AVD Managerが起動するとこんな画面になります。 Create Virtual Deviceを押して、デバイスを作っていきます。

4.2.1. ハードウェアの選択
適当なハードウェアを選択します。 PC上で動かすのでのサイズをモニタに合わせたほうがよいので、480x800のデバイスを選択しました。

4.2.2. イメージの選択
常用しているAndroidが5なのでLolipopを選択します(Downloadのリンクを押します)。 ここではRecommendedタブから選びましたが、x86 Imagesなどを選択すると他にもいろいろなバージョンを選択することができます。

まずダウンロードが始まります。 ライセンス条項をよく読んでAcceptを選択しましょう。

ダウンロードが完了するとNextが押せるようになるので、Nextを押します。

4.2.3. 各種設定
各種設定の確認を行います。 AVD Nameは初期状態だと登録できないので、適当な名前にしておきます。

保存中…

できました。

4.3. エミュレータの起動
画面上部の緑の三角形を押すと、ビルドが走りエミュレータ上での実行となります。

実行するデバイスを選択します。 先ほど作ったエミュレータ上のデバイスを選択します。

エミュレータ起動中です。

やりました!起動しました!

ここでロックを外すとアプリが実行されます。

まとめ
画面の指示に従えばOK。 非常に簡単でした。
(キャプチャが大変でした…)