Fix Missing Create New Document at Right Click in Nautilus Files in Fedora 23

Fedora 23 comes with Nautilus File Manager. You might have noticed that in the file manager, when you go to a location and right click with mouse, the option for “New Folder” is present, but the option for “New Document” is missing.

To create a new file, there is always command-line option like touch, vi, and so on, but what if you want to create a new empty file in right-click of mouse, and do not want to go to the terminal each time.

Solution:
Open the terminal, run the following commands:

cd ~/Templates/
touch ‘New Text File.txt’ && touch ‘New Word File.doc’ && touch ‘New Excel File.xls’

The above command will create 3 files, a txt file, a doc file and an xls file in the Templates folder within the HOME folder. Also if you open the Templates folder in the file manager, you will notice a message at the top:

Files in this folder will appear in the New Document menu.

Now if you go to any folder in the file manager, you will find a “New Document” menu, within which you will find the option to create an empty file as present in the Templates folder. Done !!!

Install Grails on Fedora 23

Prerequisites:

  • JDK must be installed in the system.
  • Note: Check the compatibility of JDK version with Grails version.
  • Note: Grails 2.3.x have issues with JDK8, so use JDK7 with it instead.

Check JDK installation:

Check java version by running the command:

java -version

You will get an output similar to below depending on the version installed:

java version “1.8.0_66”
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

Check whether JAVA_HOME is set by running the command:

echo $JAVA_HOME

If you get blank output, i.e., JAVA_HOME is not set, perform next step.

Set JAVA_HOME:

  1. Check for jdk path, you should have a jdk path similar to “/usr/java/jdk1.8.0_66” depending on the JDK installed.
  2. Open the file /etc/profile in edit mode using a file editor as follows:

    sudo vi /etc/profile
    or,
    sudo gedit /etc/profile

  3. Append the following line at the end of the “/etc/profile” file:

    export JAVA_HOME=/usr/java/jdk1.8.0_66

    The path will be the same jdk path as found in step 1.

Grails Installation steps:

  1. Download the latest or previous version of Grails archive from the link [1]. The downloaded archive file will look similar to grails-2.3.7.zip, depending on the version downloaded.
  2. Copy the archive file to /opt/ location by running the command:

    sudo cp ~/Downloads/grails-2.3.7.zip /opt/

  3. Go to /opt folder and extract the grails-2.3.7.zip archive file by running the command:

    cd /opt/
    sudo unzip grails-2.3.7.zip

    A folder named “grails-2.3.7” will be created. Note that the folder name will vary depending on the downloaded version of archive file.

  4. Delete the archive file “grails-2.3.7.zip” by running the command:

    sudo rm grails-2.3.7.zip

  5. Open the file /etc/profile in edit mode using a file editor, and append the following line at the end:

    export GRAILS_HOME=/opt/grails-2.3.7 export PATH=$GRAILS_HOME/bin:$PATH

  6. Check if the grails is properly installed by running the command:

    grails -version

    You should get an output similar to below:

    Grails version: 2.3.7

  7. Note: Changes made in /etc/profile are not reflected immediately, but are reflected after you logout, and re-login. To reflect the changes immediately run the following command:

    source /etc/profile

  8. Another way to check if the PATH is updated properly in step 5, is by checking the value of PATH variable, using the command:

    echo $PATH

    The location “/opt/grails-2.3.7/bin” (or similar location depending on grails version), should be present in the PATH variable value, otherwise run command in step 7, and re-check.

References:

  1. https://grails.org/download.html
  2. https://grails.org/wiki/Installation

Setup Git in Fedora 23 with Bitbucket

Git Installation in Fedora:

Command to install Git:

sudo dnf install git-all

Basic Git configuration:

For complete details of git configuration refer to [2][3]. To start with it is good to configure the user name and email id, which can be done as follows:

git config –global user.name “John Doe”
git config –global user.email johndoe@example.com

The above two command will configure the user-name and email-id at global level.

Following are the 3 levels of configuration which are also described in detail in [2]:

  1. System Level (comman for all user): /etc/gitconfig file: Contains values for every user on the system and all their repositories. If you pass the option –system to git config, it reads and writes from this file specifically.
  2. User Level (comman for all git repositories): ~/.gitconfig or ~/.config/git/config file: Specific to your user. You can make Git read and write to this file specifically by passing the –global option.
  3. Repository Level (specific to particular repository): config file in the Git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository.

To check the git configuration:

git config –list

Check for already exisiting SSH keys[4] in the system:

Check if a pair of public private key already exist, by running the command:

cd ~/.ssh/
ls id_*

If you get files, then the keys already exist, no need to generate new SSH keys. Else continue to next step to generate new SSH keys.

Generating a new SSH key for secure connection[4]:

  1. Go to your HOME directory in your linux machine:
    cd ~
  2. Type the following command at the terminal
    ssh-keygen
  3. The command will prompt you to save the file under the location <HOME_Directory>/.ssh/id_rsa.
  4. Press enter to select the default location.
  5. The command will prompt for passphase. Press enter to provide blank passphase.
  6. The private key (id_rsa) and public key (id_rsa.pub) files will be generated.

Bitbucket Setup:

Create an account in Bitbucket.

Add the public key to the Bitbucket[4]:

  1. Click on your bitbucket avatar icon, and go to Bitbucket settings.
  2. Under Security, go to SSH keys.
  3. Click on the Add key, provide a label.
  4. Copy the contents of your public key (i.e. ~/.ssh/id_rsa.pub) and paste it in the text box “Key”.
  5. Click on the add key, and you are done.

Steps to create repository in Bitbucket[5][6]:

  1. From Bitbucket, click the Create button at the top of the page and select Create repository from the drop-down menu.
  2. Provide the name of the repository, say myrepo, in the Name field.
  3. Provide the description of the repository in the Description field.
  4. For Access Level, select the check-box to make the repository private, otherwise un-select it.
  5. Select Git for repository type. Note, repository type cannot be changed later.
  6. Check both Issue tracking and Wiki checkbox for Project Management.
  7. For language field, select the option of your choice.
  8. Click “Create repository” button to create the repository.

Initialize a git repository and point it to your Bitbucket repository.

mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin ssh://git@bitbucket.org/username/reponame.git

Check your repository specific git configuration:

  • To check repository specific git configuration run following commands:

cd /path/to/your/project
cat .git/config

  • Check if the repository url is using HTTPS protocol as shown below:

[remote “origin”]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://emmap1@bitbucket.org/emmap1/bitbucketspacestation.git

  • Change repository url format from HTTPS protocal to SSH protocol:
  1. Find the repository URL from the Overview Page.
  2. Select the SSH option, the URL will look similar to “ssh://git@bitbucket.org/username/reponame.git”.
  3. Change the repository url value to SSH format “ssh://git@bitbucket.org/username/reponame.git” using your favourite file editor, so that it looks like below:

[remote “origin”]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ssh://git@bitbucket.org/username/reponame.git

To set remote master as default branch for push and merge while pull, run following commands:

git config branch.master.remote origin
git config branch.master.merge refs/heads/master

To set the default git push as upstream [3]:

git config –global push.default upstream

References:

  1. https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
  2. https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
  3. https://git-scm.com/docs/git-config
  4. https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html
  5. https://confluence.atlassian.com/bitbucket/create-a-git-repository-759857290.html
  6. https://confluence.atlassian.com/bitbucket/create-a-repository-221449521.html

Install Idea IntelliJ in Fedora 23

Prerequisite:

Download the archive file for community or ultimate edition from the official website:

https://www.jetbrains.com/idea/download/#section=linux

The file will look similar to “ideaIC-15.0.2.tar.gz” in case of community edition.

Note: The community edition is a free version, while ultimate edition is a paid version which comes with one month free trial.

Installation Steps:

  • Copy the archive file to a desired location:

sudo cp ideaIC-15.0.2.tar.gz /opt/

  • Extract the archive file:

sudo tar -xvf ideaIC-15.0.2.tar.gz

  • Create symbolic links so that the IDE can be opened from any location:

ln -sf /opt/idea-IC-143.1184.17 /opt/idea
ln -s /opt/idea/bin/idea.sh /usr/local/bin/idea

  • Open the IntelliJ IDE by the running the following command:

idea

  • Create a desktop launcher:
    To create a desktop launcher create a idea.desktop file in the Desktop folder inside the HOME folder. Copy paste the following contents in the file:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=IntelliJ IDEA
GenericName=Java IDE
Comment=IntelliJ IDEA.
Exec=idea
Icon=/opt/idea/bin/idea.png
Terminal=false
Type=Application
Categories=Development;IDE

Install Apache Maven in Fedora 23

Prerequisite:

  • JDK must be installed in the system.
  • Download the binary tar .gz archive file from the Apache Maven website, i.e., from the location https://maven.apache.org/download.cgi. The file will look similar to “apache-maven-3.3.9-bin.tar.gz”.

Installation:

  1. Create a new folder say “apache-maven” inside the location “/usr/local/” by running the command:

    sudo mkdir -p /usr/local/apache-maven

  2. Move the downloaded “apache-maven-3.3.9-bin.tar.gz” file to the above created folder location by running the command:

    sudo mv apache-maven-3.3.9-bin.tar.gz /usr/local/apache-maven

  3. Go to the folder location:

    cd /usr/local/apache-maven

  4. Extract the contents of the archive file:

    sudo tar -xzvf apache-maven-3.3.9-bin.tar.gz

  5. You have to set some variables like M2_HOME, M2, MAVEN_OPTS and PATH, which can be done by editing either “.profile” or “.bash_profile” file in the user’s HOME folder, or editing “/etc/profile” file. Editing the files inside the HOME folder will effect the user’s shell, while editing “/etc/profile” will make the changes available system-wide.To edit the file the command will be:

    sudo gedit
    or,
    sudo vi

    For example, to edit “/etc/profile” the command will be

    sudo gedit /etc/profile
    or,
    sudo vi /etc/profile

    The above commands will open file for editing.

  6. Add the following contents at the end of the file mentioned in Step5:

    export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
    export M2=$M2_HOME/bin
    export MAVEN_OPTS=”-Xms256m -Xmx512m”
    export PATH=$M2:$PATH

    Note: The path mentioned in the 1st line to set M2_HOME should be the location where the file gets extracted in Step2.

  7. Execute the following command:

    sudo update-alternatives –install “/usr/bin/mvn” “mvn” “/usr/local/apache-maven/apache-maven-3.3.9/bin/mvn” 1

    Note: The file location “/usr/local/apache-maven/apache-maven-3.3.9/bin/mvn” should be present inside the extracted folder in Step2.

  8. Check the maven installation by running the command:

    mvn -version

    You should get the output similar to below:

    Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
    Maven home: /usr/local/apache-maven-3.3.9
    Java version: 1.8.0_66, vendor: Oracle Corporation
    Java home: /usr/java/jdk1.8.0_66/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: “linux”, version: “4.2.3-300.fc23.x86_64”, arch: “amd64”, family: “unix”

Desktop shortcut for application launcher in Fedora 23

 

In fedora you cannot right-click and create a desktop shortcut for your applications. In this post some of the ways are presented which can be used.

Method 1: If .desktop file is already present in the system

Lets say you have installed google chrome browser, and now you want to have a desktop shortcut for it.

  1. Go to location /usr/share/applications/ or ~/.local/share/applications/ using the file browser or by typing the following command:

    cd /usr/share/applications/
    or,
    ~/.local/share/applications/

  2. Check if the .desktop file is already present in the location. In the above example for google chrome browser, you may find a file like “google-chrome.desktop”.
  3. Copy the .desktop file of your application (in this case google-chrome.desktop) to following location:

    <home_folder>/Desktop

    For example if the user name is harry, copy the file to the location

    /home/harry/Desktop

  4. Give the permission to the desktop file, like chmod 755 <file_name>
  5. Done. You should be able to see the launcher of you application in the user’s desktop.

Method 2: If .desktop file is not present in the location mentioned in Method 1.

Lets say you have an launcher say “abc” in the location /home/harry/, so you have to go to the location /home/harry/ in the terminal, and run it as ./abc.

Following are the steps to create a desktop launcher (shortcut) by creating a .desktop file:

  1. Go to the location Desktop folder within home folder (i.e., <home_folder>/Desktop). For above example, go to /home/harry/Desktop.
  2. Create a file say abc.desktop using vi editor or gedit, or any file editor of your choice. The file name can be anything.
  3. Following will be the content of the abc.desktop file:

    [Desktop Entry]
    Type=Application
    Encoding=UTF-8
    Name=<Name_of_your_application>
    Comment=<Any_comment_for_your_application>
    Exec=<path_of_your_application_launcher>
    Icon=<path_of_icon_file_to_be_used_for_application>
    Terminal=false

    For the above example of “abc” application, following will be the content:

    [Desktop Entry]
    Type=Application
    Encoding=UTF-8
    Name=ABC
    Comment=My ABC Application
    Exec=/home/harry/abc
    Icon=/home/harry/icon.png
    Terminal=false

  4. Give the permission to the desktop file, like chmod 755 <file_name>
  5. Done. You should be able to see the launcher of you application in the user’s desktop.

 

Install Oracle JDK & JRE in Fedora 23

Prerequisite:

Download the rpm files for jdk and jre from the oracle website [1].

The downloaded file will have names similar to jdk-8u66-linux-x64.rpm and jre-8u66-linux-x64.rpm respectively.

Remove Pre-installed OpenJDK:

Fedora 23 comes with OpenJDK by default. To know the details of already installed Java enter the following command:

rpm -qa | grep jdk

You will get an output as follows:
java-1.8.0-openjdk-headless-1.8.0.60-14.b27.fc23.x86_64

To remove the above OpenJDK package, enter the following command:

sudo yum remove <package-name>
or,
sudo dnf remove <package-name>

For above example, the command will be as follows:

sudo dnf remove java-1.8.0-openjdk-headless-1.8.0.60-14.b27.fc23.x86_64

It will ask to remove multiple packages, type ‘y’ to proceed.

Installation of Oracle JDK & JRE:

  • Install Oracle JDK rpm package:

rpm -Uvh <path-to-jdk-rpm>

Example: rpm -Uvh jdk-8u66-linux-x64.rpm

  • Install Oracle JRE rpm package:

rpm -Uvh <path-to-jre-rpm>

Example: rpm -Uvh jre-8u66-linux-x64.rpm

  • Install java:

alternatives –install /usr/bin/java java /usr/java/latest/jre/bin/java 20000

  • Install javaws:

alternatives –install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000

  • Install Java Browser (Mozilla) Plugin:

For 32-bit:

alternatives –install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 20000

For 64-bit:

alternatives –install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 20000

  • Install javac (if JDK is installed):

alternatives –install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
alternatives –install /usr/bin/jar jar /usr/java/latest/bin/jar 20000

References:

  1. http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. https://ask.fedoraproject.org/en/question/8943/how-to-install-java-in-fedora-17/