Wednesday, October 5, 2016

HOW TO PERSONALISE YOUR UBUNTU MACHINE


How to add my name in login page and home folder




You cannot do it when you get a used laptop and you are logged in with some other logins you got.

For that we need to login to a TTY terminal provided by Ubuntu.

What is a TTY?

Early user terminals connected to computers were electromechanical teleprinters or teletypewriters (TeleTYpewriter, TTY), and since then TTY has continued to be used as the name for the text-only console.
There are 6 virtual consoles in Ubuntu accessed by the keyboard shortcuts Ctrl+Alt+F1 to Ctrl+Alt+F6. You can move away from a text-only console (move the console to the background) by using the keyboard shortcut Ctrl+Alt+F7 
On some systems it is Alt+F8 or Alt+F9, on others it is Alt+F7. The Ctrl is not needed to come back from the tty, only to drop to it.
The actual F key depends on which tty your X session is running in. As far as I know, the default value is 8 (or 7) so Alt+F8 should do it. If not, just try the other values until you hit the right one.
As @mantawork points out in the comments, a generic way is Alt+Left Arrow while in terminal 1. In general Alt+Left Arrow or Alt+Right Arrow will cycle through the ttys. If you repeat that you will eventually be taken back to the one that has your X session.
Thats all about TTYs

Continue...

So do  Ctrl+Alt+F1  

Unix(-like) operative systems decouples the user name from its user identity, so you may safely change the first without changing the other. All permissions, files etc are tied to your identity (uid), not your username.
To manage every aspect of the user database, you use the usermod tool.
To change username (it is probably best to do this without being logged in):
usermod -l newUsername oldUsername
This however, doesn't rename the home folder.
To change home-folder, use
usermod -d /home/newHomeDir -m newUsername
after you changed the username.
Some additional information for not so experienced users:
As I only have ONE user account (administrator), it would not let me change the username ("you are already logged in" was the response in TTY1 (Ctrl+Alt+F1). I found some information to get around this:
  1. Add a new user, e.g. "temporary". If you are still in TTY1:
    adduser temporary
    
    set the password and remaining details 
  2. Add the user to sudo group
  3. usermod -aG sudo temporary
  4. And just type exit. This should bring you to the original login prompt. If not, type exit again.
  5. Change the account type of your new temporary user to administrator:
    In tty7 (Ctrl+Alt+F7, "normal" desktop) login in to your usual account. Change his privileges through the gui: System settings > users account. Click Unlock then change account type to "administrator".
  6. Log out again.
  7. Return to tty1: Login with the 'temporary' user account and password. Change your username and folder as mentioned above. exit (until you get the login prompt)
  8. Go back to TTY7 (Ctrl+Alt+F7) to login on the GUI/normal desktop screen and see if this works.
  9. Delete temporary user and folder:
    sudo deluser temporary
    
    sudo rm -r /home/temporary

Tuesday, August 16, 2016

Freshly Set up Ruby on Rails to build a project

Ruby on Rails on Ubuntu

Ubuntu is a popular platform for Rails development, as are other Unix-based operating systems such as Mac OS X. Installation is relatively easy and widespread help is available in the Rails developer community.

Use a Ruby Version Manager

You’ll need an easy way to switch between Ruby versions. Just as important, you’ll have a dependency mess if you install gems into the system environment. I recommend RVM to manage Ruby versions and gems because it is popular, well-supported, and full-featured. If you are an experienced Unix administrator, you can consider alternatives such as Chruby or Sam Stephenson’s rbenv.
Conveniently, you can use RVM to install Ruby.

Don’t Install Ruby from a Package

Ubuntu provides a package manager system for installing system software. You’ll use this to prepare your computer before installing Ruby. However, don’t use apt-get to install Ruby. The package manager will install an outdated version of Ruby. And it will install Ruby at the system level (for all users). It’s better to use RVM to install Ruby within your user environment.

Hosted Development

You can use Ruby on Rails without actually installing it on your computer. Hosted development, using a service such as Cloud9, means you get a computer “in the cloud” that you use from your web browser. Any computer can access the hosted development environment, though you’ll need a broadband connection. Cloud9 is free for small projects.
Using a hosted environment means you are no longer dependent on the physical presence of a computer that stores all your files. If your computer crashes or is stolen, you can continue to use your hosted environment from any other computer. Likewise, if you frequently work on more than one computer, a hosted environment eliminates the difficulty of maintaining duplicate development environments. For these reasons some developers prefer to “work in the cloud” using Cloud9. Cloud9 is a good option if you have trouble installing Ruby on Rails on your computer.

Prepare Your System

You’ll need to prepare your computer with the required system software before installing Ruby on Rails.
You’ll need superuser (root) access to update the system software.
Update your package manager first:
$ sudo apt-get update
This must finish without error or the following step will fail.
Install Curl:
$ sudo apt-get install curl
You’ll use Curl for installing RVM.

Install Ruby Using RVM

Use RVM, the Ruby Version Manager, to install Ruby and manage your Rails versions.
If you have an older version of Ruby installed on your computer, there’s no need to remove it. RVM will leave your “system Ruby” untouched and use your shell to intercept any calls to Ruby. Any older Ruby versions will remain on your system and the RVM version will take precedence.
Ruby 2.3.1 was current when this was written. You can check for the current recommended version of RubyRVM will install the newest stable Ruby version.
The RVM website explains how to install RVM. Here’s the simplest way:
$ \curl -L https://get.rvm.io | bash -s stable --ruby
Note the backslash before “curl” (this avoids potential version conflicts).
The “—ruby” flag will install the newest version of Ruby.
RVM includes an “autolibs” option to identify and install system software needed for your operating system. See the article RVM Autolibs: Automatic Dependency Handling and Ruby 2.0 for more information.

Check the Gem Manager

RubyGems is the gem manager in Ruby.
Check the installed gem manager version. You may see:
$ gem -v
2.3.1
At the time this was written, a newer RubyGems version was available. Use gem update --system to upgrade the Ruby gem manager:
$ gem update --system

RVM Gemsets

Not all Rails developers use RVM to manage gems, but many recommend it.
Display a list of gemsets:
$ rvm gemset list

gemsets for ruby-2.3.1
=> (default)
   global
Only the “default” and “global” gemsets are pre-installed.
If you get an error “rvm is not a function,” close your console and open it again.

Install Bundler

The Bundler gem is an essential tool for managing gems when developing and running Rails applications. RVM used to install Bundler automatically. As of version 1.26.11 (released March 31, 2015), RVM no longer installs Bundler automatically. You must install Bundler:
$ gem install bundler

Nokogiri

Nokogiri is a gem that is a dependency for many other gems. Nokogiri is a gem that requires compilation for your specific operating system. As such, if your system environment doesn’t match Nokogiri’s requirements, compilation of Nokogiri will fail. If your system is configured properly, you’ll be able to compile Nokogiri. However, compilation takes time. Every time you install the Nokogiri gem, you’ll wait (as long as five minutes).
To save time, install the Nokogiri gem in the RVM global gemset:
$ gem install nokogiri
During installation, Nokogiri will display two lengthy messages in the console. It will also pause without displaying any progress for as long as five minutes. Don’t assume installation has failed unless you see an error message or you’ve waited more than ten minutes.
If installation fails, make sure your system is configured properly (look for help on Stack Overflow).

Rails Installation Options

Check for the current version of Rails. Rails 5.0.0 was current when this was written.
You can install Rails directly into the global gemset. However, many developers prefer to keep the global gemset sparse and install Rails into project-specific gemsets, so each project has the appropriate version of Rails.
If you install Rails at this point, you will install it into the global gemset.
Instead, make a gemset just for the current stable release:
$ rvm use ruby-2.3.1@rails5.0 --create
Here are the options you have for installing Rails.
If you want the most recent stable release:
$ gem install rails
$ rails -v
If you want the newest beta version or release candidate, you can install with --pre.
$ gem install rails --pre
$ rails -v
Or you can get a specific version.
For example, if you want the Rails 3.2.18 release:
$ gem install rails --version=3.2.18
$ rails -v

Create a Workspace Folder

You’ll need a convenient folder to store your Rails projects. You can give it any name, such as code/ or projects/. For this tutorial, we’ll call itworkspace/.
Create a projects folder and move into the folder:
$ mkdir workspace
$ cd workspace
This is where you’ll create your Rails applications.

New Rails Application

Here’s how to create a project-specific gemset, installing Rails, and creating a new application.
$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.3.1@myapp --ruby-version --create
$ gem install rails
$ rails new .

Install and set up git


$  sudo apt-get install git
Step 1: Check for ssh keys                                                       $ cd ~/.ssh                                                                 $ ls
Step 2: Generate ssh key                                                         $ ssh-keygen -t rsa -C remyasenan@gmail.com                                 Add passphrase
Step 3: Add your ssh key to Github                                               $  sudo apt-get install xclip                                               $  xclip -sel clip <~/.ssh/id_rsa.pub    (give the path as .ssh/id_rsa)
  • Go to your github profile 'Account Settings'
  • Click "SSH Keys"
  • "Add SSH key"
  • Paste your key(/home/remya/.ssh/id_rsa.pub) into key field
  • Click Add
Step 4: Test everything                                                          $ ssh -T git@github.com 

Install Java
Install Oracle Java Runtime (JRE) in Ubuntu 
Ubuntu 12.04 (Precise Pangolin) is right around the corner and requests have been pouring in from our loyal readers. One of those requests is how to install Oracle Java Runtime Environment (JRE) 7 in Ubuntu 12.04. I have written about this topic on this blog previously, but not for Precise Pangolin. This brief tutorial is going to show you how to install it in Ubuntu 12.04 Precise Pangolin if you haven’t already done so.
Objectives:
  • Install Oracle Java / JRE in Ubuntu 12.04 (Precise Pangolin)
  • Enjoy!
To get started, press Ctrl – Alt – T on your keyboard to open Terminal. When it opens, run the commands below to remove all other installations of OpenJDK from your system.
sudo apt-get purge openjdk*

After that, go and download Java JRE package from here.  When prompted, save the download. Please select the 32 or 64 bit .tar.gzversion file from the list.

oracle_jre_precise

After saving the file, go back to your terminal and run the below commands to extract the java packages you downloaded.
tar -xvf ~/Downloads/jre-7u3-linux-i586.tar.gz

Next, create your java 7 folder by running the commands below.
sudo mkdir -p /usr/lib/jvm/jre1.7.0

Then move all the extracted files and folders into the java 7 folder.
sudo mv jre1.7.0_03/* /usr/lib/jvm/jre1.7.0/

Next, run the commands below to install / update java 7
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0/bin/java 0
Next, create a plugin folder in your home directory by running the commands below.
mkdir ~/.mozilla/plugins 

Finally, link the java plugin to your profile.
ln -s /usr/lib/jvm/jre1.7.0/lib/i386/libnpjp2.so ~/.mozilla/plugins/

If your system profile is AMD64, then link java to your profile by running the commands below.
ln -s /usr/lib/jvm/jre1.7.0/lib/amd64/libnpjp2.so ~/.mozilla/plugins/ 

Install IDE 

RUBYMINE

Download Rubymine
Open a console and cd into "{installation home}/bin" and type:
   ./rubymine.sh

SUBLIME

Install via the Package Manager(apt-get):

Simply add to your packages:
For Sublime-Text-2:

 $ sudo add-apt-repository ppa:webupd8team/sublime-text-2                           $ sudo apt-get update                                                              $ sudo apt-get install sublime-text
For Sublime-Text-3:
 $ sudo add-apt-repository ppa:webupd8team/sublime-text-3                          $ sudo apt-get update                                                              $ sudo apt-get install sublime-text-installer

Install Mysql Server

  • sudo apt-get update
  • sudo apt-get install mysql-server

Install Mysql Client

On Ubuntu/Debian and other distributions using aptitude:
sudo apt-get install libmysql-ruby libmysqlclient-dev
If the above command doesn't work because libmysql-ruby cannot be found, the following should be sufficient:
sudo apt-get install libmysqlclient-dev

Install Mysql Administration and development tool

Go to Ubuntu Software centre and type 'mysql workbench'


Now its almost ready for a rails application to start up for development in your machine. 

Get set gooo...  :-)