Twitter : display your rate limit per hour

[pene@donunix]  curl -u twitter_name:twitter_password http://twitter.com/account/rate_limit_status.xml

N.B. : For information, the default rate limit is 100 requests per hour.

grep: advanced use

How to display all lines with the word text or the word name?
Here is the answer:

[pene@donunix] grep -P 'text|name' file.txt

SSH : Public keys generation

The purpose of this short post is to explain how being connected to an ssh server without typing the password, how ?
With the generation of public ssh keys.

I. Client : Generation of public keys

First (just for the first time) you have to genere the 2 keys :
[donunix@client] ssh-keygen -t dsa

During the dsa key generation, ssh-keygen ask you to enter a path phrase (it replace the password system). type [enter] if you doesn't what to genere a path phrase.

The 2 keys are in the ~/.ssh directory :
[donunix@client] ls ~/.ssh/id_dsa*
id_dsa id_dsa.pub

  • id_dsa is the private key
  • id_dsa.pub is the public key to send too the server

Client : send to the server the public keys

copy the public keys to the server :
[donunix@client] scp .ssh/id_dsa.pub user@server:.ssh/client.pub

Server : Record the client public keys

Connect to the server :
[donunix@client] ssh donunix@server

record the keys on the .ssh/authorized_keys file :
[donunix@server] cd .ssh
[donunix@server] cat client.pub >> authorized_keys

And that's all folk ;)
You can now run ssh sessions without typing your password.

[Dvorak keyboard] Launch a XKB keyboard file

I want to learn the french version of the Dvorak Simplified Keyboard.
To toggle my keyboard from azerty to Dvorak-bepo configuration, I need to launch the dvorak-bepo.xkb file.

So here is, how to set your keyboard in Dvorak-bepo :
[pene@donunix] xkbcomp -w0 fr-dvorak-bepo.xkb :0

And if you want to go back, with the classic French configuration :
[pene@donunix] setxkbmap fr

Create a different colored prompt for each users and hosts

I've just coded this script to avoid mistakes when you're using more than one host and user login :

#!/usr/bin/ksh
#######################################
# Program : Prompt-Color
#
# Version : V1.0
# Date : 2009-03-02
# Author : N. PENE
#
# Inputs : none
#######################################
hostname=`hostname`
username=`whoami`

#-- classic colors vars :
BLACK='\[\033[0;30m\]'
RED='\[\033[0;31m\]'
GREEN='\[\033[0;32m\]'
BROWN='\[\033[0;33m\]'
BLUE='\[\033[0;34m\]'
PURPLE='\[\033[0;35m\]'
CYAN='\[\033[0;36m\]'
GRAY='\[\033[0;37m\]'
DEFAULT='\[\033[0m\]'
#-- bolded colors vars :
BBLACK='\[\033[1;30m\]'
BRED='\[\033[1;31m\]'
BGREEN='\[\033[1;32m\]'
BBROWN='\[\033[1;33m\]'
BBLUE='\[\033[1;34m\]'
BPURPLE='\[\033[1;35m\]'
BCYAN='\[\033[1;36m\]'
BGRAY='\[\033[1;37m\]'
BDEFAULT='\[\033[1;0m\]'


cprompt=$DEFAULT
cborder=$DEFAULT
cpath=$DEFAULT

#-- username color :
case $username in
"npene" ) cuser=$CYAN;;
"donunix" ) cuser=$BLUE;;
"fenice" ) cuser=$PURPLE;;
"donpene" ) cuser=$BROWN;;
"root" ) cuser=$GREEN;;
esac

#-- hostname color :
case $hostname in
"host1" ) chost=$BRED;;
"host2" ) chost=$BBLUE;;
esac

PS1="$cborder[$cuser\u$cborder@$chost\h$cborder: $cpath\W$cborder] $cprompt"
export PS1