How to Add Swap Space

21 08 2010

You can either use a dedicated hard drive partition to add new swap space, or create a swap file on an existing filesystem and use it as swap space.

How much swap space is currently used by the system?

Free command displays the swap space. free -k shows the output in KB.

# free -k
             total       used       free     shared    buffers     cached
Mem:       3082356    2043700    1038656          0      50976    1646268
-/+ buffers/cache:     346456    2735900
Swap:      4192956          0    4192956

Swapon command with option -s, displays the current swap space in KB.

# swapon -s
Filename                        Type            Size    Used    Priority
/dev/sda2                       partition       4192956 0       -1

Swapon -s, is same as the following.

# cat /proc/swaps
Filename                        Type            Size    Used    Priority
/dev/sda2                       partition       4192956 0       -1

Method 1: Use a Hard Drive Partition for Additional Swap Space

If you have an additional hard disk, (or space available in an existing disk), create a partition using fdisk command. Let us assume that this partition is called /dev/sdc1

Now setup this newly created partition as swap area using the mkswap command as shown below.

# mkswap /dev/sdc1

Enable the swap partition for usage using swapon command as shown below.

# swapon /dev/sdc1

To make this swap space partition available even after the reboot, add the following line to the /etc/fstab file.

# cat /etc/fstab
/dev/sdc1               swap                    swap    defaults        0 0

Verify whether the newly created swap area is available for your use.

# swapon -s
Filename                        Type            Size    Used    Priority
/dev/sda2                       partition       4192956 0       -1
/dev/sdc1                       partition       1048568 0       -2

# free -k
             total       used       free     shared    buffers     cached
Mem:       3082356    3022364      59992          0      52056    2646472
-/+ buffers/cache:     323836    2758520
Swap:      5241524          0    5241524

Note: In the output of swapon -s command, the Type column will say “partition” if the swap space is created from a disk partition.

Method 2: Use a File for Additional Swap Space

If you don’t have any additional disks, you can create a file somewhere on your filesystem, and use that file for swap space.

The following dd command example creates a swap file with the name “myswapfile” under /root directory with a size of 1024MB (1GB).

# dd if=/dev/zero of=/root/myswapfile bs=1M count=1024
1024+0 records in
1024+0 records out

# ls -l /root/myswapfile
-rw-r--r--    1 root     root     1073741824 Aug 14 23:47 /root/myswapfile

Change the permission of the swap file so that only root can access it.

# chmod 600 /root/myswapfile

Make this file as a swap file using mkswap command.

# mkswap /root/myswapfile
Setting up swapspace version 1, size = 1073737 kB

Enable the newly created swapfile.

# swapon /root/myswapfile

To make this swap file available as a swap area even after the reboot, add the following line to the /etc/fstab file.

# cat /etc/fstab
/root/myswapfile               swap                    swap    defaults        0 0

Verify whether the newly created swap area is available for your use.

# swapon -s
Filename                        Type            Size    Used    Priority
/dev/sda2                       partition       4192956 0       -1
/root/myswapfile                file            1048568 0       -2

# free -k
             total       used       free     shared    buffers     cached
Mem:       3082356    3022364      59992          0      52056    2646472
-/+ buffers/cache:     323836    2758520
Swap:      5241524          0    5241524

Note: In the output of swapon -s command, the Type column will say “file” if the swap space is created from a swap file.

If you don’t want to reboot to verify whether the system takes all the swap space mentioned in the /etc/fstab, you can do the following, which will disable and enable all the swap partition mentioned in the /etc/fstab

# swapoff -a

# swapon -a




Convert .chm to .pdf

14 12 2009

First install libchm-bin

$ sudo apt-get install libchm-bin     For ubuntu

# yum install libchm-bin              For fedora

and then convert book.chm file to pdf format named as out.

$ extract_chmLib book.chm out





Accessing Mobile Internet over Bluetooth in Ubuntu

31 10 2009

What you need

To using mobile internet over Bluetooth you need a few common things that is probably you have all ready. You just need a computer with Ubuntu (Linux distribution) operating system loaded. Then you have a Bluetooth enabled Mobile phone (Cellphone) which you want to use as a GPRS/EDGE/cdma 2000 1x/EVDO/HSDPA modem. You don’t need a data cable because your data communication from your PC to Mobile phone will be wireless through Bluetooth.

Make Your System Ready

Before starting the job you have to make your system ready. You may have to install some packages. By default those packages should be installed on your Ubuntu system. But make sure they all are installed.

Install the relevant packages

You need a Bluetooth device manager for gnome. There is a package named bluez-gnome. By default bluez-gnome is installed on your Ubuntu PC. You have to check that this package is all ready been installed. You can check it in Synaptic Package Manager. You will find this here:

//
System > Administration > Synaptic Package Manager

You have to also check for the package bluez-utils, bluez-pin, ppp. If those package are not installed then go to Terminal.

Application > Accessories > Terminal

Now install those with following command

sudo apt-get install bluez-gnome bluez-utils bluez-pin ppp

Permissions

Your user needs to be able to dial-out (if you are the first user on an ubuntu system, this is already done):

adduser your-username-here dialout

Log out and Log in again.

Connect to your phone

Now you have to turn on bluetooth on your phone and computer. If you’ve already tried connecting them before, delete any reference to your computer from your phone’s list of Bluetooth devices. And delete any reference to your phone’s ID from your Ubuntu PC. To do this go to here:

/var/lib/bluetooth/

Now delete all folders/files there. If you have problem with permission then do the following command on Terminal and try again.

sudo chmod -R oa+rw /var/lib/bluetooth

Now if the gnome bluetooth applet doesn’t appear yet, run:

bluetooth-applet

It should make your computer discoverable by default.

Do a bluetooth scan on the phone, and add your computer as a paired device.

Enter the same pass code in both phone and computer. They should bond.

Now you can edit the properties of the computer on the phone’s list of Bluetooth devices and tell it to always accept connections from the computer.

Now you need to find your phone’s bluetooth mac address, make the phone discoverable, and run in Terminal

hcitool scan

Copy the MAC address (the text with the capital letters, numbers, and ‘:’s) somewhere convenient. You’ll need it many times.

Now you’ll need to find out what channel to connect to:

sdptool browse XX:XX:XX:XX:XX:XX       <-- Insert your phone's MAC address here

Now probably you ‘ll see the followings reply.

Browsing 00:1F:DF:27:2D:DD ...
Service Name: Dial-up networking
Service RecHandle: 0x1002a
Service Class ID List:
 "Dialup Networking" (0x1103)
 "Generic Networking" (0x1201)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 1                           <-- Find this channel number
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "Dialup Networking" (0x1103)
 Version: 0x0100

Service Name: Nokia PC Suite
Service RecHandle: 0x1002b
Service Class ID List:
 "Serial Port" (0x1101)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 15
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100

Service Name: COM 1
Service RecHandle: 0x1002c
Service Class ID List:
 "Serial Port" (0x1101)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 3
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100

Service Name: Voice Gateway
Service RecHandle: 0x1002d
Service Class ID List:
 "Handsfree Audio Gateway" (0x111f)
 "Generic Audio" (0x1203)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 13
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "Handsfree" (0x111e)
 Version: 0x0105

Service Name: Audio Gateway
Service RecHandle: 0x1002e
Service Class ID List:
 "Headset Audio Gateway" (0x1112)
 "Generic Audio" (0x1203)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 12
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "Headset" (0x1108)
 Version: 0x0100

Service Name: Network Access Point Service
Service Description: Personal Ad-hoc Network Service which provides access to a network
Service RecHandle: 0x10034
Service Class ID List:
 "Network Access Point" (0x1116)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 PSM: 15
 "BNEP" (0x000f)
 Version: 0x0100
 SEQ8: dd 6
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "Network Access Point" (0x1116)
 Version: 0x0100

Service Name: OBEX Object Push
Service RecHandle: 0x10037
Service Class ID List:
 "OBEX Object Push" (0x1105)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 9
 "OBEX" (0x0008)
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "OBEX Object Push" (0x1105)
 Version: 0x0100

Service Name: OBEX File Transfer
Service RecHandle: 0x10038
Service Class ID List:
 "OBEX File Transfer" (0x1106)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 10
 "OBEX" (0x0008)
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "OBEX File Transfer" (0x1106)
 Version: 0x0100

Service Name: SyncML Client
Service RecHandle: 0x1003a
Service Class ID List:
 UUID 128: 00000002-0000-1000-8000-0002ee000002
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 11
 "OBEX" (0x0008)
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100

Service Name: Music-Player
Service Provider: Nokia
Service RecHandle: 0x1003b
Service Class ID List:
 "Audio Source" (0x110a)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 PSM: 25
 "AVDTP" (0x0019)
 uint16: 0x100
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "Advanced Audio" (0x110d)
 Version: 0x0100

Service Name: Media Player
Service Provider: Nokia
Service RecHandle: 0x1003c
Service Class ID List:
 "AV Remote Target" (0x110c)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 PSM: 23
 "AVCTP" (0x0017)
 uint16: 0x100
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "AV Remote" (0x110e)
 Version: 0x0100

Service Name: Media Player
Service Provider: Nokia
Service RecHandle: 0x1003d
Service Class ID List:
 "AV Remote" (0x110e)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 PSM: 23
 "AVCTP" (0x0017)
 uint16: 0x100
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "AV Remote" (0x110e)
 Version: 0x0100

Service Name: SIM ACCESS
Service RecHandle: 0x1003e
Service Class ID List:
 "SIM Access" (0x112d)
 "Generic Telephony" (0x1204)
Protocol Descriptor List:
 "L2CAP" (0x0100)
 "RFCOMM" (0x0003)
 Channel: 4
Language Base Attr List:
 code_ISO639: 0x656e
 encoding:    0x6a
 base_offset: 0x100
Profile Descriptor List:
 "SIM Access" (0x112d)
 Version: 0x0101

The number you want is the Channel number for Dial-up Networking. You find this under Service Name: Dial-up Network (Pointed in top).

Configure bluez

Now you are going to configure the bluez. Just type the following command in the terminal.

sudo gedit /etc/bluetooth/rfcomm.conf

Add the following text at the end:

rfcomm0 {
  bind yes;
  device XX:XX:XX:XX:XX:XX;  <- Insert your phone's MAC address here
 channel 1;
  comment "P900 PPP connection";
}

restart blue-utils

/etc/init.d/bluez-utils restart

Configuring PPP

Now you have to configure ppp. Just run the following in terminal.

//
sudo gedit /etc/ppp/peers/BluetoothDialup

Now you see a blank text file. Then paste the following on the file

debug
noauth
connect "/usr/sbin/chat -v -f /etc/chatscripts/BluetoothDialup"
usepeerdns
/dev/rfcomm0 115200
defaultroute
crtscts
lcp-echo-failure 0

Save and close the BluetoothDialup file. Then run the following.

gksudo gedit /etc/chatscripts/BluetoothDialup

Now you see a blank text file. Then paste the following text on the text file, replacing your-apn-here with the APN from your data services profile and your-data-profile-number-here with the number you stored the profile into on the phone . If you don’t know your apn (access point name) contact with your operator’s help line.

TIMEOUT 35
ECHO    ON
ABORT   '\nBUSY\r'
ABORT   '\nERROR\r'
ABORT   '\nNO ANSWER\r'
ABORT   '\nNO CARRIER\r'
ABORT   '\nNO DIALTONE\r'
ABORT   '\nRINGING\r\n\r\nRINGING\r'
''      \rAT
OK      'AT+CGDCONT=1,"IP","your-apn-here"'
OK      ATD*99***your-data-profile-number-here#
CONNECT ""

The “AT+CGDCONT=1″ command depends upon your operator. So get the right command from your operator’s help service.

Connect To Internet

To connect to internet through your Mobile Phone’s GPRS/EDGE/cdma 2000 1x/EVDO/HSDPA network with Bluetooth run the following dial up command in Terminal.

pon BluetoothDialup
  • Wait for about 30 – 60 seconds.You should able to connect to internet within this time.
  • Your Mobile Phone should display GPRS/EDGE/cdma 2000 1x/EVDO/HSDPA etc in the right place.

To stop your internet connection. Command this:

poff BluetoohDialup

Debug

To see your connection progress.

tail -f /var/log/syslog

You can make your phone undiscoverable/hidden now. Enjoy.





How to Open rar file or Extract rar files in Linux.

16 10 2009

RAR is a proprietary file format for data compression and archiving.

Under Linux and UNIX, use command called unrar. By default unrar is not being installed on Linux. You can install unrar command with the help of apt-get or yum command.

Install unrar command

Under Debian Linux, you need to type apt-get as follows to install unrar program:
$ sudo apt-get install unrar

If you are using Fedora core Linux then use yum command as follows:

$ yum install unrar

If any of above, methods is not working for you, download binary package from official rarlab site:
$ cd /tmp
$ wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz

Untar file
$ tar -zxvf rarlinux-3.6.0.tar.gz

Both unrar and rar commands are located in rar sub-directory. Just go to rar directory:
$ cd rar
$ ./unrar

Now copy rar and unrar to /bin directory:
$ cp rar unrar /bin

How to use unrar

unrar command supports various options below are common options that you need to use everyday.

Task: To open rar (unpack) file in current directory type command:

$ unrar e file.rar

Please note that replace file.rar filename with your actual filename.

Task: List (l) file inside rar archive:

$ unrar l file.rar

Task: To extract (x) files with full path type command:

$ unrar x file.rar

(D) To test (t) integrity of archive, file type command:
$ unrar t file.rar





How-To use Facebook Chat without a browser using pidgin.

1 09 2009

Facebook`s Chat feature really makes Facebook an all-in-one social networking website. People have started using the Facebook Chat much as they use the Google Chat. The only only downside to Facebook`s chat is that you donont have a client for the chat feature. But, now you can have your favourite Facebook Chat right on a client and chat with your Facebook friends without even logging into the Facebook website. What you will need is a chat client called Pidgin and the facebook-pidgin-chat plugin. Follow these simple steps to setup Facebook chat on the Pidgin chat client. I have given separate steps for various distros to set the Facebook-Chat-on-Pidgin working:

Install Pidgin Messengerpidgin-fb

su -c ‘yum -y install pidgin’

Install Facebook Chat plugin for Pidgin in fedora

wget http://pidgin-facebookchat.googlecode.com/files/libfacebook-1.47.so && mkdir ~/.purple/plugins && cp libfacebook-1.47.so ~/.purple/plugins/libfacebook.so

Install Facebook Chat plugin for Pidgin in ubuntu

sudo dpkg -i http://pidgin-facebookchat.googlecode.com/files/pidgin-facebookchat-1.47.deb

You should check the plugin download repository and install instructions for setting up Facebook chat on Pidgin for other platforms.








Follow

Get every new post delivered to your Inbox.