Linux - 013 Linux Bash Tips

0xa Linux Bash Commands which helps me most in my daily work.


1. cd -, swaps take you to the last cd last location

2. cd, Change to home directory

3. pushd, pushes the current directory path into stack and later you can use popd to go back to that location, use dirs to display the stack

4. fg, mainly for programmers who are editing and compiling the from command line. Eg. Start vim make some changes to the file use :w to save the contents press Ctrl-Z that process will get stopped. Now compile the code then use fg to bring back that to foreground.. Use jobs to see all stopped process and use bg to run those in background.

5. Ctrl-L, to clear the screen.

6. Ctrl-R to reverse search the previous commands

7. !xyz will execute the last xyz command with all the previous arguments.

8. Ctrl-A to go to the beginning for the line, Ctrl-E to the end of the line,

9. Ctrl-U erase all characters backward, Ctrl-W erase a word backward

10. shopt -s cdspell, will correct minor errors in cd command.
Posted by - at 9/24/2006 08:19:00 AM | 1 comments read on

Windows - Debugging Tools

I would like to mention few very good debugging tools which were very useful for me.

All the below links correspond to 32 bit platforms, go to those links they says it all.

1. Debugging Tools for Windows
2. Debug Diag
3. Dependency Walker
4. Process Explorer
5. DebugView
6. JXplorer - For LDAP related stuffs
Posted by - at 9/20/2006 08:16:00 AM | 0 comments read on

Linux - Nokia 6600

I did this couple of years before, now I don't even have that phone
Requirements:
Nokia 6600 installed with p3nfs

Procedure:


Download (and install) the needed software from bluez.sourceforge.net


a. bluez-libs-2.3
b. bluez-utils-2.2
c. bluez-bluefw-0.9
Further you need the bluez drivers which are part of any kernel >= 2.4.20.For those with older kernel, bluez-kernel-2.3 (deprecated) seems to work.
Or check whether the following utilities are installed or not

$> rpm -qa|grep bluez
bluez-bluefw-1.0-2.i386.rpm
bluez-hcidump-1.5-4.i386.rpm
bluez-libs-2.5-2.1.i386.rpm
bluez-libs-devel-2.5-2.1.i386.rpm
bluez-pan-1.1-4.i386.rpm
bluez-pin-0.23-1.i386.rpm
bluez-sdp-1.5-2.1.i386.rpm
bluez-sdp-devel-1.5-2.1.i386.rpm
bluez-utils-2.4-3.i386.rpm

Otherwise install everything



add the following lines to /etc/modules.conf


alias net-pf-31 bluez
alias bt-proto-0 l2cap
alias bt-proto-2 sco
alias bt-proto-3 rfcomm


Start bluetooth services


Get the Bluetooth device address of the phone:

e.g. with hcitool inq. Switch to bluetooth mode in nfsclient (see below on how), and remember the rfcomm port. It should be 13.



Revise your /etc/bluetooth/rfcomm.conf


rfcomm0 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 00:0e:6d:31:aa:38;
# RFCOMM channel for the connection
channel 3;
# Description of the connection
comment "Hopeless Case";
}


In your /etc/bluetooth/hcid.conf disable the following two lines by remarking with #s


auth enable;
encrypt enable;


$> killall -HUP hcid


$> hciconfig hci0 up // to detect and get your USB device up.


hci0: Type: USB
BD Address: 00:0C:76:D3:C7:06 ACL MTU: 192:8 SCO MTU: 64:8
UP RUNNING PSCAN ISCAN
RX bytes:197801 acl:3082 sco:0 events:6916 errors:0
TX bytes:1354416 acl:11245 sco:0 commands:142 errors:0


$> hcitool scan


Scanning ...
00:0E:6D:31:AA:38 Becks 6600 // ok it can see the phone


** On your 6600, under Connectivity->Bluetooth->Paired-Devices select "New Paired Device"
and wait for it to detect your PC's BT. It should now ask for a PIN. After you have paired
your new device, Authorize it


Now try pinging the device to further confirm BT link-up


$> l2ping 00:0E:6D:31:AA:38
0 bytes from 00:0E:6D:31:AA:38 id 200 time 45.03ms
0 bytes from 00:0E:6D:31:AA:38 id 201 time 15.16ms
0 bytes from 00:0E:6D:31:AA:38 id 202 time 15.50ms
3 sent, 3 received, 0% loss


Check if /dev/rfcomm0 exists, if not, you'll have to make it manually


$> mknod -m 660 /dev/rfcomm0 c 216 0
$> mknod -m 660 /dev/rfcomm1 c 216 0
$> mknod -m 660 /dev/rfcomm2 c 216 0
$> chgrp uucp /dev/rfcomm*


Establish a potential bluetooth connection with rfcomm (as root)

# rfcomm bind /dev/rfcomm0 13
- You can verify the rfcomm state by calling rfcomm without arguments
- The last argument (port) must correspond to the number shown by nfsclient on the device.
Note: due to a bug in nfsclient, it was usually 3 on series60 devices and 4 on the p800 up till nfsclient version 2.6. On newer versions it should be 13 if no program occupied this rfcomm port before.


First time device connection / Bluetooth PIN

As entering the pin on the Linux side does not seem to work, I had success with the following workaround:
Change /bin/bluepin to:
#!/bin/sh
cat /etc/bluetooth/pin
and /etc/bluetooth/pin to
PIN:0000
Now you can type 0000 on the Phone as it requests the PIN.


Start nfsapp on the 6600 and switch to bluetooth

- by pressing the joystick (or 'p').


Start p3nfsd with

% p3nfsd -series60 -tty /dev/rfcomm0
or
% p3nfsd -UIQ -tty /dev/rfcomm0
There is no difference at the moment between these settings as you can verify it with:
% p3nfsd -series60 -tty /dev/rfcomm0 -h
or
% p3nfsd -UIQ -tty /dev/rfcomm0 -h


Posted by - at 9/18/2006 08:17:00 AM | 0 comments read on

Windows - Memory Leak Analysis using Windbg

Windbg is a tool from the house of MS. It come handy when debugging in a production enviornment as it is light weight. I have been using Windbg for the last few weeks and I would like to share some tips.

Let us start of with memory leak analysis!

Download Location: Debugging Tools For Windows


Windbg has build in extension exts.dll which can used to find memory leaks. Here are the steps. Enable Stack backtrace from your executable using gflags.exe +ust /i . gflags.exe comes along with the Debugging Tools For Windows.

1. Start your program and start leaking your application
2. Run WinDBG and attach to the your process. (windbg.exe -pn ).
3. From the WinDBG command line do a !heap -stat, this will list down all the active heap blocks
4. Then do a !heap -stat -h for the block with Maximum Committed + Virtual Allocation Bytes, this will list down the handle specific allocation.
5. Now do a !heap -flt s for the size which is being allocated that we got from previous output, it will list down all the specific blocks with that particular size.
6. Then do a !heap -p -a < address >, address is the User Addr then you will get the stack trace; from where you have allocated that much bytes.

Good luck guys!!
Let your RAM Rest In Peace.
Posted by - at 9/18/2006 08:12:00 AM | 0 comments read on

Archives

  • March 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006