Setting up Play Development Environment on Ubuntu

# Configure apt for java
# http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
apt-get update
apt-get install -y python-software-properties
add-apt-repository -y ppa:webupd8team/java
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections

# Update apt sources
apt-get update

apt-get install -y unzip wget git vim oracle-java8-installer oracle-java8-set-default

# Install scala
cd /opt
wget http://www.scala-lang.org/files/archive/scala-2.12.0.tgz
tar -zxvf scala-2.12.0.tgz
# end scala

#Installing playframework on ubuntu there are two options

OFFLINE INSTALLER
Go to https://downloads.typesafe.com/typesafe-activator/1.3.12/typesafe-activator-1.3.12.zip, download the offline installer close to 617MB

OR MINIMAL ACTIVATOR

# Install play with activator
#Download and Install Play (the folder should have permission to write)
#wget http://downloads.typesafe.com/typesafe-activator/1.3.12/typesafe-activator-1.3.12-minimal.zip
#unzip typesafe-activator-1.3.12-minimal.zip
#mv activator-1.3.12-minimal activator

The off-line installer downloads all the dependencies required to run play applications. In a scenario where in we download only the small foot print of activator the dependencies are downloaded at the time of loading the project, which can be annoying and time consuming.

Follow the instructions at https://www.playframework.com/documentation/2.5.x/Installing to install the play and chose “installing play with activator” and follow instructions listed
Extracting Activator

Extract the archive on a location where you have write access. Running activator writes some files to directories within the distribution, so don’t install to /opt, /usr/local or anywhere else you’d need special permission to write to.
Adding Activator to your Path

For convenience, you should add the Activator installation directory to your system PATH:

export PATH=$PATH:/opt/activator/bin

source ~/.bashrc

Making the activator as an executable execute the following command

sudo chmod a+x /activator/bin/activator

Just in case after executing the above commands and when we issue activator in the terminal, if it says command not found, we need to manually edit the bashrc file as follows

gedit source ~/.bashrc

add the command to the bottom of the file

export PATH=$PATH:/opt/activator/bin

 

unzip typesafe-activator-1.3.12.zip
mv typesafe-activator-1.3.12 activator

cd /opt
export PATH=$PATH:/opt/activator/bin
source ~/.bashrc
sudo chmod a+x /activator/bin/activator
./activator
# end play with activator

#echo ‘PATH=${PATH}:/opt/scala-2.12.0/bin:/opt/play-2.2.5’ >> /etc/profile
echo ‘PATH=${PATH}:/opt/scala-2.12.0/bin’ >> /etc/profile

echo ‘PATH=${PATH}:/opt/activator/bin’ >> /etc/profile

sudo apt-get install git

echo “Installing IntelliJ IDEA…”

# We need root to install
[ $(id -u) != “0” ] && exec sudo “$0” “$@”

# Attempt to install a JDK
# apt-get install openjdk-8-jdk
# add-apt-repository ppa:webupd8team/java && apt-get update && apt-get install oracle-java8-installer

# Prompt for edition
#while true; do
#    read -p “Enter ‘U’ for Ultimate or ‘C’ for Community: ” ed
#    case $ed in
#        [Uu]* ) ed=U; break;;
#        [Cc]* ) ed=C; break;;
#    esac
#done
ed=C

# Fetch the most recent version
VERSION=$(wget “https://www.jetbrains.com/intellij-repository/releases” -qO- | grep -P -o -m 1 “(?<=https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/BUILD/)[^/]+(?=/)”)

# Prepend base URL for download
URL=”https://download.jetbrains.com/idea/ideaI$ed-$VERSION.tar.gz”

echo $URL

# Truncate filename
FILE=$(basename ${URL})

# Set download directory
DEST=~/Downloads/$FILE

echo “Downloading idea-I$ed-$VERSION to $DEST…”

# Download binary
wget -cO ${DEST} ${URL} –read-timeout=5 –tries=0

echo “Download complete!”

# Set directory name
DIR=”/opt/idea-I$ed-$VERSION”

echo “Installing to $DIR”

# Untar file
if mkdir ${DIR}; then
tar -xzf ${DEST} -C ${DIR} –strip-components=1
fi

# Grab executable folder
BIN=”$DIR/bin”

# Add permissions to install directory
chmod -R +rwx ${DIR}

# Set desktop shortcut path
DESK=/usr/share/applications/IDEA.desktop

# Add desktop shortcut
echo “[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/idea.sh\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application” -e > ${DESK}

# Create symlink entry
ln -s ${BIN}/idea.sh /usr/local/bin/idea

echo “Done….Installing IntelliJ IDEA…”

echo “Start….Installing Scala..”

How to Install MySQL – Ubuntu

 

apt-get install --print-uris mysql-server > desktop

http://in.archive.ubuntu.com/ubuntu/pool/main/libe/libevent/libevent-core-2.0-5_2.0.21-stable-2_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-common_5.7.16-0ubuntu0.16.04.1_all.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/liba/libaio/libaio1_0.3.110-2_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-client-core-5.7_5.7.16-0ubuntu0.16.04.1_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-client-5.7_5.7.16-0ubuntu0.16.04.1_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-server-core-5.7_5.7.16-0ubuntu0.16.04.1_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-server-5.7_5.7.16-0ubuntu0.16.04.1_amd64.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/libh/libhtml-template-perl/libhtml-template-perl_2.95-2_all.debhttp://in.archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/mysql-server_5.7.16-0ubuntu0.16.04.1_all.deb

This will print out a bunch of URLs. You can download these from another computer, and transfer them to your Ubuntu machine, putting the .deb files into /var/cache/apt/archives.

sudo apt-get install mysql-server

And apt will find the package files you’ve downloaded, and install mysql.

Ubuntu reset root password

Boot up the machine, and after the BIOS screen, hold the Right Shift when booting up, to get the Grub menu

Select the GRUB (Recovery Mode)

Hit the down arrow until you select the 2nd entry from the top (the one with the recovery mode in the description) and then hit Enter.

Using the arrow keys scroll down to root and then hit Enter.

You should now see a root prompt, something like this:

root@ubuntu:~#

At this stage you should have a read-only filesystem. You have to remount it with write permissions:

mount -rw -o remount /

Now we can set the user’s password with the passwd command. (In this example I will use jorge as the example, you need to substitute whatever the user’s username is):

root@ubuntu:~# passwd <user>
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@ubuntu:~#

Type in what you want the new password to be at the prompt. After it’s successful reboot the machine and the user will be able to log in with their new password.

Package Management

APT: Advanced Package Tool. Works with ‘deb‘ archive from the location specified in the “/etc/apt/sources.list” file.

Commands:

  • dpkg -l : List all packages
  • dpkg -i <pkgname>: Install a package
  • dpkg -r <pkgname>: Remove a package
  • dpkg -s <pkgname>: Whether an deb package installed or not.

APT – ADVANCED PACKAGING TOOL

When you install packages from the command line with sudo apt-get install ... (or sudo aptitude install ...), or when you upgrade them from the command line (with upgrade or dist-upgrade instead of install), the following information is obtained from your local system’s configuration, and not from the Internet:

  1. what packages are available
  2. what versions of them are available
  3. where the available packages should be retrieved from

Running sudo apt-get update (or sudo aptitude update) updates this on your local system. This is the step that actually retrieves information about what packages can be installed, including what updates to currently installed packages packages are available, from Internet sources.

Because information about what updated versions of packages are available is obtained by running sudo apt-get update (or sudo aptitude update), it is advisable to run this before installing any package, and necessary to run it to install the latest updates, even if you have not added or removed any Software Sources (such as a PPA).

The apt-get utility is a command line program, used to work with Ubuntu’s APT (Advanced Packaging Tool) library

  • installation of new software packages,
  • removing existing software packages,
  • upgrading of existing software packages and even used to upgrading the entire operating system.

The apt-cache command line tool is used for searching apt software package cache.

  • apt-cache pkgnames : To list all the available packages
  • apt-cache show scala : To check information of package
  • apt-cache showpkg scala : Which packages are dependent on the package

The ‘update‘ command is used to resynchronize the package index files from the their sources specified in /etc/apt/sources.list file. The update command fetched the packages from their locations and update the packages to newer version.

  • sudo apt-get update
  • sudo apt-get install scala : To update specific package
  • sudo apt-get install scala=2.3 : To update to a specific version of the package
  • sudo apt-get remove scala: Remove a package (Configuration Files Maintained)
  • sudo apt-get purge scala: Remove package with configurations
  • sudo apt-get clean: Free up disk space by cleaning .deb files

Remove Java from Ubuntu

sudo update-alternatives --remove-all java
sudo update-alternatives --remove-all javac
sudo update-alternatives --remove-all javaws
sudo rm -rf /usr/lib/jvm/jdk1.8.0

Commands

mv: Short for move, this command can be used to move your files from one folder to another.

rm: Short for remove, this command is used to remove any files or folders.

cd: Short for change, you can use this command to change your current directory.

cp: Short for copy, this command can be used to copy files or folders in a directory.

chown: This command is used to change ownership of a file.

chmod: This command is used to change permissions on a file.

ls: Short for list, this command can be used to view all of the files and folders in your current working directory.

pwd: Short for print working directory, this command can be used to display the directory in which you are currently working.

sudo: Also referred to as superuser do, a sudo command allows you to run other commands with administrative privileges. This command is especially useful for modifying files in a directory that a user wouldn’t necessarily have access to.

cd: Short for change directory, this command can be used to change the directory in which you are currently working. There are a variety of cd commands that can be used to take you to specific files or folders.

cd / : An alternate to a basic cd command, the cd / command can be used to take you to the root directory.

cd .. : This command can be used to take you up one directory level.

cd – : This command can be used to navigate to a previous directory.

find:

locate filename :

whatis ls: gives a brief description of the shell command.

whereis :

type source: source is a shell bulletin

./ dot slash

A dot slash is a dot followed immediately by a forward slash ( ./ ). It is used in Linux and Unix to execute a compiled program in the current directory. For example, if you had an executable file in the current directory called “hope” and typed “hope” at the command line, you would get an error such as “-bash: hope: command not found”. This is because this command is not a built-in command, and the executable file is not found in your PATH

source

source ~/.bashrc

source is a bash shell built-in command that executes the content of the file passed as argument, in the current shell. It has a synonym in ‘.’ (period).