Wednesday, December 29, 2010

How to sync cydia repository by ubuntu

1. apt-get install apt-mirror
2. Add cydia repository into /etc/apt/mirror.list
3. Change deb to deb-iphoneos-arm so that different arch could be loaded
ex.
original :
deb http://example.com/debian stable main contrib non-free
modified :
deb-iphoneos-arm http://example.com/debian stable main contrib non-free

4. Modify /usr/bin/apt-mirror to accept .bz2 only ( it seems that lots cydia repo did not provide .gz version of packages file )


5. run apt-mirror

After all done, mirrored repo could be found at /var/spool/apt-mirror/mirror
If anything failed during apt-mirror running, be sure to rm /var/spool/apt-mirror/var/apt-mirror.lock before re-run

Monday, June 21, 2010

Assign user name, password in smbclient



smbclient -L //192.168.x.x -o --user=USER%PASS
where USER is the user name, PASS is the password

Tuesday, April 06, 2010

Init program of Android

Android did not use shell script to do it's init, instead, it maintain a C program to do so.

Source of this init program is located at system/core/init folder of android platform source.
By default, it will load /init.rc to parse, and do init job.
Tracing into system/core/init/init.c, you will see it's him to print out " A N D R O I D" in the start up menu ( or by display a embedded image if in graphic mode )

init.rc is very similar with normal linux boot script, just as it's interpret and execute by by /init

We could look into /init.rc, then we could know what service/module is necessary for bring up a Android OS.
 Below is grab from android sdk emulator image :


on init

sysclktz 0

loglevel 3

# setup the global environment
export PATH /sbin:/system/sbin:/system/bin:/system/xbin
export LD_LIBRARY_PATH /system/lib
export ANDROID_BOOTLOGO 1
export ANDROID_ROOT /system
export ANDROID_ASSETS /system/app
export ANDROID_DATA /data
export EXTERNAL_STORAGE /sdcard
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar

# Backward compatibility
symlink system/etc /etc
symlink system/lib /lib

# create mountpoints and mount tmpfs on sqlite_stmt_journals and debugfs on d
mkdir /d
chown system system /sdcard
chmod 0777 /sdcard
mkdir /data 0771 system system
mkdir /cache 0770 system cache
mkdir /sqlite_stmt_journals 01777 root root
mount tmpfs tmpfs /sqlite_stmt_journals size=4m
mount debugfs debugfs /d

mount rootfs rootfs / ro remount

write /proc/sys/kernel/panic_on_oops 1
write /proc/sys/kernel/hung_task_timeout_secs 0
write /proc/cpu/alignment 4
write /proc/sys/kernel/sched_latency_ns 10000000
write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000

# mount mtd partitions
# TODO: this should be mounted by fs vol id (i.e. /dev/block-by-volid/system),
# once init gets that functionality.
# mount ext3 /dev/block/sda6 /system
# mount ext3 /dev/block/sda6 /system ro remount

# We chown/chmod /data again so because mount is run as root + defaults
# mount ext3 /dev/block/sda8 /data
chown system system /data
chmod 0771 /data

# Same reason as /data above
# mount ext3 /dev/block/sda5 /cache
chown system cache /cache
chmod 0770 /cache

# This may have been created by the recovery system with odd permissions
chown system system /cache/recovery
chmod 0770 /cache/recovery

# create basic filesystem structure
mkdir /data/misc 01771 system misc
mkdir /data/misc/hcid 0770 bluetooth bluetooth
mkdir /data/local 0771 shell shell
mkdir /data/local/tmp 0771 shell shell
mkdir /data/data 0771 system system
mkdir /data/app-private 0771 system system
mkdir /data/app 0771 system system
mkdir /data/property 0700 root root

mkdir /data/misc/wifi 0770 wifi wifi
mkdir /data/misc/wifi/sockets 0770 wifi wifi
mkdir /data/system/wpa_supplicant 0770 wifi wifi
mkdir /data/misc/dhcp 0770 dhcp dhcp
chown dhcp dhcp /data/misc/dhcp

# create dalvik-cache and double-check the perms
mkdir /data/dalvik-cache 0771 system system
chown system system /data/dalvik-cache
chmod 0771 /data/dalvik-cache

# create the lost+found directories, so as to enforce our permissions
mkdir /data/lost+found 0770
mkdir /cache/lost+found 0770

# double check the perms, in case lost+found already exists, and set owner
chown root root /data/lost+found
chmod 0770 /data/lost+found
chown root root /cache/lost+found
chmod 0770 /cache/lost+found


### Load some modules

on boot
# basic network init
ifup lo
hostname localhost
domainname localdomain

# set RLIMIT_NICE to allow priorities from 19 to -20
setrlimit 13 40 40

# Define the oom_adj values for the classes of processes that can be
# killed by the kernel. These are used in ActivityManagerService.
setprop ro.FOREGROUND_APP_ADJ 0
setprop ro.VISIBLE_APP_ADJ 1
setprop ro.SECONDARY_SERVER_ADJ 2
setprop ro.BACKUP_APP_ADJ 2
setprop ro.HOME_APP_ADJ 4
setprop ro.HIDDEN_APP_MIN_ADJ 7
setprop ro.CONTENT_PROVIDER_ADJ 14
setprop ro.EMPTY_APP_ADJ 15

# Define the memory thresholds at which the above process classes will
# be killed. These numbers are in pages (4k).
setprop ro.FOREGROUND_APP_MEM 1536
setprop ro.VISIBLE_APP_MEM 2048
setprop ro.SECONDARY_SERVER_MEM 4096
setprop ro.BACKUP_APP_MEM 4096
setprop ro.HOME_APP_MEM 4096
setprop ro.HIDDEN_APP_MEM 8192
setprop ro.CONTENT_PROVIDER_MEM 8704
setprop ro.EMPTY_APP_MEM 16384

# Write value must be consistent with the above properties.
write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15

write /proc/sys/vm/overcommit_memory 1
write /proc/sys/vm/min_free_order_shift 4
write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,8192,8704,16384

# Set init its forked children's oom_adj.
write /proc/1/oom_adj -16

# Permissions for System Server and daemons.
chown radio system /sys/android_power/state
chown radio system /sys/android_power/request_state
chown radio system /sys/android_power/acquire_full_wake_lock
chown radio system /sys/android_power/acquire_partial_wake_lock
chown radio system /sys/android_power/release_wake_lock
chown radio system /sys/power/state
chown radio system /sys/power/wake_lock
chown radio system /sys/power/wake_unlock
chmod 0660 /sys/power/state
chmod 0660 /sys/power/wake_lock
chmod 0660 /sys/power/wake_unlock
chown system system /sys/class/timed_output/vibrator/enable
chown system system /sys/class/leds/keyboard-backlight/brightness
chown system system /sys/class/leds/lcd-backlight/brightness
chown system system /sys/class/leds/button-backlight/brightness
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/device/grpfreq
chown system system /sys/class/leds/red/device/grppwm
chown system system /sys/class/leds/red/device/blink
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/device/grpfreq
chown system system /sys/class/leds/red/device/grppwm
chown system system /sys/class/leds/red/device/blink
chown system system /sys/class/timed_output/vibrator/enable
chown system system /sys/module/sco/parameters/disable_esco
chown system system /sys/kernel/ipv4/tcp_wmem_min
chown system system /sys/kernel/ipv4/tcp_wmem_def
chown system system /sys/kernel/ipv4/tcp_wmem_max
chown system system /sys/kernel/ipv4/tcp_rmem_min
chown system system /sys/kernel/ipv4/tcp_rmem_def
chown system system /sys/kernel/ipv4/tcp_rmem_max
chown root radio /proc/cmdline

# Define TCP buffer sizes for various networks
# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208
setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208
setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040
setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680

setprop EXTERNAL_STORAGE_STATE unmounted

class_start default

## Daemon processes to be run by init.
##
service console /system/bin/sh
console

# adbd is controlled by the persist.service.adb.enable system property
service adbd /sbin/adbd

on property:persist.service.adb.enable=1
start adbd

on property:persist.service.adb.enable=0
stop adbd

service servicemanager /system/bin/servicemanager
user system
critical
onrestart restart zygote
onrestart restart media

service vold /system/bin/vold
socket vold stream 0660 root mount

#service mountd /system/bin/mountd
# socket mountd stream 0660 root mount

service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
socket zygote stream 666
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on

service media /system/bin/mediaserver
user media
group system audio camera graphics inet net_bt net_bt_admin

service bootanim /system/bin/bootanimation
user graphics
group graphics
disabled
oneshot

service installd /system/bin/installd
socket installd stream 600 system system

service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0 -c /data/misc/wifi/wpa_supplicant.conf
group system wifi
disabled
oneshot

service dbus /system/bin/dbus-daemon --system --nofork
socket dbus stream 660 bluetooth bluetooth
user bluetooth
group bluetooth net_bt_admin

service hcid /system/bin/hcid -d -s -n -f /etc/bluez/hcid.conf
socket bluetooth stream 660 bluetooth bluetooth
socket dbus_bluetooth stream 660 bluetooth bluetooth
group bluetooth net_bt_admin misc
disabled

service hfag /system/bin/sdptool add --channel=10 HFAG
user bluetooth
group bluetooth net_bt_admin misc
disabled
oneshot

service hsag /system/bin/sdptool add --channel=11 HSAG
user bluetooth
group bluetooth net_bt_admin misc
disabled
oneshot

service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so -- -d /dev/ttyUSB1
socket rild stream 660 root radio
socket rild-debug stream 660 radio system
user root
group radio cache inet misc

service ppp /system/bin/pppd call gprs
user root
group system radio
disabled
oneshot

#Please do not change anything below this line. If you want to add new service, add it above this line
#REMOVE FROM HERE
service dhcpcd /system/bin/dhcpcd wlan0
group system dhcp
disabled
oneshot
Files inside android emulator :

neomac2:images neo$ pwd
/Users/neo/Downloads/android/android-sdk-mac_86/platforms/android-2.1/images
neomac2:images neo$ file *
NOTICE.txt:   ISO-8859 English text
kernel-qemu:  data
ramdisk.img:  gzip compressed data, from Unix
system.img:   VMS Alpha executable
userdata.img: VMS Alpha executable
neomac2:images neo$

system.img, userdata.img is actually yaffs image files, could use unyaffs to unpack :

http://code.google.com/p/unyaffs/downloads/list

Sunday, April 04, 2010

How to build squashfs-tools under mac osx

http://zettelchen.blogspot.com/2009/04/build-squashfs-tools-for-mac-os-x.html

1. remove FNM_EXTMATCH, it does not exist at mac
2. include

Thursday, March 11, 2010

iCal <-> gCal bi-direction sync 


refer to :
http://gcaldaemon.sourceforge.net/usage13.html

confirm working at 10.6 OSX, all other solution did not really bi-direction, or had some limitation.

Friday, March 05, 2010

Use Android phone as 3G modem on Mac OSX

** Only tested at Google Nexus One

Reference from :
Using Android Phone as a USB Tether on Mac OS X
Tethering android and OSX without root
Mac OS X Droid Tethering (USB/Wired)

1. Download and install necessary applications at OSX :
- TunnelBlick OpenVPN for Mac OS X
- tuntap for Mac OS X
* need to reboot to make sure kext got loaded at startup.
* or manually load them by blow command w/o reboot :
sudo kextload /Library/Extensions/tun.kext
sudo kextload /Library/Extensions/tap.kext

2. Download and install azilink.apk at android phone :
- azilink for google android
* execute azilink at android phone, enable service

3. Download Android SDK, cp tools/adb into executable path ( like /usr/sbin )

4. Enable USB debugging on the Android phone :
- Settings>Applications>Development>USB debugging.

5. Save blow script into ~/azilink.sh ( from http://pastie.org/701122 ), and execute it :

#!/bin/bash
#
# azilink for OS X
# based on http://pastie.org/405289 but works with Tunnelblick only
# (no need to install a separate copy of OpenVPN2 from macports
# or building from source by hand, thankfully)
# Requires:
# - azilink running on android phone (http://code.google.com/p/azilink/)
# (run the app and check the box to start the service).
# - adb on system path (comes with the Android SDK;
# add its tools folder to your PATH in ~/.profile or
# place or symlink the sdk's tools/adb file in e.g. usr/local/bin or somewhere else on the PATH)
# - Tunnelblick, a nice OS X packaging of OpenVPN (http://code.google.com/p/tunnelblick/)
# Install Tunnelblick to Applications. Tested with Tunnelblick 3.0b22

init() {
adb forward tcp:41927 tcp:41927
sudo /Applications/Tunnelblick.app/Contents/Resources/openvpn --dev tun \
--script-security 2\
--remote 127.0.0.1 41927 \
--proto tcp-client \
--ifconfig 192.168.56.2 192.168.56.1 \
--route 0.0.0.0 128.0.0.0 \
--route 128.0.0.0 128.0.0.0 \
--keepalive 10 30 \
--up "$0 up" \
--down "$0 down"
}

up() {
tun_dev=$1
ns=192.168.56.1
sudo /usr/sbin/scutil << EOF
open
d.init
get State:/Network/Interface/$tun_dev/IPv4
d.add InterfaceName $tun_dev
set State:/Network/Service/openvpn-$tun_dev/IPv4

d.init
d.add ServerAddresses * $ns
set State:/Network/Service/openvpn-$tun_dev/DNS
quit
EOF
}


down() {
tun_dev=$1
sudo /usr/sbin/scutil << EOF
open
remove State:/Network/Service/openvpn-$tun_dev/IPv4
remove State:/Network/Service/openvpn-$tun_dev/DNS
quit
EOF
}


case $1 in
up ) up $2 ;; # openvpn will pass tun/tap dev as $2
down) down $2 ;;
* ) init ;;
esac

Friday, February 26, 2010

Why arm chroot environment will work.

Use build-arm-chroot to create a folder that is arm based environment:
root@neo-u910:~# apt-get install qemu-arm-static
root@neo-u910:~# build-arm-chroot karmic test-123

Remove qemu-arm-static for testing
root@neo-u910:~# apt-get remove qemu-arm-static
root@neo-u910:~# rm test-123/usr/bin/qemu-arm-static

File one file, then we know it's ARM executable file :
root@neo-u910:~# file test-123/usr/bin/lscpu
test-123/usr/bin/lscpu: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped

And we can not execute it :
root@neo-u910:~# ./test-123/usr/bin/lscpu
bash: ./test-123/usr/bin/lscpu: cannot execute binary file

And we can not chroot into.
root@neo-u910:~# chroot test-123/
chroot: cannot run command `/bin/bash': Exec format error

Check our binfmt_misc setting, there is no arm related setting
root@neo-u910:~# ls /proc/sys/fs/binfmt_misc/
cli python2.6 register status

Now we install it back
root@neo-u910:~# apt-get install qemu-arm-static
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
qemu-arm-static
0 upgraded, 1 newly installed, 0 to remove and 185 not upgraded.
Need to get 0B/559kB of archives.
After this operation, 1,430kB of additional disk space will be used.
Selecting previously deselected package qemu-arm-static.
(Reading database ... 137788 files and directories currently installed.)
Unpacking qemu-arm-static (from .../qemu-arm-static_0.11.0-0ubuntu6.3_i386.deb) ...
Setting up qemu-arm-static (0.11.0-0ubuntu6.3) ...
vm.vdso_enabled = 0
vm.mmap_min_addr = 4097

And cp into target system ( recover what build-arm-chroot will do )
root@neo-u910:~# cp /usr/bin/qemu-arm-static test-123

Now binfmt_misc/arm exist.
root@neo-u910:~# ls /proc/sys/fs/binfmt_misc/
arm cli python2.6 register status
root@neo-u910:~# cat /proc/sys/fs/binfmt_misc/arm
enabled
interpreter /usr/bin/qemu-arm-static
flags:
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00fffffffffffffffffeffffff

Still can't execute it, but it's because of library path incorrect
root@neo-u910:~# ./test-123/usr/bin/lscpu
/lib/ld-linux.so.3: No such file or directory

Now chroot working
root@neo-u910:~# chroot test-123/
root@neo-u910:~# ./usr/bin/lscpu
Architecture: armv5tel
CPU(s): 2
Thread(s) per core: 1
Core(s) per socket: 2
CPU socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 15
Stepping: 6
CPU MHz: 1596.000
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K

Exit out, and look into what postinst of qemu-arm-static done :
root@neo-u910:~# dpkg -e /var/cache/apt/archives/qemu-arm-static_0.11.0-0ubuntu6.3_i386.deb
root@neo-u910:~# cat DEBIAN/postinst
#!/bin/sh

set -e

if [ "$1" = configure ] && which update-binfmts >/dev/null; then
update-binfmts --import arm
fi

if [ "$1" = configure ]; then
sysctl -p /etc/sysctl.d/qemu-arm-static.sysctl.conf
fi

exit 0

Actually, we could execute both x86/arm application inside this chroot environment :
root@neo-u910:/# file /usr/bin/qemu-arm-static
/usr/bin/qemu-arm-static: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.15, stripped
root@neo-u910:/# /usr/bin/qemu-arm-static -cpu ?
Available CPUs:
arm926
arm946
arm1026
arm1136
arm1136-r2
arm11mpcore
cortex-m3
cortex-a8
ti925t
pxa250
pxa255
pxa260
pxa261
pxa262
pxa270
pxa270-a0
pxa270-a1
pxa270-b0
pxa270-b1
pxa270-c0
pxa270-c5
any

Some explanation about binfmt_misc :
http://en.wikipedia.org/wiki/Binfmt_misc

Wednesday, February 17, 2010

debootstrap

debootstrap can be use to install a debian package based linux system.
Including same arch or not.

How to install a chroot arm linux environment :
https://wiki.ubuntu.com/ARM/BuildEABIChroot

So that can be use a powerful host system for native compile application for arm arch.

debootstrap is actually a generic script to install all kind version of debian based system.
Per distro/version specific information is store at /usr/share/debootstrap.

It will report to below information.

1. DEF_MIRROR
mirror site : where store the .deb files
per distro script will call default_mirror in /usr/share/debootstrap/functions, then export DEF_MIRROR

2. DOWNLOAD_DEBS, DOWNLOAD_INDICES
mirror style : release or main



1. parse necessary information
depends on 1st, 2nd stage, add necessary job item

2. include per distro script

3. run job item


for install a deb based linux system, it may need below step :

1. finddebs :

download_indices :
(1) get release file : http://ports.ubuntu.com/ubuntu-ports/dists/karmic/Release
(2) grep Components from release file, found main restricted universe multiverse
(3) get package.gz according to arch/distro, ex from :
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/main/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/restricted/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/universe/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/multiverse/binary-armel/

work_out_debs :

work_out_debs parse out three catalog, from unpacked Package file.
required : for package that list as "Priority: required"
base : for package that list as "Priority: important"
if buildd then base will be "Build-Essential: yes"
if fakechroot, minbase then base will be "apt"

finally, set up all_debs="$required $base"

2. printdebs - if assigned
just echo $all_debs

3. dldebs
download all .deb into ${target}/var/lib/apt, ${target}/var/cache/apt
download_main will parse file name from Package, then download package, also check md5.

4. maketarball - if assigned
tar ${target}/var/lib/apt,${target}/ var/cache/apt into one tarball.

... stay tune ...

Sunday, January 10, 2010

Git 書籤

Git 初學筆記 - 指令操作教學
http://plog.longwin.com.tw/my_note-unix/2009/05/19/git-learn-initial-command-2009

Git 初學筆記 - 實作測試
http://plog.longwin.com.tw/my_note-unix/2009/05/20/git-learn-test-command-2009

Git 中文教程
http://www.bitsun.com/documents/gittutorcn.htm

使用 Git 管理源代碼
http://www.ibm.com/developerworks/cn/linux/l-git/index.html

Git 原始碼管理
http://www.qweruiop.org/nchcrails/posts/49

Everyday GIT With 20 Commands Or So
http://people.debian.org.tw/~jesse/git/everyday_zhtw.html

grub

ubuntu 9.10 default come with grub 1.97, dont know start from which version, menu.lst had done.
Now it use grub.cfg as the configuration file. It's format and syntax is not so easy to understand, and modify.

There are two place to modify with :
/etc/grub.d/ -> lots template and stage, seems allow to add extra grub menu item
/etc/default/grub -> some general setting apply to all items

My target is remove the kernel bootsplash, also make a graphic console, so below settings satisfied me :

__
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=4" # removed splash

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=800x600
__
Also it wont accept vga=xxx as kernel cmdline now, need to GRUB_GFXMODE=???x??? instead.

Test result :
1.
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=4 vga=791"
#GRUB_TERMINAL=console
GRUB_GFXMODE=800x600
-> grub in 800x600 mode, and linux console in 1024x768 mode

2.
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=4 vga=791"
GRUB_TERMINAL=console
GRUB_GFXMODE=800x600
-> grub in text mode, and linux console in text mode

Conclusion :
Seems both grub should be in graphic mode ( by assign GRUB_TERMINAL,GRUB_GFXMODE )
And also linux kernel ( by assign vga=791 ), otherwise linux console wont be in graphic mode.

Older grub/syslinux, only vga=791 would be enough

Saturday, January 09, 2010

dvtm - Tiling window inside console

很多的 embedded 開發者, 平常都是用 vm 裝著 linux, 然後 host 開著 Windows 進行著 W皮L骨的開發。雖然我習慣直接用 Linux host 開發, 但是近來改用 Mac 後, 實在捨不得把漂漂的 Mac 改成 Linux 工作。所以也就開始開著 VM 裝著 Linux 研究, 在 VM 下的 Linux, 其實也是開著 terminal 工作居多。所以多半是用 awesome wm 來便利工作, 有些時候不想切到 VM console, 改用 ssh 連線時, 就缺少了 tiled window 的功能。

dvtm 是用來解決的
http://www.brain-dump.org/projects/dvtm/
http://www.brain-dump.org/projects/dvtm/screenshot1.png

default mod key 是 ctrl-g

darwin port 也有 porting 這個 package 到 mac, 所以 mac 下也可以用啦~

Keyboard commands
Mod Each keybinding begins with Mod which defaults to ^g but can be changed in config.h or with the -m
command line option.

Mod-c Create a new shell window.

Mod-x Close focused window.

Mod-l Increases the master area width about 5% (all except grid and fullscreen layout).

Mod-h Decreases the master area width about 5% (all except grid and fullscreen layout).

Mod-j Focus next window.

Mod-k Focus previous window.

Mod-[1..n]
Focus the nth window.

Mod-. Toggle minimization of current window.

Mod-u Focus next non minimized window.

Mod-i Focus prev non minimized window.

Mod-m Maximize current window (change to fullscreen layout).

Mod-PageUp
Scroll up.

Mod-PageDown
Scroll down.

Mod-Space
Toggle between defined layouts (affects all windows).

Mod-Enter
Zooms/cycles current window to/from master area.

Mod-t Change to vertical stack tiling layout.

Mod-b Change to bottom stack tiling layout.

Mod-g Change to grid layout.

Mod-s Shows/hides the status bar.

Mod-r Redraw whole screen.

Mod-G Escape the next typed key.

Mod-X Lock screen.

Mod-B Toggle bell (off by default).

Mod-M Toggle dvtm mouse grabbing. Mod-q Quit dvtm.

Ubuntu 文字模式開機

sudo update-rc.d -f gdm remove

or
echo false > /etc/X11/default-display-manager

/etc/X11/default-display-manager 記錄了用哪個 display-manager
如果是 gdm, 多半是 : /usr/sbin/gdm

另, 以下講的更完整:
http://www.cyberciti.biz/faq/prevent-xorg-from-starting-in-linux/