2013年2月28日 星期四

KVM-VIRSH

Create a domain

sudo virt-install \
        --name [KVM NAME] \
        --ram=2048 \
        --disk [DRIVE(LVM) IMAGE PATH]\
        --network [bridge=[bridged interface]] \
        --nographics  \  #console only
        --location=http://debian.csie.ntu.edu.tw/debian/dists/testing/main/installer-amd64/ \ #installer location
        --extra-args "console=tty0 console=ttyS0,115200nn8" #extra kernel args, attaching console to VM

Delete a domain

sudo virsh undefine [KVM NAME]

Connect to local VM

virsh list --all
virsh console [VM domain name]

dump config to xml

virsh dumpxml [VM guest name]

error: operation failed: Active console session exists for this domain

virsh console --force [VM domain name]

2013年2月22日 星期五

Git Basics


Settings:

git config --global user.name "username"
git config --global user.email "email"
*to check --> git config --list
*config file : ~/.gitconfig

initial:

ssh-keygen -C "username@email.com" -t rsa
* Generate files to .ssh/, public key paste to Github setting

Initialize A Repo:

mkdir
cd
touch README
git add README
git commit -m 'first commit'

Clone A Repo:

git clone [url] [Target Directory]

Staging/Tracking:


git add

Status:


git status
git diff --> changed but not staged
git diff --cache  --> staged


git status -s  (-s --> short)
(
? ? : untracked
A : new
M : Modified but not added
M  : Modified and added
MM : Modified again after added
 D : deleted project file
)

Commit:


git commit -m "[comment]"
git commit -a --> stage everyfile tracked
git commit --amend --> amend a previeous commmit
Ignore files:
.gitignore

Remove File:


git rm
git rm --cached [file] --> remove from staging area

Move File:


git mv [file_from] [file_to]

Commit History:


git log
git log -p --> show diff
git log -2 --> last 2 commit
git log --stat --> brief
git log --pretty --> foramtting
git log --graph --> branch & merge history

Unmodify:


git checkout -- [file]

Remote:


A remote--> repo stored in other computer
origin --> default remote name
git remote -v --> show remote URLs(for the repo)
git remote add [remote-name] [repo URL]
git fetch [remote-name] --> fetch from remote
git pull [remote-name] --> fetch and merge from remote
git push [remote-name] [local-branch-name] --> push to remote
git remote show [remote-name]
git remote rename [old-name] [new-name]
git remote rm [remote-name]


git tag:


git tag --> show tag in cur. repo
git tag -a [tag] -m [comment] --> annot. tag
git tag -s --> signed tag


git alias:


git config --global alias.[alias] '[command]'

Creating new repo for sync w/ github:


*create repo at github first
 *Push to the remote repo
 e.g.:
 git remote add [remote-name] https://github.com/[username]/[githubrepo] ([remote-name] is user defined)
 git commit -m "first commit"
 git push -u [remote-name] master