Git cheatsheet

list branch

git branch

move to another branch

git checkout your-branch

hard reset branch

git reset --hard origin/master

create new branch

git checkout -b new-branch

delete local branch

git branch -D your-branch

merge from develop to master

git merge develop

init on existed project and push master for the first time

git init
git remote add origin ssh://git@bitbucket.org/your-username/your-repo.git
git add .
git commit -am "initial commit"
git push -u origin master

Start VM in virtualbox headless mode

I want to start my VM virtualbox but without the GUI interface, cause if I need to get the access to my VM, I just can SSH into it. So it won’t need any GUI interface and I don’t have to open up Virtualbox first to start my VM.

This is a simple command line to start up your VM in headless mode, once it gets started, you can just SSH into your VM.

VBoxManage startvm myubuntu --type headless

Poweroff your VM with command line:

VBoxManage controlvm myubuntu poweroff

Or you can just init 0 in your VM when you’re done, LOL


Setup SSH key passphrase only ask once

Sometimes it’s annoying when you’re trying to work with your project and whenever you need to enter your key passphrase. So I wanna make this passphrase prompt ask only once.

vim ~/.bash_profile

and put this at the bottom of the file :

eval $(ssh-agent)
ssh-add

Or if you don’t want to be asked for passphrase at all, you can just generate new passphrase with no password.


Traceroute command line in ubuntu

This is how to install traceroute in ubuntu machine

apt-get install traceroute

And how to use it :

$ traceroute google.com
traceroute to google.com (74.125.68.100), 30 hops max, 60 byte packets
 1  192.168.100.1 (192.168.100.1)  2.281 ms  2.378 ms  2.398 ms
 2  61.5.80.1 (61.5.80.1)  9.254 ms  9.357 ms  9.378 ms
 3  121.subnet125-160-11.speedy.telkom.net.id (125.160.11.121)  8.980 ms  8.966 ms  8.941 ms
 4  61.94.171.69 (61.94.171.69)  9.611 ms  9.630 ms  9.598 ms
 5  180.240.193.238 (180.240.193.238)  23.731 ms 180.240.193.46 (180.240.193.46)  32.981 ms  33.343 ms
 6  180.240.193.237 (180.240.193.237)  29.036 ms 180.240.193.45 (180.240.193.45)  41.533 ms 180.240.193.237 (180.240.193.237)  24.494 ms
 7  180.240.204.29 (180.240.204.29)  20.850 ms 180.240.204.49 (180.240.204.49)  20.496 ms 180.240.204.29 (180.240.204.29)  20.846 ms
 8  72.14.223.88 (72.14.223.88)  21.115 ms  21.529 ms  24.440 ms

Setup read and write samba share in vagrant ubuntu

I use vagrant for daily development, now vagrant has this directory mounted when we setup vagrant at the first time. But sometimes I’d like to mount my own directory to my local machine.

This is the way I create samba share in my vagrant :

apt-get install samba samba-common

Create user for project

useradd -m user1 -d /srv/myproject

Open samba config file

vim /etc/samba/smb.conf

Put the new config below at the very bottom

[myproject]
browseable = yes
path = /srv/myproject
guest ok = yes
public = yes
read only = no
create mask = 0644
directory mask = 0755
force user = user1

Restart samba :

service samba restart

What’s next :

Mount samba share with command line


Mount samba share with command line

When you work with vagrant, you might want your project folder to be mounted on some directory on your local. You can do that easily with file manager, but here’s my favorite way to mount my samba share in vagrant to my directory on my local. So I can work on that.

Before you do this, you might want to get your current user id, so your project is accessible. And make sure the destination directory is already exists.

sudo mount -t cifs -o uid=1001,gid=1001 //192.168.56.11/kripikpasta /tmp/kripikpasta