How to install Java

Downloading and Installing Java from OpenJDK

if you want to download OpenJDK manually, download it from

But you can download JDK programmatically as the following. Java SE 7, 8, 9, 10, 11, 12, 13 are included below script. So, run below script in your terminal.

# Java SE 7

# Java SE 8

# Java SE 9

# Java SE 10

# Java SE 11

# Java SE 12

# Java SE 13

mkdir /usr/lib/jvm

# Extract all downloaded jdk files
tar -xvzf openjdk-7u75-b13-linux-x64-18_dec_2014.tar.gz -C /usr/lib/jvm

tar -xvzf openjdk-8u40-b25-linux-x64-10_feb_2015.tar.gz -C /usr/lib/jvm

tar -xvzf openjdk-9.0.4_linux-x64_bin.tar.gz -C /usr/lib/jvm

tar -xvzf openjdk-10.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvm

tar -xvzf openjdk-11.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvm

tar -xvzf openjdk-12.0.2_linux-x64_bin.tar.gz -C /usr/lib/jvm

tar -xvzf openjdk-13_linux-x64_bin.tar.gz -C /usr/lib/jvm

# Remove downloaded jdk files
rm openjdk*

# Install Java and Java Compiler to Environment
update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-se-7u75-ri/bin/java 1

update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-se-7u75-ri/bin/javac 1

update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-se-8u40-ri/bin/java 2

update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-se-8u40-ri/bin/javac 2

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-9.0.4/bin/java 3

update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-9.0.4/bin/javac 3

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-10.0.2/bin/java 4

update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-10.0.2/bin/javac 4

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11.0.2/bin/java 5

update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-11.0.2/bin/javac 5

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-12.0.2/bin/java 6

update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-12.0.2/bin/javac 6

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-13/bin/java 7

update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-13/bin/javac 7

# Verify Java and Java Compiler Installation
# check if java command is pointing to correct path in system
update-alternatives --display java
update-alternatives --display javac

# List all environment variables
update-alternatives --get-selections
# or
update-alternatives --get-selections | grep java
# or
update-alternatives --get-selections | grep ^java

Check Java Version

# Verify if Java is running
java -version

# Verify if Java Compiler is running
javac -version

GitHub clone all repositories

After you join an organization, you will need to clone all git repositories in your machine probably. 🙂

So first follow this post to create a ssh key in your machine and put in github then you can clone all repositories for any user.

if you have any authentication issue, then create an access token from github, copy and paste instead of {acceess-token} in the following code.

curl -u {access-token}:x-oauth-basic -s | grep ssh_url | awk -F '"' '{print $4}' | xargs -n 1 -P 4 git clone

In order to learn github API endpoint urls, use the following code.


To learn more details about official GitHub REST API v3, use the following link.

Github Connect with your SSH Public Key

If you are using git for your projects, you need to run some git commands such as clone, pull or push. So, let's say that you want to clone one git project and if it is asking your username and password, you can create a SSH Public Key for your pc, after that you can paste it your github account so that you will never need to specify username and password.

You can follow below screenshot to create a SSH Public Key. After you create it, copy created SSH Public Key from terminal and paste it to GitHub SSH Keygen window like below.

Follow below screenshots to add your SSH Public Key in your GitHub account.

Uninstall Vagrant on Ubuntu

Uninstall just vagrant

This will remove just the vagrant package itself.

sudo apt-get remove vagrant

Uninstall vagrant and its dependencies

To remove the vagrant package and any other dependant package which are no longer needed from Ubuntu.

sudo apt-get remove --auto-remove vagrant

Purging vagrant (your config/data too)

If you also want to delete your local/config files for vagrant then this will work.

sudo apt-get purge vagrant

To delete configuration and/or data files of vagrant and it's dependencies from Ubuntu then execute.

sudo apt-get purge --auto-remove vagrant

Bash Shortcuts

CTRL + AMove to the start of the line.
CTRL + EMove to the end of the line.
CTRL + BMove back one character.
CTRL + FMove forward one character.
CTRL + DDelete one character after cursor.
CTRL + HDelete one character after cursor.
CTRL + UDelete from the cursor to the beginning of the line.
CTRL + KDelete from the cursor to the end of the line.
CTRL + WDelete from the cursor to the start of the word.
!!Execute last command in history.
!nExecute nth command in history.
!$Last argument of last command.
!^First argument of last command.

Modify File Permissions with Linux chmod command (Ownership and Permissions)

Following are the symbolic representation of three different roles:

  • u is for user
  • g is for group
  • o is for others
  • a is for all

Following are the symbolic representation of three different permissions:

  • r is for read permission
  • w is for write permission
  • x is for execute permission

This is called octal notation because the binary numbers are converted to base-8 by using the digits 0 to 7:

  • 7, rwx, read, write, and execute
  • 6, rw-, read and write
  • 5, r-x, read and execute
  • 4, r–, read only
  • 3, -wx, write and execute
  • 2, -w-, write only
  • 1, –x, execute only
  • 0, —, none

The format of a chmod command

chmod [who][+,-,=][permissions] filename

There are two ways to give permissions.

Here is the equivalent command using octal permissions notation.

chmod 754 file.txt

This example uses symbolic permissions notation.

chmod u=rwx,g=rx,o=r file.txt

a+x is same as +x

chmod -R +w,g=rw,o-rw, ~/group-project-files/

Copying permissions

The parameter g=u means grant group permissions to be same as the user’s.

chmod g=u ~/myFile.txt

Making a File Executable

chmod +x ~/

Add single permission to a file/directory

chmod u+x filename

Add multiple permission to a file/directory

chmod u+r,g+x filename

Remove permission from a file/directory

chmod u-rx filename

Change permission for all roles on a file/directory

Following code assigns execute privilege to user, group and others (basically anybody can execute this file).

chmod a+x filename

Make permission for a file same as another file (using reference)

file2’s permission will be set exactly same as file1’s permission.

chmod –reference=file1 file2

Apply the permission to all the files under a directory recursively

chmod -R 755 directory-name/

Change execute permission only on the directories (files are not affected)

chmod u+X *

How To Use SSH to Connect to a Remote Server in Ubuntu

Enable SSH in Ubuntu Server

Install it by running the following command in your Ubuntu terminal.

sudo apt-get install openssh-server -y

Check SSH Status

sudo service ssh status

Configure SSH in Ubuntu Server

Configure SSH by running the following command in Ubuntu terminal.

sudo nano /etc/ssh/sshd_config

When you open the file, find and change the following item(default port)

# Port 22


Port 22

Restart SSH in Ubuntu Server

Apply the changes by restarting SSH.

sudo service ssh restart

Create SSH Keys

SSH keys allow authentication between two hosts without the need of a password. SSH key authentication uses two keys, a private key and a public key. The first step is to create a key pair on the client machine

ssh-keygen -t rsa

Copy the public key to the remote server

There are 3 ways to copy your public key to remote server(Ubuntu etc.).

Copy public key using ssh-copy-id

To copy public key to remote computer run the following command in local computer.

ssh-copy-id username@remote_host

Copy public key using ssh

ssh kenanhancer

ssh kenanhancer@

ssh username@remote_host -p port

Copy public key manually

To display the content of your key, type this into your local computer.

cat ~/.ssh/

chmod 600 ~/.ssh/id_rsa

Connect to Remote computer

you should make sure the ~/.ssh directory exists. This command will create the directory if necessary, or do nothing if it already exists.

mkdir -p ~/.ssh

Copy public_key_string from local computer and paste instead of public_key_string in remote computer.

echo public_key_string >> ~/.ssh/authorized_keys


echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBmtMX3tBQCHMt8p+3zP/spcamBXLAGEGNtBt1O12FXOEAX5Xw6lCNRJdH5WsdZHPUtGmwIjWZBK3ezQgw1biI3PREMmG11sDZHd5GYwAqoswyaaZsv4vEoQIkZx32rH6vm8XgszKXxtMVkhK3LfAO6Hzot4FrMjqg2eB8pvy5Nsz0MjJmdfpXkJadxofFsxkP8l6YzOWLZFWNEvqeHzmxzl1/FEdhWrdR9i4h9K5vvBKUkmTTn1WyoCKqmKdHiNRlNOfnNMJV3e/IJGzXRmFzqFQ2ApOm5Qu8r1hZ5gV87ShKnCy1++x9VNPbX4LeY56F/Ud5cp1kaOyT4RkT37FJ kenanhancer@kenans-mbp.mynet >> ~/.ssh/authorized_keys

Check key in Remote computer if you want to see

cat ~/.ssh/authorized_keys

Login to Ubuntu Server via SSH

Let's check docker containers and docker images in remote Ubuntu server by running the following command from local computer