Install JDK9 on Linux Mint

In this article we will see how we can install JDK9 i.e. Oracle Java 9 on Linux mint version.

Execute the below commands in sequence on Linux Mint machine:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java9-installer

While executing the above you will see the get the aggrement options where we need to click ok and proceed. After the above steps setup Java environment using PPA repository

Exeucte the below command to install the package :

sudo apt-get install oracle-java9-set-default

Now let us check our Java version by exeucting the below commands:

oracle@dev-VirtualBox ~ $ java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
oracle@dev-VirtualBox ~ $ 

Thank you for reading my blog , please feel free to leave me some feedback or to suggest any future topics.

Looking forward to hear from you – Swadhin Ray (Sloba) -( LinkedIn ) ( Twitter )

 

Advertisements

0% [Connecting to archive.ubuntu.com ] Error

I encountered this error while using “apt-get” command on  my Linux mint server and it got stuck for 12-3 mins.

Here is the details on my error that I faced :


dev@dev-VirtualBox /etc $ sudo apt-get install alien
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
autoconf automake autopoint autotools-dev debhelper debugedit dh-autoreconf
dh-strip-nondeterminism libfile-stripnondeterminism-perl librpm3
librpmbuild3 librpmio3 librpmsign3 libtool po-debconf rpm rpm-common
rpm2cpio

.........

......

.........

0% [Connecting to archive.ubuntu.com (2001:67c:1560:8001::14)] [Connecting to

The issue is on the IPv6 taking more time to execute. Now let us check if my IPv6 is enabled or disabled. Based on the output we will see if we need to disable.


dev@dev-VirtualBox /etc $ cat /proc/sys/net/ipv6/conf/all/disable_ipv6
0
dev@dev-VirtualBox /etc $

If we get the output “0” then my IPv6 is enabled and if we get “1” then it is disabled.  So in my case I have to disable it. Let us see how we can disable it . And try to rerun my command where I got stuck.

To disable please execute the below commands and after that reboot the machine:


dev@dev-VirtualBox /etc $ echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf
#disable ipv6
dev@dev-VirtualBox /etc $ echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
dev@dev-VirtualBox /etc $ echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
net.ipv6.conf.default.disable_ipv6 = 1
dev@dev-VirtualBox /etc $ echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
net.ipv6.conf.lo.disable_ipv6 = 1
dev@dev-VirtualBox /etc $

I have rebooted my system now let us check what is the output I am getting :


oracle@dev-VirtualBox ~ $ cat /proc/sys/net/ipv6/conf/all/disable_ipv6
1
oracle@dev-VirtualBox ~ $

Now we can see that my IPv6 is disabled , so let us try to execute my initial “apt-get” command


dev@dev-VirtualBox ~ $ sudo apt-get update
Hit:1 http://archive.canonical.com/ubuntu xenial InRelease
Ign:2 http://packages.linuxmint.com sylvia InRelease
Hit:3 http://packages.linuxmint.com sylvia Release
Hit:4 http://archive.ubuntu.com/ubuntu xenial InRelea

...

...

..

Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [233 kB]
Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [16.2 kB]
Get:24 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse i386 Packages [15.3 kB]
Fetched 4,825 kB in 1s (2,621 kB/s)
Reading package lists... Done
dev@dev-VirtualBox ~ $

So we can see that we are now able to install the packages without any issues.

 

Thank you for reading my blog , please feel free to leave me some feedback or to suggest any future topics.

Looking forward to hear from you – Swadhin Ray (Sloba) -( LinkedIn ) ( Twitter )

 

 

Append row into a CSV file on SFTP

In this post I am going to show how we can append a row into CSV file using simple bash command.

To demonstrate this I am using Linux virtual machine, the OS is on Mint 18.3 64bit.  First me create a sample file on my Linux Machine as like below.

dev@dev-VirtualBox ~/Desktop/CSV $ pwd
/home/dev/Desktop/CSV
dev@dev-VirtualBox ~/Desktop/CSV $ ls
dev@dev-VirtualBox ~/Desktop/CSV $ cat <<EOF >sample.csv
> COL1,COL2,COL3
> 1,FIRST_LINE,18-JAN-2018
> EOF
dev@dev-VirtualBox ~/Desktop/CSV $ ls
sample.csv
dev@dev-VirtualBox ~/Desktop/CSV $

Once the file is created it will look something like below:

image

Now let us think that this file is on a SFTP server where we need to connect and append another line without renaming or changing the file format.

Login to the server


login as: dev
dev@10.0.0.203's password:
Welcome to Linux Mint 18.3 Sylvia (GNU/Linux 4.10.0-38-generic x86_64)

* Documentation:  <a href="https://www.linuxmint.com/">https://www.linuxmint.com</a>
Last login: Tue Jan 23 09:55:52 2018 from 10.0.0.203
dev@dev-VirtualBox ~ $ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
dev@dev-VirtualBox ~ $ cd Desktop/
dev@dev-VirtualBox ~/Desktop $ ls
CSV
dev@dev-VirtualBox ~/Desktop $ cd CSV/
dev@dev-VirtualBox ~/Desktop/CSV $ ls
sample.csv

So now we can login to the server.

Method 1: Now let us execute the below line to insert or append a new row to the existing CSV file i.e. sample.csv:


dev@dev-VirtualBox ~/Desktop/CSV $ sed -i.bak 1i"2,Second_Line,18-JAN-2018" sample.csv
dev@dev-VirtualBox ~/Desktop/CSV $

Once the above line is executed we will see the row is inserted but not at the end but at the beginning.

image

Now how we can append the line at the end .


dev@dev-VirtualBox ~/Desktop/CSV $ pwd
/home/dev/Desktop/CSV
dev@dev-VirtualBox ~/Desktop/CSV $ ls
sample.csv
dev@dev-VirtualBox ~/Desktop/CSV $ cat sample.csv
COL1,COL2,COL3
1,FIRST_LINE,18-JAN-2018
dev@dev-VirtualBox ~/Desktop/CSV $ sed -i -e "\$a2,Second_Line,18-JAN-2018" sample.csv
dev@dev-VirtualBox ~/Desktop/CSV $ cat sample.csv
COL1,COL2,COL3
1,FIRST_LINE,18-JAN-2018
2,Second_Line,18-JAN-2018
dev@dev-VirtualBox ~/Desktop/CSV $

 

The line used to insert the row/ append the row at the end is :

sed -i -e "\$a2,Second_Line,18-JAN-2018" sample.csv

Method 2: Now let us check how we can use echo to insert the line at the end.


dev@dev-VirtualBox ~/Desktop/CSV $ echo "3,Third_Line,18-JAN-2018" >> sample.csvdev@dev-VirtualBox ~/Desktop/CSV $ cat sample.csv
COL1,COL2,COL3
1,FIRST_LINE,18-JAN-2018
2,Second_Line,18-JAN-2018
3,Third_Line,18-JAN-2018
dev@dev-VirtualBox ~/Desktop/CSV $

Method 3: Append using a simple python programming


dev@dev-VirtualBox ~/Desktop/CSV $ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> with open('sample.csv', 'a') as file:
...     file.write('4,Fourth_Line,18-JAN-2018')
... ;
   File "<stdin>", line 3
     ;
     ^
SyntaxError: invalid syntax
>>> with open('sample.csv', 'a') as file:
...     file.write('4,Fourth_Line,18-JAN-2018\n');
...
>>> exit()

Finally, the file will look like as below:


dev@dev-VirtualBox ~/Desktop/CSV $ cat sample.csv
COL1,COL2,COL3
1,FIRST_LINE,18-JAN-2018
2,Second_Line,18-JAN-2018
3,Third_Line,18-JAN-2018
4,Fourth_Line,18-JAN-2018

dev@dev-VirtualBox ~/Desktop/CSV $



 

image

 

To automate the process you can create a script and try to pass the row as a input to the file while calling the script.

 

Thank you for reading my blog , please feel free to leave me some feedback or to suggest any future topics.

Looking forward to hear from you – Swadhin Ray (Sloba) -( LinkedIn ) ( Twitter )

 

Access Windows shared directory from Ubuntu 16.04.3 LTS VirtualBox Guest

In this post I am going to show how to access windows shared directory from Ubuntu 16.04.3 LTS virtual machine.

First create a directory on the host. For example I am creating one directory called on my E drive [ My host is Windows 7 ] .

Now open VirtualBox go to settings of your Ubuntu guest, under shared section add your directory that was created with full permission. Once this is completed login to Ubuntu virtual machine and type the below:

 sudo usermod -aG vboxsf $(whoami) 

Executed on my machine as like below:

sloba@sloba-VirtualBox:~$ sudo usermod -aG vboxsf $(whoami)
[sudo] password for sloba:
sloba@sloba-VirtualBox:~$ reboot

After that reboot your Ubuntu machine you can access the shared drive as shown below.


sloba@sloba-VirtualBox:~$ ls
Desktop Downloads Music Pictures Templates
Documents examples.desktop oraInventory Public Videos
sloba@sloba-VirtualBox:~$ cd /media/
sloba@sloba-VirtualBox:/media$ ls -lrt
total 12
drwxrwx--- 1 root vboxsf 0 Jan 22 21:12 sf_vmshare

sloba@sloba-VirtualBox:/media$ cd sf_vmshare/
sloba@sloba-VirtualBox:/media/sf_vmshare$

 

Thank you for reading my blog , please feel free to leave me some feedback or to suggest any future topics.

Looking forward to hear from you – Swadhin Ray (Sloba) -( LinkedIn ) ( Twitter )

 

 

Sending Email from Linux

 

Here is the simple way to write an email script which can be utilized to send emails to recipients.

Login to your Linux box , I am using a virtual machine with Linux Mint operating system installed running on Oracle Virtual Box.

login as: sloba
sloba@**********'s password:
Welcome to Linux Mint 17.2 Rafaela (GNU/Linux 3.16.0-38-generic i686)

Welcome to Linux Mint
 * Documentation:  http://www.linuxmint.com
Last login: Fri Jul 24 12:52:24 2015 from msi-l1028.metricstream.com
sloba@sloba-VirtualBox ~ $ 

Below is a very basic and simple script which can be used to send email :

 

##################################################################
# Email notification
##################################################################
SUBJECT="TEST EMAIL FROM UNIX"
# use form to send from whom the email address has sent
FROM="automail@slobaexpert.wordpress.com"
DESCRIPTION="THIS IS AN AUTO-GENERATED MESSAGE"
#Put the email address of the person to whom you want to send with comma seperator
EMAIL="<<to email address>> @<<hostname >>.com"
EMAILMESSAGE=/tmp/emailmessage

 echo "From: $FROM" > $EMAILMESSAGE
 echo "To: $EMAIL" >> $EMAILMESSAGE
 echo "Subject: $SUBJECT " >> $EMAILMESSAGE
 echo "************************************************************************" >> $EMAILMESSAGE
 echo "$DESCRIPTION : DO NOT REPLY TO THIS EMAIL MESSAGE. " >> $EMAILMESSAGE
 echo "************************************************************************" >> $EMAILMESSAGE
 echo " " >> $EMAILMESSAGE
 echo " " >> $EMAILMESSAGE
 echo "Test file email " >> $EMAILMESSAGE
 echo " " >> $EMAILMESSAGE
 echo " " >> $EMAILMESSAGE
 echo "Thanks, " >> $EMAILMESSAGE
 echo "$FROM" >> $EMAILMESSAGE
 cat $EMAILMESSAGE | /usr/sbin/sendmail -t

 

You can change the TO address from the above script and test it. But we need to make sure “sendmail ” is already installed on your server to use this , if not then you can install using the below command.

sudo apt-get install sendmail

Enable SSH server in Linux Mint

Normally we do connect to any server from WinScp or Putty tool from Windows platform to connect any Linux environment to do various activities. 

Here I am going to show how we can enable SSH on Linux Mint operating system. I am using a virtual machine was built on Oracle Virtual Box. 

image

The above image show my virtual machine running on Oracle VM virtual box. Now let me open my putty and try connect to my virtual machine. To know the hostname of the VM you can open the terminal and type “hostname” as shown like below:]

image

Open Putty :

image

Click on Open.

image

After this I get the above error. Now let try to enable SSH on our Linux machine we need to first install “OpenSSH” .  

There are two options that we can do to install “OpenSSH” :

Option 1:

  • Open the main menu, select the Software Manager
  • Search for “Openssh ” on the search box
  • Click on the package openssh-server, then select install.
  • Once the installation is completed then start SSH by executing “/etc/init.d/ ssh start”  command.

image

image

image

image

Click on “install”

Option 2: 

As Linux Mint Operating system is based on Ubuntu , so we can install “openssh” from terminal or console.

 

image

image

image

image

Check if port 22 is enabled or not under “sshd_config” file , we can also modify the port in this file to access SSH on another port but I am using the default setup i.e. port 22.

image

Now let’s try connecting through putty from my local system to the VM .

image

 

image

 

image

Now we can see that I am able to connect to my Linux machine using Putty after enabling SSH on VM server.