Just a case if you want to know some application or service who is running under specific port :
$ netstat -tulpn | grep :80
Sometimes you need to run with sudo to see all services :
$ sudo netstat -tulpn | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1393/nginx.conf
It turns out that 1393 is the pid of service
docker to start a container from image
$ sudo docker run -itd --name jenkins --publish 8080:8080 --publish 50000:50000 jenkins
docker to get inside the container
$ sudo docker exec -it jenkins bash
Play video headlessly and only audio with command line :
$ mplayer -vo null myvideo.mp4
To describe specific AMI
$ aws ec2 describe-images --image-ids ami-5731123e
To describe instance
$ aws ec2 describe-instances --instance-ids i-1234567890abcdef0
To describe VPCs
$ aws ec2 describe-vpcs
To describe route tables
$ aws ec2 describe-route-tables
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 remote add origin ssh://email@example.com/your-username/your-repo.git
git add .
git commit -am "initial commit"
git push -u origin master
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
Easy way to save session and load it again when you open up rtorrent, so you don’t have to start over again.
Start rtorrent and set the session to some directory:
$ rtorrent -s /tmp
try to load it again:
$ rtorrent -s /tmp
Sometimes you want to know the serial of your laptop that you’re using on ubuntu, use this command:
sudo dmidecode | grep -A 9 "System Information"
sudo dmidecode -s system-product-name
This is how I install python 2.7.13 without erasing the current version of python that exists inside the OS. It is an alternative install.
$ wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
$ tar xvf Python-2.7.13.tar.xz
$ cd Python-2.7.13
$ sudo make altinstall
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.
and put this at the bottom of the file :
Or if you don’t want to be asked for passphrase at all, you can just generate new passphrase with no password.