Wednesday, December 7, 2011

Git Simple commands

Like other repository managers CVS, git is a also a repository manager. Where we can commit our code, so that it can be updated in repository.

Branches : Whole repository can be managed using two branches : local  and remote branches. Master is the root of all branches where all builds from different branches are committed and are in production version. Local branches are the branches specific for particular project. Remote branches are the branches specific to particular project but not created by us.

Useful git commands :

#git push origin branch-name : push the code to specified branch
#git branch : will show your current branch
#git branch  -a :show list of all branches including remote and local and master branches
#git branch -r : show list of all remote branches.
#git stash : save your local changes into git pull or git svn (so that whenever you git pull --rebase changes will automatically comes in)
#git checkout <branch_name> : To switch to specified branch
#git pull --rebase : pull the updated build from current branch
#git logs : to check the last updates in repository
#gitk : is an Graphical interface to git.
#git status : How many local changes you have made.
#git diff <filename> : shows the differences of changes you have made in that file after last commit/update.
#git branch <branch_name> : create a new branch with <branch_name>

Note for more details refer link

Wednesday, November 30, 2011

String vs String Builder vs String Buffer

String : Immutable
String Builder : Mutable + Thread safe
String Buffer : Mutable + not Thread safe.


Performance wise : string is bad , as for every operation it creates new string object hence immutable. whereas String builder/ String Buffer doesn't create new object very time for string operations.

For ex :

String A = A + "BBC"
then for this a new "A" object will be created. So we are creating those many objects of string class.

When using String Builder/ String Buffer, then operations performed on same object and doesn't create new object of String Buffer/ Builder. Hence mutable.
Therefore performance is good.

##PS : For more refer mutable/immutable

Saturday, October 1, 2011

MySQL Reset Root Password

1> First, stop the database
sudo /etc/init.d/mysql stop

2> Start mysqld_safe [which starts the mysql server in safe option] LIke to restart server when some error occured. For more details click here.
Similarily we are using mysqld_safe for resetting lost/forgot password.

/usr/bin/mysqld_safe --skip-grant-tables &
You have to run above using root (sudo -i)
3> It shows mysql daemon started with databases in /var/lib/mysql
Since server is running with --skip-grant-tables flag, means you can access the database without password
Now write the command :
mysql --user=root mysql
Enter your root password
4> Now since we have to update our password in User table. Therefore 
We provide command :
Update user set Password=PASSWORD("Your New Password") Where User='root';
5> Flush Privileges :
Means clear and reload the priviledges.
So command will be 
flush privileges; More about flush option click here
 
6> Exit Mysql
7>Now You have to stop the Daemon Mysql server
It is a two step process :
  • Firstly bring the Background process to Foreground
    Command used for this is :
    fg
     
     
  • Kill the Foreground process
    Ctrl + c [But sometimes Ctrl +z]
8>Now start the mysql 
sudo /etc/init.d/mysql start
9>Now go to mysql
mysql --user=root --pass=newpassword

Monday, September 5, 2011

apt -get broken packages

1>
sudo apt-get clean
will clear your cache, afterwards try again to install the packages you want.
2>
sudo apt-get install -f

Monday, August 29, 2011

Some important commands in ubuntu

1> To remove an application already installed
sudo apt-get remove <app>

2> To remove application already installed with all config files.
sudo apt-get --purge remove <appn>

3>To list all installed packages
dpkg --list
 dpkg --list less
dpkg --list | grep -i 'app'




Sunday, August 28, 2011

How to make password protected folder in Ubuntu

Steps are :

## Install cfs using sudo apt-get install cfs

## Create the encrypted directory (let say lock)
$ cmkdir lock (It will ask for key i.e passwd for folder should not less than 16 chars)

## So encrypted directory lock is created, now we have to put our secret files, this is done by attaching another directory to lock ( let say directory is clock where we put our personal files)
$ cattach lock clock (again it will ask for key)

## You can look a new directory called /crypt is created  and clock folder is inside it where you put ur personal files. /crypt/clock

## Move ur personal stuff to clock
$ mv personal-files /crypt/clock

## Now, to close ~/lock so no one can get into it, we need to unattach the directory with the cdetach command

## $ cdetach clock 

NOTE : Next time if u want to acess ur personal stuff firstly u should start cfsd so, /etc/init.d/cfsd start and then reattach using cattach and then 
sudo umount -f /crypt/clock


Now u can acess ur files. 
After that u shud deattach using cdetach so that it become protected again.
 

Monday, August 22, 2011

Loading Servlet in Tomcat 5.5.29

1> After installing tomcat 5.5.29, CLASSPATH needs to be set for servlet-api.jar file (which is located in apache-tomcat (in my case it is tomcat0)/common/lib/servlet-api.jar). So CLASSPATH = $CLASSPATH:$CATALINA_HOME/common/lib/servlet-api.jar , where CATALINA_HOME=apache-tomcat folder.

export CLASSPATH

2>Create a directory where you compile all your servlet codes. Let say /usr/Servlet.
Also CLASSPATH needs to be set to this folder also.
i.e CLASSPATH=/usr/Servlet.
export CLASSPATH

3>Create your servlet code (let say example.java). Now compile it to create example.class.
sudo javac -classpath /opt/tomcat0/common/lib/servlet-api.jar HelloWorld.java
where path for servlet jar should be included. i.e

sudo javac -classpath <servlet-jar-path> <example.java>

4>Now goto CATALINA_HOME/webapps/ROOT/WEB-INF
--> Create a classes folder (if not present) and copy example.class file to classes folder.
--> Now in web.xml file add these lines
<servlet>
<servlet-name>example</servlet-name>
<servlet-class>example</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>example</servlet-name>
<url-pattern>/example</url-pattern>
</servlet-mapping>

Above entries to be created inside <web-app>...</web-app> tags available in web.xml file

5> Now stop and start the tomcat .
In my case :
Stop : sudo /etc/init.d/tomcat0 stop
Start : sudo /etc/init.d/tomcat0 start.

6> Goto to browser and type :
http://localhost:8080/example


Thats all

Sunday, August 21, 2011

To Do List After installing Fresh Ubuntu 10.04 lucid

You can go to the link given as Here 
Repository update  source list is quite nice. (Follow the same instructions as given in link to update repositories).

Speakers donot mute after plugging headphone in Dell Vostro

You can follow this link here
For me Downloading and installing driver (deb)  here  worked for me.

Monday, August 15, 2011

How to enable Wireless on ubuntu

Install following packages from repositories :
1> bcmwl-kernel-source
2> b43-fwcutter
3>bcmwl-modaliases 
After that reboot your machine. 
 

Sunday, August 14, 2011

Forgot Windows 7 password

To reset windows 7 password , use Britec software.
1>http://www.briteccomputers.co.uk/downloads/BritecRecoveryConsole.iso
Download iso into pendrive(bootable)
2> Goto bios and change boot options.
3> On running britec goto password option and select on user whose password you want to reset.

Friday, August 12, 2011

History of commands in shell

Can be seen on bash_history file.
Can be found in /home/bharat/.bash_history

Monday, July 11, 2011

Grub Menu Timeout

1> sudo gedit /boot/grub/menu.list
2> set timeout (value in seconds)
rebot the system.

Wednesday, April 20, 2011

Macintosh on Ubuntu

We can get the feel and look of  Macintosh on Ubuntu.
Steps:
1> Download Macbuntu or mac4lin from sourceforge.
2> Install it from installation file ./install.sh (run it on terminal)
3> Also install dockey (if not provided in downloaded folder of macbuntu or mac4lin)
4> Customize it according to your need.

NOTE: Before installation make sure that you are using the appropriate version of ubuntu for which Macbuntu or mac4lin are compatible.

Sunday, April 17, 2011

Password Reset in Ubuntu

1> During Grub loader press ESC
2> Go to Recovery Mode of Ubuntu
3> Select Drop to Root user
4> On terminal write passwd <username>
    It will ask for new password reset.

Friday, March 18, 2011

Repository dpkg Lock error

E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
This happens if installation is still going on and you are trying to install another package or may be you have killed the ongoing installation.

Therefore for this write on terminal as:
sudo rm /var/lib/dpkg/lock
Now you can use sudo apt normally.

distribution installation through bin

1>Just go to bin and write ./filename   like in ocrep
2> If it doesnot work write  :
chmod 755 <file name>.bin

Also u have to do sudo to do this.
like sudo ./filename

Thursday, March 17, 2011

Compiz Fusion

For making eye candy 3D look to our desktop we use compiz fusion application.
More details can be found Here.

Wireless in Ubuntu 10.04

sudo apt-get install broadcom or for more info refer the following link.
here

Sunday, February 20, 2011

Recovering your Firefox Bookmark

Windows:
1> Goto : C:/Application Data/Mozilla/Firefox/Profile/../Bookmark backup
       save this profile folder to some other location.
2> After reinstalling Mozilla again copy Bookmark backup to same location
3> Open Mozilla -> Open Bookmarks tab -> click on Organize Bookmark -> goto import and backup tab -> restore ->add file.

Similarily in Ubuntu      

Saturday, February 19, 2011

Check the version of shell

1> echo $SHELL   (Since it is an environment variable)
    /bin/bash
2>/bin/bash --version
   this will give the version of shell as output.

SSH

SSH : is know as secure shell used to secure remote login over insecure network.
You can login to other machine, assuming ssh server is running on machine you want to login.
1> install ssh (sudo apt-get install ssh)
2>remote login:
     - Let us say remote system is: bharatj@nsl-32.cse.iitb.ac.in or bharatj@ipaddress
     - Write on terminal as follows:
     - ssh bharatj@nsl-32.cse.iitb.ac.in
     - Ask for password (enter your remote system password)
     - Now you are on remote machine which can be seen as
     - bharatj@nsl-32$ (terminal prompt)
     - Now you can browse through the contents using cd etc commands.

Copying file from remote machine to local machine:
1>Write command on terminal as follows:
     scp bharatj@nsl-32.cse.iitb.ac.in:sourcepath/source-file destination-path
     For ex: source path is /users1/pg09/bharatj/Desktop
                 source file is tracker.c
                 destination path /home/bharatj/Desktop
     So after this tracker.c will be copied on local machine on desktop location.

                     
Copying directory from Remote machine to Local machine:
1> Write on terminal :
      scp -r bharatj@nsl-32.cse.iitb.ac.in: /users1/pg09/bharatj/Desktop/experiment /home/bharatj/Desktop
     This will copy directory experiment from remote machine to local machine on Desktop.

Note: scp -------------- for file transfer
          scp -r -------------for directory

Copying file from Local machine to Remote machine:
1> scp file.pdf bharatj@nsl-32.cse.iitb.ac.in:/users1/pg09/bharatj/Desktop
      This will copy file file.pdf from Local machine to remote machine on Desktop.

Copying directory from Local to Remote Machine:
1>scp -r MTP bharatj@nsl-32.cse.iitb.ac.in:/user1/pg09/bharatj/Desktop
    This will copy directory MTP from local machine to Remote machine Desktop.

To find Ip address and other information of your machine through terminal

1> open terminal
2>ifconfig

Monday, February 14, 2011

youtube downloader in Ubuntu

1> Go to fire fox add ons and install download helper from here here
2> Install it (by double clicking when saved on pc)
3> Go to view tab -> toolbar ->customize. and then select download helper icon and drag on toolbar.
4> Open you tube and scroll down arrow in download helper it will save the file.

For more click on this video

Sunday, February 13, 2011

Moving Window buttons to right on Ubuntu

1> press Alt + F2(function key)
2> type gconf-editor and click run
3> click + button in apps option and then navigate to metacity
4>go to button layout and make changes

refer : here  for more information.

Saturday, February 12, 2011

wine

wine is basically used to run windows application on linux.
install wine using sudo apt-get install wine

*goto setup and write wine setup.exe

wget

wget : is a non interactive way of downloading software from web. It supports http, ftp, https protocols as well as retrieval from http proxies.
wget is non interactive means it can run in a background without user logged in.
ex: wget <URL>  on terminal. where URL is the URL of the software package from where it can be downloaded.
various options are also present  (see man wget).
for ex :wget http://www.skype.com/intl/en/get-skype/on-your-computer/linux/

Finding the cpu width

1> Install cpuid by:
           sudo apt-get install cpuid
     cpuid command is also useful for finding various entities about processor.
2> write on terminal :
          sudo lshw
in second or 3rd paragraph with heading cpu 1 (gives the description of cpu like processor name intel core2 duo, and from their we can see width of cpu).

PPA /Personal package archieve

Using PPA we can distribute our own software package to other Ubuntu users, similarly like we download software packages from ubuntu resource. It means ubuntu users can install your software package in the same way as they install standard ubuntu software packages and also receive updates when you make updation to your package.
Package published by you will remain in your PPA untill and unless you remove your package.  Size limit for PPA is 2GB.
1> Firstly you should activate whether your PPA is individual or team PPA. For this you have to do some sort of login in your profile page.
2>After this launchpad generate a key, which is used for package.


** How to install software from PPA ?
1> Visit PPA overview launchpad page and look for heading " Adding this ppa to your system" . Make a note about location which looks like ppa: user/ppa-name.
let us say " ppa: gwibber-daily/ppa
write on terminal : sudo add-apt-repository ppa: gwibber-daily/ppa

2> Your system will now fetch the PPA key.
3> sudo apt-get update
Now you are ready to run sudo apt-get install <sp> (from ppa).


NOTE : Package you are installing from PPA is your own trust towards the publisher.

Useful Links :a>https://help.launchpad.net/FrontPage
                      b>https://help.launchpad.net/Packaging/PPA#keys?action=show&redirect=PPAKeys
                      c>https://help.launchpad.net/Packaging/PPA/InstallingSoftware
                      d>https://help.ubuntu.com/community/Repositories/Ubuntu#Adding%20Repositories%20in%20Ubuntu



Repository GUI (Synaptic package)

* GUI based repository management is basically done Software Sources.
   System -> Administration -> Software Sources.
Select repository from Third Party Software or Other software tab, you can add or delete any repository (select / un select). After this click reload (so that changes will be made). [Revert is used to undo the changes.]


Ubuntu Software Center is just like Control Panel Add or Remove option.

Friday, February 11, 2011

PDF Annotator

We can use various annotators like:
1> Okular : sudo apt-get install okular
2> Xournal : sudo apt-get install xournal

Record my desktop

*Installation
sudo apt-get install recordmydesktop

*Capturing video : write on terminal
recordmydesktop

* Stop recording:
CLTR + c

Repository

Thousands of software packages are stored in archives which are commonly referred to as repositories. Repositories make it very easy to install software packages provided you have Internet connection. It also provide high level security as each software package in archives are thoroughly tested and built specifically for each version of Ubuntu.
Software repositories are organized into 4 categories according to level of support provided by Ubuntu.
                         + Main : oficially supported software by Ubuntu.
                         + Restricted : software which are not available under completely free license.
                         +Universe : not officially supported software
                         +Multi verse : software which are not free.
Note : After installation two repository component are available viz Main, Restricted.
Repository can be edited(modified) by making some changes in /etc/apt/source.list file.
Managing Repository Through Command Line :

Since we know apt stores a list of repository or software channel in a file.
  For modification in repository we have to make changes in /etc/apt/source.list.

Note : It is a good idea to make a backup of source.list before editing source.list.
          sudo cp /etc/apt/source.list /etc/apt/source.list.backup

Now open source.list for editing -
    gedit /etc/apt/source.list

  Explanation of various contents of source.list :

 deb http://us.archive.ubuntu.com/ubuntu  hardy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu hardy main restricted

1> All lines starting with # or ## are comments.
2>Lines without # are apt repository lines and are read by synaptic, apt-get etc.
       Lines starting with:
        2.1> deb : These repositories contains binary or pre compiled packages which are required by most of the users.
       2.2> deb-src : These repositories contains the source code of packages which are useful for developers.
3> deb/deb-src is then followed by location of package on Internet like http://archieve.ubuntu.com/ubuntu i.e URI(Uniform Resource Identifier).
- In our case it is : ftp://ftp.iitb.ac.in/os/ubuntu/archives/
4> hardy : is the name or version of your distribution.
- For Ubuntu 10.04 it is  : Lucid Lynx
5> Followed by repository component.


Adding Repository : Refer here
If we want to add Multi verse and universe repositories then we have to add lines with multi verse and universe. But remember to add lucid-update. So that we can get updated software pa
ckages list from multi verse and universe repositories. 

sudo apt-get update : For updation of repositories.


NOTE: 1> In some ubuntu versions Launchpad ppa i.e adding repository through commandline works like ubuntu 9.10
ex: sudo add-apt-repository ppa:<repository-name>
           2> Make sure repositories that u r adding should be compatible with your Ubuntu version, otherwise it may cause inconsistency to your system and may be u have to re install Ubuntu.
         3> When u edit source.list then always update repository by sudo apt-get update.
        4> always take backup when editing source.list 


Thursday, February 10, 2011

APT Ubuntu

* apt-get is a powerful command line tool used with ubuntu advanced packaging tool(APT) for performing functions like

Wednesday, February 9, 2011

Packages to be installed after installing fresh Ubuntu

UNETBOOTIN

UNETBOOTIN is used to make bootable pen drive(USB) for various distributions.
1> Install Unetbootin
        sudo apt-get install unetbootin

2>After installation goto
      Applications ->System Tools ->Unetbootin

3>Then select the distribution and version for already downloaded installation cd (ISO)
4> Check on ISO in disk image option and browse the source file for distribution(i.e iso to be copied on usb)
5> Click OK will extract the ISO image of distribution and copy it on USB
6> After completion, then select Reboot now, and it will reboot the system.
7> Go to BIOS and change boot option.


NOTE : For more information goto :a)http://www.howtogeek.com/howto/linux/create-a-bootable-ubuntu-usb-flash-drive-the-easy-way/
                                              b)http://unetbootin.sourceforge.net/