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. :))