Saturday, December 27, 2008

How to set environment variables in Ubuntu Linux

Here you can learn how to set up environment variables on Ubuntu.

Please follow the simple following steps:

1. Go to:
Applications > Accessories > Terminal
to open the terminal window.

2. You should take a back up of /etc/profile file. So write the commands:
sudo cp -p /etc/profile /etc/profile_backup

3. Now, to edit the /etc/profile file, write the following command in the terminal:
gksudo gedit /etc/profile
The file will be opened for editing.

4. You have to add one line at the end of the file. That line will tell the name of the variable and it's value.

Format for this command is:
export ENV_VARIABLE_NAME=VALUE
where ENV_VARIABLE_NAME is the name of the variable and VALUE is the value.

For example,
export JAVA_HOME=/mnt/F/ubuntu/j2sdk1.4.2_16
here /mnt/F/ubuntu/j2sdk1.4.2_16 - this path is the value of the variable JAVA_HOME.

5. Save your file and close it.

6. Restart your machine.

7. You can check if the value is properly set with these commands:
cd $JAVA_HOME
pwd

Right Alt key doesn't work? How to fix your right Alt key in Ubuntu?


Have you just noticed that your right alt key is not working in your Ubuntu?


Nope, don't be afraid, your button is ok. You just have to alter some option to make it behave like the left alt key.

1. First go to
System -> Preference -> Keyboard

2. Under Layout options tab, open the branch "third level choosers" and assign the third level chooser to any another key other than the right alt key.

It's done! :D

Synchronize Files Between your Desktop PC and Laptop

If you have two computers, you might want to synchronize data between the two. For example, if you have a laptop, you might want to transfer the files in your Documents folder to the main PC (and vice versa). You could do this manually by creating a network share, but it’s much better to do it automatically, with just a single click.

There are a variety of ways of synchronizing files under Ubuntu, and indeed, this is the kind of task that Linux excels in. However, perhaps the most fuss-free method is to use a program called Unison (or, actually, Unison GTK, which adds a graphical front end to the Unison command-line program; throughout I refer to the whole thing as Unison for simplicity). Unison uses built-in Linux tools to sync files but hides everything behind a friendly user interface.

The following are the steps required to sync the Documents folders on two separate computers using Unison. Before following these steps, ensure each computer has the correct time. This is essential because synchronization will fail otherwise.

These instructions make reference to a desktop PC and laptop computer but could be any two computers capable of running Ubuntu (or indeed any computer with Linux installed that can run Unison):

  1. On the desktop PC, use Synaptic to install the unison-gtk package. Meanwhile, on the laptop, use Synaptic to install the openssh-server and unison-gtk packages. As you might have guessed, Unison uses the SSH program in the background to provide the file transfer conduit but you won’t come into direct contact with it.
  2. Once installed on the desktop PC, Unison can be found on the Applications —> Accessories menu. When it starts, a wizard will walk you through creating an initial profile. The first step is to enter the folder on the desktop PC that you want to synchronize. Click the Browse button, and then locate your Documents folder. Click OK to close the file-browsing dialog box and OK again to move onto the next step of the wizard in Unison.
  3. In the next step, you must tell Unison which folder you want to synchronize with on the laptop. In the Directory text field, type Documents again. There’s no need to precede it with /home/username because Unison will automatically log into the laptop’s /home/ folder each time it synchronizes.
  4. Click the SSH radio button. You’ll now need to find the IP address of the laptop. This can be done by moving over to it, right-clicking its NetworkManager icon, and selecting Connection Information. Then look in the dialog box that appears for the line that reads IP Address. Type what you see (four numbers separated by dots) into the Host text field back on the desktop PC.
  5. In the User text field, still on the desktop PC, type the login name you use on the laptop. Then click the OK button.
  6. You’ll immediately be told that the laptop computer is being contacted. Then a dialog box will pop up telling you that the “authenticity of host can’t be established.” This is fine. Just type yes to continue, and hit OK.
  7. You’ll then be prompted for the login password on the laptop. Type it, and then click OK.
  8. After this, you’ll see a scary-looking warning dialog box saying that “no archives were found for these roots.” Don’t worry. This appears because this is the first time you’ve synchronized. Once you click OK, Unison will detect the files both on the desktop PC and on the laptop (it’s worth pointing out that you won’t see any sign of Unison running on the laptop, and you won’t have to do anything on the laptop—Unison runs automatically in the background).
  9. After a few minutes, the program window on the desktop PC will indicate the file differences between the two folders. The Path heading will show the file in question, and under the Action heading will be the “direction of travel,” indicated by an arrow—if the arrow points left, the file will be transferred to the desktop PC from the laptop. If it points right, the file will be transferred from the desktop PC to the laptop. If you don’t want to synchronize a particular file or folder, select it, and click the Skip button on the toolbar. However, assuming you’re happy with everything, click the Go button on the toolbar. The files will then be copied across. When Unison has finished (look at the status bar in the bottom left of the Unison window and the Status heading in the list of files), you can close the program window.

And that’s all there is to it. After this, you should run Unison on the desktop PC every time you want to sync the Documents folders on the two computers, such as when you get home from work. When Unison starts, just select default from the list.

Note that Unison always updates older files when synchronizing. For example, if you started a file on your desktop PC, transferred it to your laptop using Unison, and edited it while out and about, Unison would automatically overwrite the older file on the desktop PC with the updated version. This makes sense, of course. If the situation arises that the file gets updated on both machines between synchronizations, a question mark will appear alongside the file when you come to synchronize—see screenshot above—and it won’t get automatically copied across. You’ll then have to manually intervene to decide which to overwrite—the copy on the desktop PC or the copy on the laptop. Click the Right to Left toolbar button to overwrite the file on the desktop PC or the Left to Right button to overwrite the file on the laptop.

You can create additional profiles to sync other folders too—just click the Create New Profile button in Unison’s startup program window, type a name for the profile when prompted, and then double-click its entry in the list to start working through the wizard again. I find it useful to synchronize the Desktop folder on both machines because I tend to temporarily store a lot of files there. Don’t choose to sync your entire /home folder—hidden files are copied across too by Unison, and hidden files within your /home folder contain program configuration files unique to each computer. Upon synchronization there would be some almighty file clashes, and the likelihood of the login accounts on both systems getting damaged beyond repair because of mangled configuration files is high.

How to open .chm file Ubuntu and convert .chm file to pdf document


Do you want to open a .chm file in your Ubuntu?


Simple!!

For Gnome users, you may use the package "gnochm". Install it with this command:
sudo aptitude install gnochm
For KDE users, you may use the package "kchmviewer". Install it with this command:
sudo aptitude install kchmviewer
Do you want to convert from .chm to .pdf?

You can use this conversion tool:
sudo aptitude install chm2pdf

Simple enough, isn't it? :D

Thursday, November 13, 2008

Another Version of Ubuntu Is Out—How Do I Upgrade my current Ubuntu?

Automatic
-------------
If a new version of Ubuntu is released, the update manager will notify you via an upgrade notification pop-up bubble. To upgrade, click the Upgrade button, and follow the instructions.

Manual
----------
If you want to manually upgrade, first find out the codename for the next version of Ubuntu (in the same vain as Warty, Hoary, Breezy, and Dapper). Now open this file:

/etc/apt/sources.list


and replace the word "dapper" (or the code name of your current ubuntu) with the new codeword. Now run:

sudo apt-get updates


This command updated your package list. Now upgrade the system:

sudo apt-get dist-upgrade


You are asked if you wish to continue. Press Y, and then press Enter to continue. Your entire system is now upgraded.

source - http://www.informit.com/articles/article.aspx?p=667418

Thursday, September 11, 2008

Useful ubuntu commands for newbies/beginners

Privilege related commands:


sudo command - run command as root
sudo su - open a root shell
sudo su user - open a shell as user

sudo -k - forget sudo passwords

gksudo command - visual sudo dialog (GNOME)

kdesudo command - visual sudo dialog (KDE)

sudo visudo - edit /etc/sudoers
gksudo nautilus - root file manager (GNOME)
kdesudo konqueror - root file manager (KDE)
passwd - change your password


Display related commands:

sudo /etc/init.d/gdm restart - restart X (GNOME)
sudo /etc/init.d/kdm restart - restart X (KDE)
(file) /etc/X11/xorg.conf - display configuration
sudo dpkg-reconfigure -phigh xserver-xorg - reset X configuration
Ctrl+Alt+Bksp - restart X display if frozen
Ctrl+Alt+FN - switch to tty N
Ctrl+Alt+F7 - switch back to X display

System Services related commands:

start service - start job service (Upstart)
stop service - stop job service (Upstart)
status service - check if service is running (Upstart)
/etc/init.d/service start - start service (SysV)
/etc/init.d/service stop - stop service (SysV)
/etc/init.d/service status - check service (SysV)
/etc/init.d/service restart - restart service (SysV)
runlevel - get current runlevel

Package Management

apt-get update - refresh available updates

apt-get upgrade - upgrade all packages
apt-get dist-upgrade - upgrade Ubuntu version
apt-get install pkg - install pkg
apt-get remove pkg - uninstall pkg
apt-get autoremove - remove obsolete packages
apt-get -f install - try to fix broken packages
dpkg –configure -a - try to fix broken packages
dpkg -i pkg.deb - install file pkg.deb
(file) /etc/apt/sources.list - APT repository list

Network related commands:

ifconfig - show network information
iwconfig - show wireless information
sudo iwlist scan - scan for wireless networks
sudo /etc/init.d/networking restart - reset network
(file) /etc/network/interfaces - manual configuration
ifup interface - bring interface online
ifdown interface - disable interface

Special Packages

ubuntu-desktop - standard Ubuntu environment
kubuntu-desktop - KDE desktop
xubuntu-desktop - XFCE desktop
ubuntu-minimal - core Ubuntu utilities
ubuntu-standard - standard Ubuntu utilities
ubuntu-restricted-extras - non-free, but useful
kubuntu-restricted-extras - KDE of the above
xubuntu-restricted-extras - XFCE of the above
build-essential - packages used to compile programs
linux-image-generic - latest generic kernel image
linux-headers-generic - latest build headers

Firewall:

ufw enable - turn on the firewall
ufw disable - turn off the firewall
ufw default allow - allow all connections by default
ufw default deny - drop all connections by default
ufw status - current status and rules
ufw allow port - allow traffic on port
ufw deny port - block port
ufw deny from ip - block ip adress
Application Names
nautilus - file manager (GNOME)
dolphin - file manager (KDE)
konqueror - web browser/filemanager (KDE)
kate - text editor (KDE)
gedit - text editor (GNOME)


System:

Recovery - Type the phrase “REISUB” while holding down Alt and SysRq (PrintScrn) with about 1 second between each letter. Your system will reboot.

lsb_release -a - get Ubuntu version
uname -r - get kernel version
uname -a - get all kernel information

Thursday, September 4, 2008

How to mount a HDD partition in ubuntu

It's simple !

First of all, you have to create a mount point. A suitable place already is given: inside root, there is a directory named mnt. Inside mnt, you can create am empty directory where the HDD FAT/FAT32 partition will be mapped.

Create a mount point:

sudo mkdir /mnt/F

Now the next task is to find out the partition that we want to be mounted.

See the HDD partitions:

sudo fdisk -l

After this command, you'll see a list of partitions (both physical and logical). select the desired one for mounting. For example, you want to mount /dev/sda9 . So the command is:

sudo mount /dev/sda9 /mnt/F
But if the partition is of NTFS type; then use this command instead:
sudo mount /dev/sda9 /mnt/F -t ntfs -o nls=utf8,umask=0222
Done! now browse to /mnt/F and you'll get the HDD contents.

Wednesday, August 6, 2008

installing java and running a simple program

Hello all! I downloaded the jdk package from SUN's site and installed it offline. It's just simple.

offline istallation
---------------------

If you download the .bin file from Sun's site, then you can install it by:
sudo ./j2sdk-1_4_2_16-linux-i586.bin

online istallation
---------------------
sudo aptitude install sun-java6-jdk


Now, you have to set the path variables for JAVA:
export JAVA_HOME=/mnt/F/ubuntu/j2sdk1.4.2_16
export PATH=$JAVA_HOME/bin:$PATH

Now, switch to the directory /usr/bin :
cd /usr/bin

Now execute these commands sequentially:
sudo rm ./java
sudo rm ./java_vm
sudo rm ./javaws

sudo ln -s /mnt/F/ubuntu/j2sdk1.4.2_16/bin/java ./java
sudo ln -s /mnt/F/ubuntu/j2sdk1.4.2_16/bin/java_vm ./java_vm
sudo ln -s /mnt/F/ubuntu/j2sdk1.4.2_16/bin/javaws ./javaws
sudo ln -s /mnt/F/ubuntu/j2sdk1.4.2_16/bin/javac ./


You are done! Now you can run any java program from any directory you like.


Compiling your first java program

---------------------------------

You may write a sample code like this:
//First Java Program
class Main
{
public static void main (String[] args)
{
System.out.println ("Hello Ubuntu!");
}
}

Compile it:
javac Main.java

Run it:
java Main

you should get the output "Hello Ubuntu!"

installing and running gcc / g++ compiler in ubuntu


New to ubuntu? just stumbled upon installing gcc compiler and running a sample program? It's simple!

open up a terminal and write the command:

sudo aptitude install build-essential

It will automatically install gcc/g++ compiler into your system. Also you can do the same thing from the Synaptic package manager. Open the Synaptic package manager, search for a package "gcc" and then you will get the list of available packages. Just select g++ from there and install. Done !

To test it, write a simple C code like this and name it test.c:

#include
int main()
{
printf("Hello ubuntu!");
return 0;
}

to compile it:
g++ -lm -o test.o test.c

here -lm indicates that the compiler may invoke the math library. test.o is the name of the object file.

finally, you can get the output by executing the object file:
sudo ./test.o

Here you can find details of the build-essential package:
http://packages.ubuntu.com/hardy/build-essential

Wednesday, July 16, 2008

connect to Internet: Enable your DSL / ppp / pppoe connection in Ubuntu

Wanna connect to internet with the dsl / ppp / pppoe connection in Ubuntu? I found it actually quite easy, easier than connecting from windows.

1. Open up a terminal and run the command:
sudo pppoeconf

It'll open up a new window and it'll search for a connection. If it finds any, it'll ask you for username and password in subsequent windows. REMEMBER! the password is written in simple textmode therefore it is visible when you are typing! So, look back and see who's watching from your back. :)

2. Now your connection is set.

3. Whenever you want to CONNECT, just run the command:
sudo pon dsl-provider

Don't close the terminal, minimize it while you're doing other things.

4. If you want to DISCONNECT:
sudo poff

In case you opened more than 1 connection, run this command to close them all:
sudo poff -a

5. Remember, after setting the username and password once, you dont need to set them all the time unless you want to change them completely.

Was the info helpful? Please leave a comment.
:D

Tuesday, July 15, 2008

Solution : problem installing ubuntu with WUBI, installation halts at Busybox (initramfs) prompt



Are you trying to install Ubuntu/Xubuntu using WUBI? After running the wubi from inside windows and after reboot do you stuck at some point with this prompt?

Busybox v1.1.3 (Debian 1.1.1.3-5ubunu7) Bult-in shell (ash)
Enter help for a list of built in commands.
(initramfs)


I also got the same thing and was astonished. The solution is simple: From windows, after running the WUBI installer, replce "quiet splash" with "all_generic_ide" in the file g:\ubuntu\disks\boot\grub\menu.lst and reboot. Hope it works. (Here G: was the drive that is selected for Ubuntu installation, it may be different for you)

also, is your drive FAT32 formatted? make it NTFS.

Monday, July 7, 2008

Solution: Buffer I/O error on device FD0, Logical Block 0 (in Xubuntu 7.10)

Few days back I was trying to install Xubuntu 7.10 in my machine with WUBI. The installation began ok, but at some point it stucks and showed me the message :

[173.22] Buffer I/O error on device FD0, Logical Block 0
[182.56] Buffer I/O error on device FD0, Logical Block 0
.
.

and it continued to show those errors. The installation was a failure.

After some searching in the Internet, I figured out what went wrong. I don't have any floppy drive attached(I have one but I disconnected it long ago. I hate floppies :P) with the motherboard. yet, the installer was trying to read from the floppy drive. As a result the aforementioned error appeared.

The solution was simple! From the BIOS, I disabled the FDD and after that installation went on smoothly. Hope it works for you! :)

Thursday, April 17, 2008

Use your mobile as an external modem in ubuntu linux; with wvdial

Well ... I have to search a lot to find the way to use my Sony Ericsson w810 mobile phone as a modem and enjoy internet in Ubuntu linux. And After searching a lot, I found the solution quite easy! It's so simple. You just have to write three commands sequentially. These commands work perfectly with other mobile also, not necessarily with SE only.

At first, open a terminal and run this command and it'll show you the connected modem:

sudo wvdialconf /etc/wvdial.conf

Now, open the file wvdial.conf with gedit or mousepad(depends on whether you are running Ubuntu or Xubuntu; I use Xubuntu)

sudo mousepad /etc/wvdial.conf

You have to set the username, password, dial no. and un-comment those three lines (normally those are commented with a '#' sign at the beginning of the line. Wipe out those '#' sign). Leave other lines unharmed.

Finally, just run this command:

sudo wvdial

and you'll be online immediately! Remember not to close the terminal, minimize it while you are running other programs.

That's it :)

Sunday, April 6, 2008

Setting/Installing JAVA and PC^2 (pcsquare) in Ubuntu Live

See the HDD partitions:
sudo fdisk -l

Create a mount point and mount that partition:
sudo mkdir /mnt/F
sudo mount /dev/sda9 /mnt/F

Unzipping pc^2 zip file:
unzip -o pc2v8.zip (download the package)

Installing java:
sudo ./j2sdk-1_4_2_16-linux-i586.bin (download from Sun's site)

Setting the path variables for JAVA:
export JAVA_HOME=/mnt/F/ubuntu/j2sdk1.4.2_16
export PATH=$JAVA_HOME/bin:$PATH

Necessary configuration for java:

cd /usr/bin

sudo rm ./java
sudo rm ./java_vm
sudo rm ./javaws

sudo ln -s /mnt/F/ubuntu/j2sdk1.4.2_16/bin/java ./java
sudo ln -s /mnt/F/ubuntu/j2sdk1.4.2_16/bin/java_vm ./java_vm
sudo ln -s /mnt/F/ubuntu/j2sdk1.4.2_16/bin/javaws ./javaws
sudo ln -s /mnt/F/ubuntu/j2sdk1.4.2_16/bin/javac ./


This will enable gcc:

sudo aptitude install build-essential

manually restarting your network:
sudo /etc/init.d/networking restart

see the interface information:
sudo mousepad /etc/network/interfaces
/etc/hosts
/etc/hostname