Archive for the ‘Unix’ Category

Hard link vs soft link

The following figure explains hardlink, softlink and    their association with inode. The figure is adopted from [1]









Categories: Uncategorized, Unix

su vs sudo command

The command su (short for substitute user) is used to switch user in UNIX environment. When we issue su command  with/without a username, it switches to root or otherwise user mentioned.


On the other hand, sudo command run a single command with root privilege. By leveraging sudo, the system discourages to switch to root user when it is not absolutely necessary.


We can su with -c  to achieve the same as sudo command.



#Prosunjit Biswas#


Categories: Uncategorized, Unix

Set up Pretty Good Privacy (PGP) Key in Ubuntu



Pretty Good Privacy (PGP) is a data encryption and decryption computer program that provides cryptographic privacy and authentication for data communication. PGP is often used for signing, encrypting, and decrypting texts, e-mails, files, directories, and whole disk partitions and to increase the security of e-mail communications. [1]


In our case we would use GNU OpenPGP implementation which is Gnu pg or gpg. GnuPG allows to encrypt and sign your data and communication, features a versatile key management system as well as access modules for all kinds of public key directories. [2]

Generate PGP keys


# Command to create gpg key

gpg  –gen-key


Before you hit this command, you may need to install rng-tools. During the key generation operation, your system tells you that no more random bytes are available and that it needs to collect more entropy, and you are stuck. rng-tools helps in this regards. First we need to install rng-tools and need to updated /etc/default/rng-tools file  to add the line HRNGDEVICE=/dev/urandom. Follow [3] for details.


sudo apt-get install rng-tools

#start the service

sudo /etc/init.d/rng-tools start



Now, gpg  –gen-key would possibly work successfully.


Screenshot 2016-03-28 22.20.55.png

Generating pgp key



Publish PGP key:



To publish GPG keys in ubuntu server, run following commands

gpg --keyserver --send-keys 47BBA6FC
Your public key (fingerprint) would look something like following

Screenshot 2016-03-28 22.29.30.png

Listing pgp fingerprint


Finally, you can make sure your public key exists on the ubuntu server by
searching it with your email address.



Screenshot 2016-03-28 22.31.26.png

Searching gpg key by email address


Now hopefully, you can find your pgp keys on the server. So, finally, you
a public key of your own published.


Export and Import Public and Private keys:

#export public key

gpg –export -a “name of key holder” > public.key

#import private key

gpg –export-secret-key -a”name of key holder” > private.key








Categories: Uncategorized, Unix

Linux Performance tools

December 15, 2015 Leave a comment

Linux performance tools.





Categories: Unix

Verifying python package requirements for OpenStack Services

Each OpenStack service (e.g. keystone, swift, nova) has specific python package requirements. Messing up with versions of these packages and/or version may kill one of your beautiful days. Before it kills yourself, help yourself.


Each OpenStack service has a listing of required packages and its  minimum and maximum supported version. For example, to see what package and its version are required for OpenStack Swift service go to Swift Installed directory (in my case /opt/stack/swift) and cat the requirement.txt file.


Screenshot 2015-12-07 16.29.07

Additionally, to check installed python packages follow the command

pip list  # show all installed packages.

pip list | grep greenlet # show version of installed greenlet package

Now, if you have a wrong version of greenlet installed, uninstall the current greenlet and install the correct one.


#uninstall current greenlet

sudo pip uninstall greenlet  # remove current greenlet

# install greenlet as per version shown in requirement.txt file.

sudo pip install==0.3.1

Categories: openstack, Unix

multiple search inside VIM

There are two simple ways to highlight multiple words in vim editor.

  1. Go to search mode i.e. type ‘/‘ and then type \v followed by the words you want to search separated by ‘|‘ (pipe).
    Ex: /\vword1|word2|word3
  2. Go to search mode and type the words you want to search separated by ‘\|‘.
    Ex: /word1\|word2\|word3


Categories: Unix

Find keys from a JSON file

Find all keys of a json file.

Assume, the Input JSON file is  tweet1.json which is actually a  Twitter Tweet.

Finding all the JSON keys of the JSON file:

grep  ‘[a-z]*[:]’ tweet1.json | awk ‘{print $1}’

Finding all the unique keys of the JSON file:

grep  ‘[a-z]*[:]’ tweet1.json | awk ‘{print $1}’| sort  | uniq -c

Find all the duplicate keys of the JSON file:

   grep  ‘[a-z]*[:]’ tweet1.json | awk ‘{print $1}’| sort  | uniq -d -c

Categories: Unix