Thursday, June 29, 2017

Combine multiple commits into single one - squash your github commits

How to combine multiple commits into single one?

While carrying out a pull request, I ended up with 7 commits in the same pull request. 

I wish to combine all those 7 commits into a single one.( So it is easier to merge and unnecessary  history is removed)

# carrying out squash:

You want to squash all 7 commits into one:

# git rebase -i HEAD~7


It will launch a editor.

# Leave first commit as is.

# From 2 - 7 , change (edit) pick as squash

Now, It will squash the changes and launches editor for  adding commit message. (which actually contains all 7 commit messages).
You can edit the commit message as you wish.

Note: any commit message with # is comment. you need to delete unneeded commit message, else it will only add confusion.

# pushing changes:

Now, I have already pushed all those 7 commits into the github's pull request

So, I need to do force push:

# git push origin  <your branch name>  --force

that's it. :)

You can verify your github pull request. 

markdown preview in google-chrome

You are updating a markdown file and wish to preview how your changes look like.

You can install the below addon:

You can edit markdown file using your favourite editor and  preview your changes live in your chrome browser.

Wednesday, June 21, 2017

Execute ansible-playbook faster

Execute ansible faster:

Set the below value in /etc/ansible/ansible.cfg (or) wherever your configuration file is:

pipelining = True

How this helps? 



Enabling pipelining reduces the number of SSH operations required to execute a module on the remote server, by executing many ansible modules without actual file transfer. This can result in a very significant performance improvement when enabled, however when using “sudo:” operations you must first disable ‘requiretty’ in /etc/sudoers on all managed hosts.
By default, this option is disabled to preserve compatibility with sudoers configurations that have requiretty (the default on many distros), but is highly recommended if you can enable it, eliminating the need for Accelerated Mode:

pipelining = False

Bringup a network interface


If the interface(for eg: eth0) is not UP automatically on system boot, you can temporarily  bring up the interface like:

# dhclient <eth0>


To make it permanent, edit /etc/sysconfig/network-scripts/ifcfg-eth0
Set ONBOOT as yes as:

Here, eth0 is the interface configured.

Tuesday, June 20, 2017

Progress of copy operation

See progress while carrying out copy operation: 

rsync --info=progress2 <source> <destination>

While using cp command, there is currently no direct way to check the can make use of rsync with 'info' flag as above to see the progress of copy operation.

Tuesday, June 13, 2017

port opened in your machine

Check whether a specific port is opened on your machine:

You can make use of "netstat -tuplen"

# netstat -tuplen

For example, httpd (apache) server listens @ 80 port

# netstat -tuplen | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      0          269550     15610/httpd        

Tuesday, June 6, 2017

sudo su to execute bash( and avoid sh)


"sudo su" does not read /etc/bashrc and executes "sh" instead of bash


You need to add the following lines in your /root/.bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc

that's it. 

Monday, June 5, 2017

save username/password while using github

You need to set this to store credentials in disk

git config credential.helper store

First time it will ask for credentials and stored in disk...afterwards same will be used.

This is applicable per github repo.


You can do the same globally by:

git config --global credential.helper store

cat ~/.gitconfig shoud reflect this.


Setting up fresh github repo

Setting up fresh github repo:

1. first visit github and create a user.

2. visit the url  like<test_user>

3. goto "repositories tab" - click on "new"

4. give a name "my_new_repository"

5. Now you should be able to access this link:<test_user>/<my_new_repository>

Now, open terminal and follow the *sample* workflow to freshly initialize your github repo:

echo "# simple_testing" >>

git init

git add

git commit -m "first commit"

git remote add origin<user name>/simple_testing.git

git push -u origin master

Here, simple_testing is the "repo" name created.

Friday, June 2, 2017

github - keep your fork in sync

Keep your fork in sync. with original master :

# Now, you are in your local cloned copy of original GitHub repo:

git checkout master

You wish to update master to be in sync with original GitHub repo.

# First, add github location  as "remote"  (1)  - here *upstream* is the name provided by us:

git remote add upstream

# fetch all branches - see we are using name provided above :)  (2)

git fetch upstream

# apply all changes from original github location to your branch and then play your changes on top


git rebase upstream/master

Now your fork is in sync with original repo :) - but only locally. You need to push the changes to get in sync.

// Check status
$ git status
On branch master
Your branch is ahead of 'origin/master' by 15 commits.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean

// Push all changes you pulled from origin/master
$ git push

// Now check status again
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean

You may check in GitHub UI, whether all changes are in.


(1)  git-remote  add

Adds a remote named <name> for the repository at <url>. The command git fetch <name> can then be used to create and update remote-tracking branches <name>/<branch>.

(2) git-fetch - Download objects and refs from another repository

(3)  git-rebase - Reapply commits on top of another base tip

How to get your local test branch to be in sync with master ? 

So, lets say now your master branch is sync with *upstream* branch.

You want to make all changes you made to master to your localbranch (say testcodebranch).

So, do this:

# git co testcodebranch
# git rebase master

This way testcodebranch will be in sync with master.
It will contain all the commits from the master branch + additional commit from you will be at the TOP.


arp program in linux

arp program is used to read( and do more) arp cache, which is maintaining a table to ip address and corresponding mac address.

In order to get arp program, you need to install net-tools.

What other binaries provided by net-tools?

you can make use "dnf --list repoquery net-tools" command:

output :
# dnf repoquery --list net-tools