Saturday, February 28, 2015

Clipboard from Command line in Ubuntu || xclip

xclip is a command line utility that is designed to run on any system with an X11 implementation. It provides an interface to X selections ("the clipboard") from the command line. It can read data from standard in or a file and place it in an X selection for pasting into other X applications. xclip can also print an X selection to standard out, which can then be redirected to a file or another program.


sudo apt-get install xclip
# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)

xclip -sel clip < ~/test_file.txt
# Copies the contents of the id_rsa.pub file to your clipboard

Friday, February 27, 2015

How to generate SSH keys for Github in Ubuntu

SSH keys are a way to identify trusted computers, without involving passwords. 

To get the previously generated ssh keys, we can use:


ls -al ~/.ssh

To generate the new SSH keys we can use the below command in the terminal with the corresponding email id:


ssh-keygen -t rsa -C "paul.pronabananda@gmail.com"

It will prompt the filename where to save the key. We can forward with the default file. After that we need to provide the password, and confirm password for this key. The key will be generated. Now its the time of add the key with key-agent.

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Now its the time to make link between my pc and the github application. For this purpose, i will copy the content of the public key and save it in the ssh tab of the personal setting after loggin in to the gitub account. After completion, we need to test the connectivity through ssh.


ssh -T git@github.com

After providing password while prompted, it will give the message as:

Hi ! You've successfully authenticated, but GitHub does not provide shell access.

For details

Thursday, February 26, 2015

Git-Specific Commands

Some mostly used commands for Github. They all begin the same way, with the word “git.”
git init: Initializes a new Git repository. Until you run this command inside a repository or directory, it’s just a regular folder. Only after you input this does it accept further Git commands.
git help: Forgot a command? Type this into the command line to bring up the 21 most common git commands. You can also be more specific and type “git help init” or another term to figure out how to use and configure a specific git command.
git status: Check the status of your repository. See which files are inside it, which changes still need to be committed, and which branch of the repository you’re currently working on.
git add: This does not add new files to your repository. Instead, it brings new files to Git’s attention. After you add files, they’re included in Git’s “snapshots” of the repository.
git commit: Git’s most important command. After you make any sort of change, you input this in order to take a “snapshot” of the repository. Usually it goes git commit -m “Message here.”The -mindicates that the following section of the command should be read as a message.
git branch: Working with multiple collaborators and want to make changes on your own? This command will let you build a new branch, or timeline of commits, of changes and file additions that are completely your own. Your title goes after the command. If you wanted a new branch called “cats,” you’d type git branch cats
git checkout: Literally allows you to “check out” a repository that you are not currently inside. This is a navigational command that lets you move to the repository you want to check. You can use this command as git checkout masterto look at the master branch, or git checkout catsto look at another branch.
git merge: When you’re done working on a branch, you can merge your changes back to the master branch, which is visible to all collaborators. git merge catswould take all the changes you made to the “cats” branch and add them to the master.
git push: If you’re working on your local computer, and want your commits to be visible online on GitHub as well, you “push” the changes up to GitHub with this command.
git pull: If you’re working on your local computer and want the most up-to-date version of your repository to work with, you “pull” the changes down from GitHub with this command.

Pushing Up to Github Repo from Ubuntu [Linux]

To be a proficient programmer its mandatory to work with the projects of Github for development (both Project ans self) purpose. For windows, Github provide the application for easier access. But for Linux OS, we need to configure the Git at our pc. We will have to follow some steps for this purpose. We can check he following steps:

Installing Git for Linux

sudo apt-get install git

Configuring GitHub

 git config --global user.name "pronabananda"
 git config --global user.name "paul.pronabananda@gmail.com"

Creating a local repository

Local repository is which project folder we want to connect with the github project folder. For my case, i have created a folder named testproject. And through terminal i am now in the project folder.

Creating a repository on GitHub

Then i have created a repository in GitHub by click and typing. And after confirmation, i have ogt the code which will have be run in the already opened terminal.



- -Generated Code --
echo "# testproject" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/pronabananda/testproject.git
git push -u origin master
- -


Pushing Up local to Github repo:

Following the above code i have run the below code in my terminals to up my local repo. to Github repo:
--
echo "Its a intial testproject" >> README.md
git init
git add .        [ I have added all the files and folder. For this reason I have used . instead of any specific file name]
git commit -m "Initial commit"
git remote add origin https://github.com/pronabananda/testproject.git
git push -u origin master [For the case of first time, it will ask user id and password of Github Account]
--

For adding already existing repo:
git remote add origin https://github.com/pronabananda/testproject.git
git push -u origin master

--------------------------------------------------
If we want to omit some specific type of files and folder for pushing up to Github Repo from the local. For that case we will have to add a file named .gitignore containing the list of files and folder to be skipped. After pushing up the files, if we run the

git log  

it return the full id of the commit. In future for to download the specific state of the project we will have to use this.
----
root@PaulsofTech-WorkStation:/home/paul/workspace/testproject# git log
commit 8b59ac34c30d00a7c4975fadadf6fea52a98515c
Author: pronabananda
Date:   Thu Feb 26 00:51:15 2015 +0600

    Initial commit
---

Monday, February 16, 2015

Making an application Launcher for a Java(Jar) Application

After installing the Java runtime environment you can create a launch icon like other applications in the sistem by making a *.desktop file.
It makes things easier and prettier!
  • Create a folder in a directory of your choice with the *.jar (the application) and *.png (the application icon) files. In this case the directory I will use is /usr/share/folder. For the ~/folderis a good idea to name it with the application name, for example, if the application is VUE name the folder ~/VUE or ~/vue.
    Open the terminal and run the following code line:
    sudo mkdir /usr/share/folder
    Or open your file manager (Nautilus in this case) with super admin privileges by runing the following code line in the terminal:
    gksu nautilus
    After that, go to /usr/share and create the folder folder with the GUI.
  • Also in the terminal and run the following code line:
    sudo gedit /usr/share/applications/*.desktop
(You could use your editor of choice. In this case was used Gedit.)
  • Paste the following code lines in the file you are editing:
    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=false
    Icon[en_US]=/usr/share/HomeAccountant/HomeAccountant.png
    Name[en_US]=HomeAccountant
    Exec=java -jar /usr/share/HomeAccountant/HomeAccountant.jar
    Comment[en_US]=Home Accountant
    Name=HomeAccountant
    Comment=Home Accountant
    Icon=gnome-panel-launcher
  • Save the file.

Sunday, February 15, 2015

Creating Shortcut in Ubuntu

To create Desktop shortcuts in Ubuntu,gnome-panel package is required first.
  1. Open Terminal. To open terminal click the Dash home from Unity launcher. And type terminal in the search field. And click Terminal.
  2. Type the below code in terminal and hit enter.
    sudo apt-get install --no-install-recommends gnome-panel
    
  3. Then type below code in terminal and hit enter
    gnome-desktop-item-edit ~/Desktop/ --create-new
    
  4. The create launcher window will pop-up,Type application name in the name field and type application name or path or browse in the command field. And click OK button.
  5. Now check your desktop for the shortcut.
  6. If you want your shortcut to appear in the Unity launcher panel (the pop-out one on the left), you can drag it there from the desktop.

Saturday, February 14, 2015

Setting root password on Ubuntu

First enable the root account by running the command...

:~# sudo passwd -u root

Enter your personal password to continue...

Now reset - add the root password by running the command...

:~# sudo passwd root

You will be prompted for a new password for the root user

That's it, you can switch to root with the 'su' command...

:~# su

enter the root password...


Ah, but it's not over, if you try to login via SFTP as root you will find that your ignored, hmm, what have Ubuntu got against root?

Solution is to edit sshd_config...

:~# nano /etc/ssh/sshd_config

and edit line 28 from...

PermitRootLogin without-password

to

PermitRootLogin yes


Save changes and exit...

Then restart SSH...

:~# service ssh restart

There done, now you can login via SFTP as root.

easy LAMP setup in Ubuntu

Source Link

1. Install Apache

To install Apache you must install the Metapackage apache2. This can be done by searching for and installing in the Software Centre, or by running the following command.

 sudo apt-get install apache2

2. Install MySQL

To install MySQL you must install the Metapackage mysql-server. This can be done by searching for and installing in the Software Centre, or by running the following command.


sudo apt-get install mysql-server

3. Install PHP

To install PHP you must install the Metapackages php5 and libapache2-mod-php5. This can be done by searching for and installing in the Software Centre, or by running the following command.

 sudo apt-get install php5 libapache2-mod-php5

4. Restart Server

Your server should restart Apache automatically after the installation of both MySQL and PHP. If it doesn't, execute this command.


sudo /etc/init.d/apache2 restart

5. Check Apache

Open a web browser and navigate to http://localhost/. You should see a message saying It works!


6. Check PHP

You can check your PHP by executing any PHP file from within /var/www/. Alternatively you can execute the following command, which will make PHP run the code without the need for creating a file .


 php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";'

Friday, February 13, 2015

How to install Oracle Java on Ubuntu 14.04

Using a PPA

You can use WebUpd8 PPA (this will download the required files from Oracle and install JDK 8):

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

Manual install

The tar.gz provided by Oracle don't have an actual installation process. You just extract those files to a location you want and add them to your path. So the process is the following:
  • Download a .tar.gz from Oracle (here I will be using jdk-8u31-linux-x64.tar.gz);
  • Extract it to somewhere;
     tar -xvf jdk-8u31-linux-x64.tar.gz (64-bit)
  • Move the extracted folder to /usr/lib/jvm. This is not required but it is the place where Java runtime software is installed
    sudo mv /path/to/jdk1.8.0_31 /usr/lib/jvm/oracle_jdk8
     
  • Create a file /etc/profile.d/oraclejdk.sh with the following content (adapt the paths to reflect the path where you stored your JDK):
    export J2SDKDIR=/usr/lib/jvm/oracle_jdk8
    export J2REDIR=/usr/lib/jvm/oracle_jdk8/jre
    export PATH=$PATH:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/bin
    export JAVA_HOME=/usr/lib/jvm/oracle_jdk8
    export DERBY_HOME=/usr/lib/jvm/oracle_jdk8/db
     
  • Make it executable:
    sudo chmod +x /etc/profile.d/oraclejdk.sh
Done! Those paths will only be recognized after logout or restart, so if you want to use them right away run source /etc/profile.d/oraclejdk.sh.