—————– தமிழ் வாழ்க ————————

Archive for the ‘Ubuntu/Linux’ Category

GitHub : A Practical Approach

GitHub is a web-based GIT repo for version control system. This tutorial is for the beginners, who are about to use git / github.

GitHub is mostly like an social media, where you can build your profile, upload projects, share it and connect with other users by  following their accounts, contributing to other project by forking it, adding features and commit it back to original source and so on.

naga2raja_github

My GitHub Page

I am not a frequent user of Github, but I use git a lot. Git is a core of GitHub, used to manages the source code without overwriting any part of the project. At any point of time, you can revert back your changes.

Few terms you need to understand before diving in:

Repo: A directory or storage space where your projects resides. Sometimes GitHub users shorten this to “repo.” It can be local to a folder on your computer, or it can be a storage space on GitHub or another online host. You can keep code files, text files, image files, you name it, inside a repository.

Version Control: For example, if you have a Word file, you either overwrite every saved file with a new save, or you save multiple versions. With Git, you don’t have to do it. It keeps “snapshots” of every point in time in the project’s history, so you can never lose or overwrite it.

Commit:  When you commit, you are taking a “snapshot” of your repository at that point in time, giving you a checkpoint to which you can reevaluate or restore your project to any previous state.

Branch: If multiple people work on same project, they take a “branch”of the main project “master”, do their changes and then “merge” that branch back with the “master”.

Git Installation:

To install git, use the following command.

  • Debian/Ubuntu

          $ sudo apt-get install git

  • Fedora / Redhat

          $ yum install git

  • OpenBSD

          $ pkg_add git

  • Windows:

Download the executable file from http://git-scm.com/download/win

Git Commands:

After installing git, type “git” in the command-line to see its usage and list of commands.

git_commands

List of Git commands

There are quite a few import git commands we use most frequently, they are,

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. It also creates a .git folder inside it.

git config: Short for “configure,” this is most useful when you’re setting up Git for the first time.

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 -m indicates 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 time-line 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 “mybranch,” you’d type git branch mybranch.

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 master to look at the master branch, or git checkout mybranch to 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 mybranch would take all the changes you made to the “mybranch” 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.

We will see the usage of the above commands practically in the following sections.

Configuring GitHub:

First, create an account in GitHub, and then follow the steps.

Step 1: config

we need to setup the user-name and user-email parameters. To do it,

$ git config –global user.name “<Your Name>”

$ git config –global user.email “<Your E-mail same as in GitHub account>”

git config user.name, user.email

git config user.name, user.email

E-mail should be the same email that you had used in GitHub account.

Step 2: Creating a Repo

Online repo creations – In GitHub:

  • In GitHub profile page, select the “Repositories” tab and click “New” button.
Repository Creation Step 1

Repository Creation Step 1

  • Then, In the repository creation page, specify the name of your repository, descriptions, access parameters like public or private (Private is not Free), which licence and also you have an option to create Readme files.
Repository Creation Step 2

Repository Creation Step 2

  • After repo creation, you will see the “Project page” as below.
Project page

Project page

Local Repo Creation – In your PC:

We had made a github project to live online, but that’s not where we’ll be working. The bulk of your work is going to be done on your computer. So we need to actually mirror that repository to a local directory.

Initializing Git

Initializing Git

  • Initialize Git. To do that create a folder and run init command.
    • $ mkdir Designs
    • $ cd Designs
    • git init
  •  After you initialize git, a .git folder will be created which allows you to run all git commands.
  • Add some contents inside the folder.
  • We are on the master branch of the project, which makes sense since we haven’t “branched” of it. Secondly, the files that we added are “untracked” files, which means Git is ignoring it for now. To make Git notice that the file is there, then we need to add it by,

    • git add <file_name>
  • After adding our files, we need to take a “snapshot” of the project so far by “committing” it:
    • $ git commit -m “<Message for your understanding>”

Refer the following screenshot for the above commands and the usage of “git status

git Init, git status, git commit

git Init, git status, git commit

Step 3: Sync the local repo with Online repo (GitHub)

  • First, we need to tell Git that a remote repository actually exists in Github. Goto that github page, copy the URL and add .git to the end of the url and parse it to “git remote add” command.

    • $ git remote add origin https://github.com/naga2raja/Designs.git
git remote

git remote

  • To confirm,whether git identifies the remote repository, type the        following command to check:

$ git remote -v

  • This command gives you a list of all the remote origins your local repository knows about. Until now we have only Designs.git that we just added. It’s listed twice, which means it is available to push information to, and to fetch information from.
  • Git push – Its time for us to push our changes to GitHub. This can be done by,
    • $ git push
git push error

git push error

  • If you get any error messages like mentioned in the side screen-shot, then just pull it first and then push it.
  • You need to give the credentials of the GitHub account while pushing the data into your account.
git pull and git push

git pull and git push

  • After you pushed the changes successfully, you can see your files in the GitHub project page.

    After pushing the files to GitHub

    After pushing the files to GitHub

Thats All Folks !!! We will meet in the next tutorial of git about forking the existing repositories from GitHub, adding some features and commit back to GitHub.

Keyboard Shortcuts – Ubuntu

General keyboard shortcuts

Ctrl + A = Select all
Ctrl + C = Copy the highlighted content to clipboard
Ctrl + V = Paste the clipboard content
Ctrl + N = New (Create a new document, not in terminal)
Ctrl + O = Open a document
Ctrl + S = Save the current document
Ctrl + P = Print the current document
Ctrl + W = Close the close document
Ctrl + Q = Quit the current application
Keyboard shortcuts for GNOME desktop

Ctrl + Alt + F1 = Switch to the first virtual terminal
Ctrl + Alt + F2(F3)(F4)(F5)(F6) = Select the different virtual terminals
Ctrl + Alt + F7 = Restore back to the current terminal session with X
Ctrl + Alt + Backspace = Restart GNOME
Alt + Tab = Switch between open programs
Ctrl + Alt + L = Lock the screen.
Alt + F1 = opens the Applications menu
Alt + F2 = opens the Run Application dialog box.
Alt + F3 = opens the Deskbar Applet
Alt + F4 = closes the current window.
Alt + F5 = unmaximizes the current window.
Alt + F7 = move the current window
Alt + F8 = resizes the current window.
Alt + F9 = minimizes the current window.
Alt + F10 =  maximizes the current window.
Alt + Space = opens the window menu.
Ctrl + Alt + + = Switch to next X resolution
Ctrl + Alt + – = Switch to previous X resolution
Ctrl + Alt + Left/Right = move to the next/previous workspace
Keyboard shortcuts for Terminal

Ctrl + A = Move cursor to beginning of line
Ctrl + E = Move cursor to end of line
Ctrl + C = kills the current process.
Ctrl + Z = sends the current process to the background.
Ctrl + D = logs you out.
Ctrl + R = finds the last command matching the entered letters.
Enter a letter, followed by Tab + Tab = lists the available commands beginning with those letters.
Ctrl + U = deletes the current line.
Ctrl + K = deletes the command from the cursor right.
Ctrl + W = deletes the word before the cursor.
Ctrl + L = clears the terminal output
Shift + Ctrl + C = copy the highlighted command to the clipboard.
Shift + Ctrl + V (or Shift + Insert) = pastes the contents of the clipboard.
Alt + F = moves forward one word.
Alt + B = moves backward one word.
Arrow Up/Down = browse command history
Shift + PageUp / PageDown = Scroll terminal output
Keyboard shortcuts for Compiz

Alt + Tab = switch between open windows
Win + Tab = switch between open windows with Shift Switcher or Ring Switcher effect
Win + E = Expo, show all workspace
Ctrl + Alt + Down = Film Effect
Ctrl + Alt + Left mouse button = Rotate Desktop Cube
Alt + Shift + Up = Scale Windows
Ctrl + Alt + D = Show Desktop
Win + Left mouse button = take screenshot on selected area
Win + Mousewheel = Zoom In/Out
Alt + Mousewheel = Transparent Window
Alt + F8 = Resize Window
Alt + F7 = Move Window
Win + P = Add Helper
F9 = show widget layer
Shift + F9 = show water effects
Win + Shift + Left mouse button = Fire Effects
Win + Shift + C = Clear Fire Effects
Win + Left mouse button = Annotate: Draw
Win + 1 = Start annotation
Win + 3 = End annotation
Win + S = selects windows for grouping
Win + T = Group Windows together
Win + U = Ungroup Windows
Win + Left/Right = Flip Windows
Keyboard shortcut for Nautilus

Shift + Ctrl + N = Create New Folder
Ctrl + T = Delete selected file(s) to trash
Alt + ENTER = Show File/Folder Properties
Ctrl + 1 = Toggle View As Icons
Ctrl + 2 = Toggle View As List
Shift + Right = Open Directory (Only in List View)
Shift + Left = Close Directory (Only in List View)
Ctrl + S = Select Pattern
F2 = Rename File
Ctrl + A = Select all files and folders
Ctrl + W = Close Window
Ctrl + Shift + W = Close All Nautilus Windows
Ctrl + R = Reload Nautilus Window
Alt + Up = Open parent directory
Alt + Left = Back
Alt + Right = Forward
Alt + Home = go to Home folder
Ctrl + L = go to location bar
F9 = Show sidepane
Ctrl + H = Show Hidden Files
Ctrl + + = Zoom In
Ctrl + – = Zoom Out
Ctrl + 0 = Normal Size

(For those who want to configure your own keyboard shortcuts, you can do it at System->Preferences->Keyboard Shortcuts.)

Which one is your favorite keyboard shortcuts?

Is there anymore left..

Changing Prompt Name and Set Window title – Ubuntu Terminal

There are many situations where we need to change the prompt name and set a window title in our Ubuntu terminal.

Follow the steps mentioned below.

$ sudo gedit ~/.bashrc
Please do the following changes in the file.

Comment out the existing PS1 line and add a new line with your text.

if [ “$color_prompt” = yes ]; then
#    PS1=’${debian_chroot:+($debian_chroot)}\[33[01;32m\]\u@\h\[33[00m\]:\[33[01;34m\]\w\[33[00m\]\$ ‘

       PS1='<your_text_here>:\w\$ ‘

else
#    PS1=’${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ‘
       PS1='<your_text_here>:\w\$ ‘
  fi

Then save the file and source it to see the changes.

$ source ~/.bashrc

Now you will see your prompt name change in your Ubuntu terminal. Doing this will only change the prompt, but not the title. The title will remain the same as the previous. There are many ways to set the title for Ubuntu terminal. I will suggest one of them.
Install wmctrl package.

$ sudo apt-get install wmctrl

Then

$ wmctrl -r :ACTIVE: -N “<your title>”

Thats It!!!

Making ADB work for LAVA, BSNL Penta and other low cost models

Most of the Indian tablets doesn’t recognize when we put

$ adb devices

List of devices Attached

To solve this, we need to add the vendor id to ~/.android/adb_usb.ini

$ echo "0x2207" >>~/.android/adb_usb.ini

To get the vendor ID, please use

$lsusb

Bus 002 Device 008: ID 2207:0010  

Here, 2207 is the vendor ID.

Added the following lines to /etc/udev/rules.d/51-android.rules:

$ sudo vim /etc/udev/rules.d/51-android.rules

and add the following lines.

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", 
ENV{PRODUCT}=="207/*", MODE="0666" 
SUBSYSTEM=="usb", SYSFS{idVendor}=="207", MODE="0666"

After making the above changes, restart the adb server and check the device again.

$ adb kill-server  
$ adb start-server 
$ adb devices 

Now we can see the device listed on the

List of devices attached

0123456789ABCDEF device

If the devices is listed like

?????????????????? device

it means that adb doesn’t have the permission. So you need to kill the adb server and start as sudo.

$ adb kill-server

$ sudo <path-to-adb> start-server

$ adb devices

Hope it will work perfectly.

 

Tips and Tricks for Ubuntu after Installation Gizmo’s Freeware

Tips and Tricks for Ubuntu after Installation Gizmo's Freeware.

Power of Linux Terminal …

The following are the funny and useful things in Linux terminal.. Just try out and enjoy…..

To Watch Star Wars :

telnet towel.blinkenlights.nl

Chat with a bot :

telnet the-funk.net 7000

To have your name in banner:

sudo apt-get install sysvbanner

banner <your name>

To checkout how long your machine has been running:

uptime

To see the arbitrary precision calculator (7^500 is interesting! That’s 7 to the 500th power)

bc

To checkout your fortune:

sudo apt-get install fortunemod

fortune

Funny Cowsay:

sudo apt-get install cowsay

cowsay ‘<your message>’

Note: Don’t forget the single quotes

Games on Terminal:

sudo apt-get emacs23

Note: emacs version may change based on your system versions (replace 23 with 21 if the package not found error occurs..)

To play ‘snake’

emacs23

Once emacs23 opens, hit…

Esc>>”X”

Type in…

snake

To play ‘tetris’

emacs23

Once emacs23 opens, hit…

Esc>>”X”

Type in…

tetris

Some Useful System Commands :

Show some computer stats

lspci

Access a dictionary through terminal (must have a working internet connection):

Note: Replace ‘word’ with whatever you’d like to search for (without quotes)

sudo apt-get install curl

curl dict://dict.org/d:word

Check system temperature and battery charge:

acpi -t

See a list of all running processes

ps aux

View the current time, date, and year

date

Show a simple calendar

cal

See what programs are running with the path names

ps -aux

See your current IP address

ifconfig -a

See what your system is doing at startup

dmesg

Show information about the computer users

finger -l

Show current Ubuntu version

cat /etc/issue

System Recovery

Backup xorg.conf

sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_backup

Replace current xorg.conf with a previously made backup

sudo cp /etc/X11/xorg.conf_backup /etc/X11/xorg.conf

Delete auto xorg.conf backups

sudo rm /etc/X11/xorg.conf.2007*

Use nano to edit xorg.conf (works in “terminal-only” mode)

sudo nano /etc/X11/xorg.conf

Keyboard Shortcuts

Terminal keyboard shortcut for paste

Ctrl>>Shift>>Alt>>”V”

Or…

Shift>>Insert

Advanced Users Only

Open up a file browser with all privileges

gksudo nautilus

Edit color options (advanced users only)

gedit .gtkrc-2.0

Give a .sh file executable priveledges

chmod +x

To clear all of the past commands you have run in the terminal history type:

history -c

Funny Gnome:

If you use GNOME

Alt+F2 in your keyboard

and then type “free the fish”

SUPER COW POWERS

aptitude -h

Read the last line

apt-get moo

aptitude moo

aptitude -v moo

aptitude -v -v moo

aptitude -v -v -v moo

aptitude -v -v -v -v moo

aptitude -v -v -v -v -v moo

apt-get moo

Debian’s Top Secret List of planned Release Names

zcat /usr/share/doc/linux-image-`uname -r`/changelog.Debian.gz | egrep -e “Release”

zgrep “The.*Release” /usr/share/doc/dpkg/changelog.Debian.g

 

To play song or movie from terminal:

vlc <song name>

if vlc not installed, either try installing vlc using

sudo apt-get install vlc

or

play using totem

totem <song or movie name>

 

Ubuntu Gmail Notifier GmailWatcher Gets New UI, Instant Notifications

GmailWatcher
GmailWatcher is a Gmail notifier especially designed for Ubuntu. It supports multiple accounts, labels (you can select for which labels to receive notifications) and comes with Ubuntu Messaging Menu integration / NotifyOSD support.
The application displays the unread email count in the Ubuntu Messaging Menu and clicking it, you can see details such as the sender, title and so on, each under its label – all without having to open your browser.

GmailWatcher
For the past few weeks, Owais Lone, the GmailWatcher developer has been rewriting the application which now supports GTK3 and comes with a new user interface (see screenshot above).
Besides the UI, GmailWatcher also got some new features like instant notifications, easy account switching, displays unread email count on the Unity launcher (only when opening the main GmailWatcher window – you can pin it to the launcher to always see the number of unread emails) and more.
The new GmailWatcher is not yet stable and is only available for Ubuntu 11.10 Oneiric Ocelot for now. If you’re already using Oneiric and want to try one of the best Gmail notifiers for Ubuntu, install it using the commands below:
sudo add-apt-repository ppa:loneowais/gmailwatcher.dev sudo apt-get update sudo apt-get install gmailwatcher <source: Webupd8> 

Tag Cloud