Pages

Saturday, February 4, 2012

Configuring ip for lan while connecting two users using ssh.

Firstly, while connecting lan between two users using an lan cable, you have to neccessarily set the ip for two users. for this, after connecting the lan cable between two systems, now type:

              sudo ifconfig
  to check whether ur ip is set or not. If the 'inet6 addr :' is blank as shown above. Then u have to set the ip. For this type,

              sudo ifconfig eth0 192.168.1.4
 the 3rd one ie, 'eth0' may be different in different systems, suppose 'eth1' is another one. As it is shown when u type ifconfig, now regarding ip, '192.168.1.' is general used for lans based on class addresses. Now rest you can decided, i have given '4' to last one. Each system should have different ip, one system with '192.168.1.4' and another with '192.168.1.6' as you like.


ssh :secure shell 
for sharing the files through lan or wifi, you need ssh. You need to check whether the connection is established between two users, ie, type ' ping ' followed by the ip of the other computer to which u have connected. for eg:

ping 192.168.1.4

After that, type ssh in terminal to access the other systems terminal, following the ip of the other ie.


sudo ssh 192.168.1.4


Also graphical u can share a folder in you system or mount the other computer folders using the ssh, for this go to the 'connect to server' and choose the ssh and then type the ip of the other system.


if an error occurs indicating " host authentication or verification key failed" then, u have to remove the key, since changing lan connections with different system with ubuntu may arise this errors. Actually, the host key had been changed for the currently connecting system. so change the host key using the command :

ssh-keygen -f [path of hostkey filename] -R [ip of connecting system]

 sometimes, defaultly the hostkey filename would be in location '/home/[username]/.ssh/known_hosts'. Replace [username] with ur systems username.
 
you can also try the below one for the problem 
" ssh: connect to host 192.168.2.4 port 22: Connection refused "


Actually , The above error looks more like sshd is not running on host 192.168.2.4 .Try installing 'openssh-server' and if it doesnot work, then try below one:

#cd /root/.ssh

#vi known_hosts
*delete everyting on that file

#service sshd restart


Tuesday, January 31, 2012

BITBUCKET REPOSITORY CREATION

CREATING A NEW REPOSITORY

create a file named ".hgrc" and type the codes below with the username of bitbucket followed by the mail id for example

       after saving close it

1. Create a account in bitbucket
2. thus after creating the bitbucket account, click on the 'Repository' above for creating a repository , untick the private option near the name followed by clicking create repository .Afterwards copy the link given below.
3. install 'mercurial' package by typing 'sudo apt-get install mercurial'
4. now type 'hg init' in the terminal
5. again type 'hg clone ' followed by the copied link. This creates the directory of the name given.
6. Enter the directory and type 'hg add' followed by all the file names in the directory.
7. now type 'hg commit -m "any name" '
8. type 'hg push' followed by the copied link , thus after completing with asking the password of the bitbucket.


UPDATING THE EXSISTING REPOSITORY

1. copy the new files to the already created repository within the system
2. now add the new files names following the 'hg add' command within terminal
3. now follow the above step from 7
  

Wednesday, January 25, 2012

Grub Error, no such Partition found- fixing in ubuntu

Firstly, insert your current linux os bootable using either cd or usb. Now, enter into the terminal by selecting the trying option. After, taking the terminal type

sudo fdisk -l


which prints the every the partition. Select your linux partition. Mount the linux partition using mount command, ie. suppose consider /dev/sda6 is your linux partition, mount it by the following command. Before that create a directory for mounting the drive, ie,

sudo mkdir  /media/sda6

now after creating, mount the drive in the created 'sda6' directory

sudo mount   /dev/sda6  /media/sda6

after mounting, type the below command for installing grub from cd or usb

sudo grub-install --root-directory=/media/sda6 /dev/sda

thus u have installed the grub

Sunday, January 22, 2012

" No such partition, Grub Rescue error in Windows " Solution

This error occurs usually for the Laptop users, who tries to delete the Linux partition within Windows. Since, installing Linux, the Grub is installed in the Master Boot Record (MBR), which then replaces the Windows boot-loader. So, deleting the linux partition after entering windows will definitely cause the error. The Grub looks for the 'Grub file' of the linux partition, which doesn't exists and results in errors.
             For solving the it, you need Windows boot-able CD.  After inserting the CD, now select the Repair options to enter the recovery console or command prompt. Now enter
        diskpart

Select the partition, which ever is your boot-table drive. Now enter the into the boot-able drive, by type the drive letter followed by colon and press enter. For example : consider  'F' to be the bootable drive,
              C:\Users\amith> f:
              F:\>
After entering the bootable driver, enter into the 'boot' folder
             cd  boot
              
now type 
             bootsect  /nt60  SYS  /mbr
                 or
              bootrec   /nt60 SYS  /mbr 



Creating Executable files in C

Unlike any other languages C is the most efficient language which has rich set of operators and due to its non-restrictions and generality makes it convenient for programming in many areas. In this post, i would like to show, how to create your own executable commands, like general shell commands i.e,
cp - copy command for copying files,      ls - for listing all enteries within a directory,     mv - command for moving files    etc. This task is very simple.
Firstly create a C file using any editor with 'c' as extension at the end. For example, here i am using a vim editor and create a C file which prints anything you give.
vim printprogram.c



now i am going to  write the following code in the created file
// program to print input 

#include     // library file
#define FILE_END EOF     //symbolic constants

main()     // start point 
{
   char k ;    // variable declarations
   printf("Enter & press Ctrl+D when finished:");
   
   //getchar for input 
   while ( (k = getchar()) != FILE_END )  {
      putchar(k);    //output
   }
}              // end point    
after coding the file, thus proceed for its working ie, compile the file by typing the following command in the terminal
cc printprogram.c -o printpg

'cc' is the complier or you can use 'gcc' since both are same. The option '-o ' is to copy the generated machine-executable code to a file print. Now check whether it runs by again typing in the terminal, the following command
./printpg

Here the ' . ' means current directory and ' ./ ' means inside the current directory to execute the file ' printpg '. If the file is running correctly then you can proceed to next step.
change the permission of the file
chmod -c 777 printpg
Now copy the file to the bin directory, where the executable files can be run without using ' ./ ' in the terminal.
sudo cp printpg /bin/
Remove the file print in your current directory
rm printpg
now just type print in the terminal
printpg
Atlast your executable file is ready to use.

Creating Script files using Python

Open a terminal by pressing Ctrl+Alt+t or Applications->Accessories->Terminal

create a file which you want to make script. In python, create files with py as extension or just the name.
vim filename.py
now after creating the file. Code the file with program you want to use in the script. For example, i am creating an echo function which prints whatever we give.
#!/usr/bin/python
a=raw_input()
print a

save the file as usually by pressing esc and the semicolon followed by wq. After saving the file change permission of file by typing the below code
chmod -c 777 filename.py
since the executable files like cp, ls, mkdir etc are saved at /bin/ location. Thus paste the file in the bin folder as super user mode.
sudo cp filename.py  /bin/
Type your root password when asked. Now after that, the original file filename.py is still in your directory, so please remove or move it to another location. Instead of cp, you can use mv(move) in the above command, if you want to move the original file. Now just type the filename only.
filename.py
you can use just filename without any extension for creating python files, since it works. For eg:
vim filename
Thus, now you just have to enter only the filename.
Note : Keep in mind, the line in the code " #!/usr/bin/python " is important since it shows the python location in your system to the python interpreter, so that while running python files, you need not have to use python command before your file and also very important while running python scripts.
For more details on python programming, you can check python program section in the Python programming Basics post of mine. Same way, you can also create such executable files using C program, for further details on C executable files visit http://amithkp.wordpress.com/2012/01/04/executable-file-creation-in-c/ .

Usb support for Virtualbox users

Here, this post provide information on usb supports for virtualbox. For this, you may need the most latest version of virtual box which has usb supports. You can download it from the following sites through your synaptic manager. You have to choose  anyone from here based on your linux edition
http://download.virtualbox.org/virtualbox/debian oneiric contrib
http://download.virtualbox.org/virtualbox/debian natty contrib
http://download.virtualbox.org/virtualbox/debian maverick contrib non-free
http://download.virtualbox.org/virtualbox/debian lucid contrib non-free
http://download.virtualbox.org/virtualbox/debian karmic contrib non-free
http://download.virtualbox.org/virtualbox/debian hardy contrib non-free
http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free
http://download.virtualbox.org/virtualbox/debian lenny contrib non-free.

I am a linux-mint user, so i choose http://download.virtualbox.org/virtualbox/debian natty contrib  and add it to the synaptic manager.
Adding to synaptic package manager is simple. Firstly,  select synaptic package manager by  clicking  Systerm->Administration->Synaptic Package Manager from the top panel. After opening the synaptic manager, click the Settings->Repositories to launch the Software Sources window.

Now  add the link to the ' Other Software ' tab in the ' Sotware Sources ' window of synaptic manager by clicking the add button. You may add like this, for me, i prefer
deb http://download.virtualbox.org/virtualbox/debian natty contrib
you can choose anyone of the above link, which is your linux edition, as i told earlier.
Remember after adding, there will be extra one with same link in the 'Other Software' window and  with 'source code' at the end. Untick that one and now close the  Software Sources window. Now, before reloading the Synaptic manager, you have to download and register the Oracle Public Key for virtualbox, for  that type the below command in the terminal.
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
After entering it, u will get  ok output. Now try reloading the synaptic package manager or type
sudo apt-get update
in terminal. Now you have updated and can continue checking the synaptic package manager for virtual box 4.1 or type
sudo apt-get install virtualbox-4.1
it may take more time, since more than 40MB. After installing it, you have to download a extension packager for virtual box which you can get from this link http://download.virtualbox.org/virtualbox/4.1.8/VirtualBoxSDK-4.1.8-75467.zip . For more detail, you can refer this link https://www.virtualbox.org/wiki/Linux_Downloads. Now import it to virtualbox, click on File->Preferences  to launch VirtualBox - Settings window and click on Extensions in the left side and import the extension package.

After upgrading the package, now you can install window7 or windows xp in virtual box. By clicking the 'new' and follow the steps. Give the name of the Operating system you want to install when the ' VM Name and OS Type ' window occurs. Follow whatever step and give dynamic memory allocation option when asked, after all when finished, you have click run to start the windows and browse the location of your windows image to mount and for installing, rest is same as installing windows. Now install guest addition in the virtual box by click it in Devices of windows Running window.
Now it will reboot to take changes. After rebooting, you just turn off the machine by closing the windows7 running window. Again, back to the virtualbox window, click the settings to lauch the OS settings which ever os you are using and in that click on usb on leftside and tick the usb controller. Also add a usb filter ie new filter for detecting usb's.
you can also share folders of your host by adding the host folders in the 'Shared Folder s' .
Note : After installing everything, you need to the permission  of host for vboxusesrs. For that go to the System->Administration->Users and Groups. Now click ' Manage Groups in the launched window and a Group settings window appears, in that select ' vboxusers ' and click properties and tick the user, if it is untick. Type password if asked.