Thursday, October 11, 2012

How to write Control Character in Unix File

Open File in vi editor
Come in Insert mode by pressing Esc i
Press Control V
Then Press Control M
Then Esc


List of Ctrl Chars
 
Numeric Values Decimal Hex ASCII Character
Meaning Keyboard Entry
0
00
NUL Null Ctrl-@
1
01
SOH Start of heading
Ctrl-A
2
02
STX Start of text Ctrl-B
3
03
ETX Break/end of text Ctrl-C
4
04
EOT End of transmission Ctrl-D
5
05
ENQ Enquiry Ctrl-E
6
06
ACK Positive acknowledgment Ctrl-F
7
07
BEL Bell Ctrl-G
8
08
BS Backspace Ctrl-H
9
09
HT Horizontal tab Ctrl-I
10
0A
LF Line feed Ctrl-J
11
0B
VT Vertical tab Ctrl-K
12
0C
FF Form feed Ctrl-L
13
0D
CR Carriage return
(Equivilant to the Enter or
Return key)
Ctrl-M
14
0E
SO Shift out Ctrl-N
15
0F
SI Shift in/XON (resume
output)
Ctrl-O
16
10
DLE Data link escape Ctrl-P
17
11
DC1 Device control character 1 Ctrl-Q
18
12
DC2 Device control character 2
Ctrl-R
19
13
DC3 Device control character 3
Ctrl-S
20
14
DC4 Device control character 4
Ctrl-T
21
15
NAK Negative acknowledgment Ctrl-U
22
16
SYN Synchronous idle Ctrl-V
23
17
ETB End of transmission block Ctrl-W
24
18
CAN Cancel Ctrl-X
25
19
EM End of medium Ctrl-Y
26
1A
SUB Substitute/end of file Ctrl-Z
27
1B
ESC
Escape Ctrl-[
28
1C
FS File separator Ctrl-\
29
1D GS Group separator Ctrl-]
30
1E
RS
Record separator Ctrl-^
31
1F
US
Unit separator Ctrl-_

Monday, May 14, 2012

Secure SSH, CVS, SCP without Password Prompt

  1. Suppose the domain name of your server is server, and your login name loginname.
  2. On the client, generate a public and private key.

    ssh-keygen -C loginname@server -t dsa
     
    When asked for a password, simply press return. 
    The private key is stored in ~/.ssh/id_dsa, and the public key in ~/.ssh/id_dsa.pub.
    Never give the private key away! 
  3. Copy the public file to the server with

    scp ~/.ssh/id_dsa.pub loginname@server:~/
  4. Login on the server with 

    ssh loginname@server
     
    append the copied file to ~/.ssh/authorized_keys with
     
    cat ~/id_dsa.pub >>~/.ssh/authorized_keys
  5. If you want to enable this features on other servers, just repeat step 3 on each of the servers.

    
    That’s it! If you have done everything correctly, the next time you 
    login via SSH or use CVS over SSH, you will not need to enter a password
     yet you have a secure connenction.

    In case this does not work check /var/log/auth.log or /var/log/secure for error on server machine. If you see

    Authentication refused: bad ownership or modes for directory /home/dave/.ssh
     
    This is bcoz of bad permission these can be fixed with below commands.
     
    chmod g-w /home/your_user
    chmod 700 /home/your_user/.ssh
    chmod 600 /home/your_user/.ssh/authorized_keys

Thursday, March 22, 2012

Commands will let you determine which version(s) of GCC were used to compile and link a binary executable file

his trick will let you determine which version(s) of GCC were used to compile and link a binary executable file:
Code:
strings -a /path/to/binary-file | grep "GCC:" | sort -u

Here is a dirt-simple scripted version of the pipeline.
which-gcc:
#!/bin/bash

if [ -z "$1" ] ; then
echo "Usage: which-gcc file"
echo "Determines GCC version(s) used to build file"
exit
fi

strings -a $1 | grep "GCC:" | sort -u


Here are some examples from my system:
Code:
$ which-gcc /bin/bash
GCC: (GNU) 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)
I'm using GCC 3.4.6.

Code:
$ which-gcc `which vuescan`
GCC: (GNU) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
This commercial product was built on a Red Hat system, quite some time ago.

Code:
$ which-gcc /opt/google-earth/googleearth-bin
GCC: (GNU) 3.4.5 20050809 (prerelease) (Ubuntu 3.4.4-6ubuntu8)
GCC: (GNU) 4.0.2
The multiple version lines suggest Google Earth is at least in part statically linked. The final executable and at least one component library were built with different versions of GCC.

Code:
$ which-gcc /usr/bin/ooffice2

ooffice2 is not a GCC executable, thus no output. (It's a Bourne shell script. Reader exercise: produce a useful message when the file argument is not a GCC-created executable. :))

Thursday, September 15, 2011

Restore Grub of Installed Linux

I have machine with dual boot. 4 years back I installed Windows XP Pro and Ubuntu 7.10. After 4 years it was time to reinstall XP the only issue was restoring GRUB as on Ubuntu 7.10 back to MBR as XP will rewrite the MBR. Here are the steps to achieve it.

After successful re-installation of XP.
  • Boot system with Live CD of Linux can be ubuntu/Knnopix etc.
  • mount the Linux Partition after Live CD is done.
    sudo mkdir /mnt/root
    sudo mount -t etx3 /dev/sda6 /mnt/root
  • Then have to mount the proc subsystem and dev inside /mnt/root
    sudo mount -t proc none /mnt/root/proc
    sudo mount -o bind /dev /mnt/root/dev
  • Doing this allows grub to discover drives.
  • Now time to run grub
    sudo chroot /mnt/root grub
    find /boot/grub/stage1
  • I had (hd0,5)
    root (hd0,5)
    setup (hd0)
  • Thats it. Grub is now restored on MBR.

Wednesday, July 07, 2010

Directory List in Text File under Windows

It very simple...just try below command


dir /AD /S /B > C:\DirList.txt


check C:\DirList.txt it will have the complete directory list under root directory passed.

Thursday, May 27, 2010

Date datatype does not display time when selected

Default date format is set to DD-MON-YY. This can be changed by running below sql.

alter session set nls_date_format = 'dd/mm/yyyy hh24:mi:ss';

Tuesday, May 11, 2010

SQL Server 2005 Express and 2008 Express Side by Side

Normally this fails due to - The SQL Server 2005 Express Tools are installed i.e. SQL Server 2005 Management Studio....There are two ways of fixing it...

a) Remove 2005 Management Studio...and then try to Install SQL Server 2008 Express Edition..I have not tried this as I wanted both Management Studion i.e 2005 and 2008...Needless to say 2008 Management Studio can access SQL Server 2005 Database.

b) While installing SQL Server 2008 Express it checks for Registry Key HKLM/SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM....rename this key from ShellSEM to ShellSEM.old. Install SQL Server 2008 Express...after installation name it back to ShellSEM...now both Management Studio will be in working state...