Friday 6 March 2020

Git Installation and Configuration [Windows]

Install https://git-scm.com/download/win

Steps:-

[1]
Github - Profile settings - SSH and GPG keys

[2]
Checking for existing SSH keys - 
Before you generate an SSH key, you can check to see if you have any existing SSH keys.

Open Git Bash.

Enter ls -al ~/.ssh to see if existing SSH keys are present:


$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist

Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:


  • id_rsa.pub
  • id_ecdsa.pub
  • id_ed25519.pub

If you don't have an existing public and private key pair, or don't wish to use any that are available to connect to GitHub, then generate a new SSH key.

If you see an existing public and private key pair listed (for example id_rsa.pub and id_rsa) that you would like to use to connect to GitHub, you can add your SSH key to the ssh-agent.

[3]
Generating a new SSH key and adding it to the ssh-agent

After you've checked for existing SSH keys, you can generate a new SSH key to use for authentication, then add it to the ssh-agent.

If you don't already have an SSH key, you must generate a new SSH key. If you're unsure whether you already have an SSH key, check for existing keys.

Generating a new SSH key
Open Git Bash.

Paste the text below, substituting in your GitHub email address.


$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This creates a new ssh key, using the provided email as a label.


> Generating public/private rsa key pair.
When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.


> Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".


> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

[4]

Copy SSH key to clipboard from git bash
$ clip < ~/.ssh/id_rsa.pub

[5]

New SSH key
Add Title and Key

[6]

Git global setup
git config --global user.name "name"
git config --global user.email "email"

You are done

Thursday 9 May 2019

How to install Java and set JAVA_HOME Path in Ubuntu [Solved]

$ sudo apt-get update


$ sudo apt-get upgrade

Install OpenJDK 8 on Ubuntu

Press Ctrl + Alt + T to open the terminal and enter the following command mentioned in the box.
$ sudo apt install openjdk-8-jdk


It is also possible to install only the JRE, which you can do by executing sudo apt install openjdk-8-jre.

Set JAVA_HOME Path

All you have to do now is to set the “JAVA_HOME” and “PATH” environment variables and then you are done. Enter the following commands to set your environment variables.

$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

To check whether your JAVA_HOME path has been successfully saved, enter the following command to check.

$ echo $JAVA_HOME

Add JAVA bin directory to the PATH variable

Like we have added JAVA_HOME path, we will now update the PATH variable as well. To do that, enter the following command on the terminal.
$ export PATH=$PATH:$JAVA_HOME/bin

This will append the java bin directory to the existing PATH variable. You can also check the PATH variable by entering the following command
$ echo $PATH

Test JAVA setup

$ java -version

Friday 22 March 2019

Amazon EC2 Instance

How to get started with Amazon EC2
Setting up with Amazon EC2
  • Sign up with AWS
Note -  If you previously signed in to the AWS Management Console using AWS account root user credentials, choose Sign in to a different account. If you previously signed in to the console using IAM credentials, choose Sign-in using root account credentials. Then choose to Create a new AWS account.
To create an AWS account - Open https://aws.amazon.com/ and then choose to create an AWS account.
  • Create an IAM user
To create an IAM user for yourself and add the user to an Administrators group
  1. Use your AWS account email address and password to sign in as the AWS account root user to the IAM console at https://console.aws.amazon.com/iam/.
  2. In the navigation pane of the console, choose Users, and then choose Add user.
  3. For User name, type Administrator
  4. elect the checkbox next to AWS Management Console access, select Custom password, and then type the new user's password in the text box. You can optionally select Require password reset to force the user to create a new password the next time the user signs in.
  5. Choose Next: Permissions.
  6. On the Set permissions page, choose to Add user to group.
  7. Choose Create group.
  8. In the Create group dialog box, for Group name type Administrators.
  9. For Filter policies, select the check box for AWS managed - job function.
  10. In the policy list, select the check box for AdministratorAccess. Then choose Create group.
  11. Back in the list of groups, select the check box for your new group. Choose Refresh if necessary to see the group in the list.
  12. Choose Next: Tags to add metadata to the user by attaching tags as key-value pairs.
  13. Choose Next: Review to see the list of group memberships to be added to the new user. When you are ready to proceed, choose to Create user.
To sign in as this new IAM user 

  • Create a key pair
To create a key pair

  1. Sign in to AWS using the URL that you created in the previous section.
  2. From the AWS dashboard, choose EC2 to open the Amazon EC2 console.
  3. From the navigation bar, select a region for the key pair. You can select any region that's available to you, regardless of your location. However, key pairs are specific to a region; for example, if you see plan to launch an instance in the US East (Ohio) Region, you must create a key pair for the instance in the US East (Ohio) Region.
  4. In the navigation pane, under NETWORK & SECURITY, choose Key Pairs.
  5. Choose Create Key Pair.
  6. Enter a name for the new key pair in the Key pair name field of the Create Key Pairdialog box, and then choose Create. Use a name that is easy for you to remember, such as your IAM user name, followed by -key-pair, plus the region name. For example, me-key-pair-useast2.
  7. If you will use an SSH client on a Mac or Linux computer to connect to your Linux instance, use the following command to set the permissions of your private key file so that only you can read it.
chmod 400 your_user_name-key-pair-region_name.pem
  • Create a Virtual Private Cloud
Amazon VPC enables you to launch AWS resources into a virtual network that you've defined, known as a virtual private cloud (VPC). The newer EC2 instance types require that you launch your instances in a VPC. If you have a default VPC, you can skip this section and move to the next task, Create a Security Group. To determine whether you have a default VPC, open the Amazon EC2 console and look for Default VPC under Account Attributes on the dashboard.
  • Create a Security Group
To create a security group with the least privilege
  1. Choose Security Groups in the navigation pane.
  2. Choose Security Groups in the navigation pane.
  3. Enter a name for the new security group and a description. Use a name that is easy for you to remember, such as your IAM user name, followed by _SG_, plus the region name. For example, me_SG_uswest2.
  4. In the VPC list, select your VPC. If you have a default VPC, it's the one that is marked with an asterisk (*).
  5. On the Inbound tab, create the following rules (choose Add Rule for each new rule), and then choose Create:
    • Choose HTTP from the Type list, and make sure that Source is set to Anywhere (0.0.0.0/0).
    • Choose HTTPS from the Type list, and make sure that Source is set to Anywhere (0.0.0.0/0).
    • Choose SSH from the Type list. In the Source box, choose My IP to automatically populate the field with the public IPv4 address of your local computer. Alternatively, choose Custom and specify the public IPv4 address of your computer or network in CIDR notation. To specify an individual IP address in CIDR notation, add the routing suffix /32, for example, 203.0.113.25/32. If your company allocates addresses from a range, specify the entire range, such as 203.0.113.0/24.
Getting Started with Amazon EC2 Linux Instances

Friday 1 March 2019

Monitoring with Ganglia

Prerequisites
Installing LAMP server

Before starting, you will need to install LAMP on the server. You can install it by running the following command:

user@host:$ sudo apt-get install -y apache2
user@host:$ service apache2 status
OR
Go to http://localhost or http://server-ipA page saying your Apache server is running properly should show up.

user@host:$ sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip
user@host:$ php -v
OR
Go to http://localhost/info.php or http://server-ip/info.php. If php is running in your server, you will receive the following message in your web browser.

Installing Ganglia Server

user@host:$ sudo apt-get install ganglia-monitor rrdtool gmetad ganglia-webfrontend

During installation, you will be asked to restart Apache. Select yes. Depending on your system, you may be asked twice. Select yes again.


Configure Ganglia Master Node
Now you need to copy the ganglia webfrontend apache configuration to correct location using the following command

user@host:$ sudo cp /etc/ganglia-webfrontend/apache.conf /etc/apache2/sites-enabled/ganglia.conf

Now you need to edit the ganglia meta daemon configuration file using the following command

user@host:$ sudo gedit /etc/ganglia/gmetad.conf

change the following
data_source "my cluster" localhost
to
data_source "mach cluster" localhost

Need to edit the master node configuration file using the following command

user@host:$ sudo gedit /etc/ganglia/gmond.conf

change the following

/* If a cluster attribute is specified, then all gmond hosts are wrapped inside 
 * of a <CLUSTER> tag.  If you do not specify a cluster tag, then all <HOSTS> will 
 * NOT be wrapped inside of a <CLUSTER> tag. */ 
cluster { 
  name = "unspecified" 
  owner = "unspecified" 
  latlong = "unspecified" 
  url = "unspecified" 

to

/* If a cluster attribute is specified, then all gmond hosts are wrapped inside 
 * of a <CLUSTER> tag.  If you do not specify a cluster tag, then all <HOSTS> will 
 * NOT be wrapped inside of a <CLUSTER> tag. */ 
cluster { 
  name = "mach cluster" 
  owner = "unspecified" 
  latlong = "unspecified" 
  url = "unspecified" 

/* Feel free to specify as many udp_send_channels as you like.  Gmond 
   used to only support having a single channel */ 
udp_send_channel { 
  mcast_join = 239.2.11.71 
  port = 8649 
  ttl = 1 

to

/* Feel free to specify as many udp_send_channels as you like.  Gmond 
   used to only support having a single channel */ 
udp_send_channel { 
  # mcast_join = 239.2.11.71 
  host = localhost
  port = 8649 
  ttl = 1 

/* You can specify as many udp_recv_channels as you like as well. */ 
udp_recv_channel { 
  mcast_join = 239.2.11.71 
  port = 8649 
  bind = 239.2.11.71 

to

/* You can specify as many udp_recv_channels as you like as well. */ 
udp_recv_channel { 
  # mcast_join = 239.2.11.71 
  port = 8649 
  # bind = 239.2.11.71 

Save and exit the file

Restart Ganglia-monitor, Gmetad and Apache.

user@host:$ sudo systemctl start ganglia-monitor
user@host:$ sudo systemctl start gmetad
user@host:$ sudo systemctl restart apache2

Web Interface

Ganglia should now be set up and accessible at http://localhost/ganglia.






Tuesday 9 October 2018

Git

Ubuntu

$ sudo apt-get update

$ sudo apt-get upgrade

$ sudo apt-get install git

$ git --version



RSA SSH keys



If you already have an RSA SSH key pair to use with GitLab

ssh-keygen -o -f ~/.ssh/id_rsa

If you don't have an existing one, Create a new one 

Go to 

gitlab settings -> SSH keys -> Generate one -> Generating new SSH key pair -> 

ssh-keygen -o -t rsa -C "your.email@example.com" -b 4096

Adding a SSH key to your GitLab account

xclip -sel clip < ~/.ssh/id_rsa.pub

Paste -> Add key

Git global setup
git config --global user.name "name"
git config --global user.email "email"
Create a new repository

git clone <copy_ssh_key>

you can test your setup by running ssh -T git@example.com (replacing example.com with your GitLab domain) and verifying that you receive a Welcome to GitLab message.

If you get this error:-

sign_and_send_pubkey: signing failed: agent refused operation

Permission denied (publickey).

Try:-

$ ssh-add

$ ssh-add -l

Monday 8 October 2018

CUDA, cuDNN and Tensorflow

Installing cuDNN on Linux

1. Installing NVIDIA Graphics Driver

2. Installing CUDA

   2.1 Install repository meta-data -
      sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb

   2.2 Install CUDA public GPG-key

             sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub

   2.3 Update apt repository cache
             sudo apt-get update

   2.4 Install CUDA
             sudo apt-get install cuda

   2.5 Environment setup
             export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}

3  Downloading cuDNN

   3.1 Navigate to your <cudnnpath> directory containing cuDNN Debian file.

   3.2 Install the runtime library, for example:
       sudo dpkg -i libcudnn7_7.0.3.11-1+cuda9.0_amd64.deb

   3.3 Install the developer library, for example:
       sudo dpkg -i libcudnn7-dev_7.0.3.11-1+cuda9.0_amd64.deb

   3.4 Install the code samples and the cuDNN Library User Guide, for example:
       sudo dpkg -i libcudnn7-doc_7.0.3.11-1+cuda9.0_amd64.deb

Check the version of CUDA
cat /usr/local/cuda/version.txt

Check the version of cuDNN
cat /usr/include/cudnn.h | grep CUDNN_MAJOR -A 2

Tuesday 2 October 2018

No module named cv2 in jupyter notebook [SOLVED]

No issues importing cv2 in anaconda environment on terminal.
(TGS-salt-identification) chaumayu@HP-Pavilion:~$ python
Python 2.7.14 |Intel Corporation| (default, Aug  3 2018, 14:28:40)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import cv2
>>> exit()


However when I open Jupyter notebook and execute:-
import cv2
gives following error
-----------------------------------------------------------
ImportError                    Traceback(most recent call last)
-----> 1 import cv2
ImportError : No module named 'cv2' 
Do
sys.path.append('/home/chaumayu/anaconda2/envs/<env-name>/lib/python2.7/site-packages')