2009年4月18日星期六

禁用组合键

郁闷死了,开 vbox 启用 usb 中的系统时误按了 ctl+alt+backspace ,导致桌面重启,usb 文件系统破坏。唉,还是把它们禁用了好。

1,ctl+alt+backspace

vim /etc/X11/xorg.conf

追加

Section "ServerFlags"
Option "DontZap" "yes"
EndSection

2,ctl+alt+del

vim /etc/inittab

注释

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

2009年4月17日星期五

debian下让virtualbox能使用usb的方法

1.创建一个 usbfs 的组,并且把当前用户添加到 usbfs 组中。

sudo groupadd usbfs
sudo adduser yourusername usbfs

2.编辑器 /etc/init.d/mountkernfs.sh

if [ -d /proc/bus/usb ]
then
domount usbfs usbdevfs /proc/bus/usb usbfs -onodev,noexec,nosuid
fi

在其中加入 devgid=1003,devmode=644,其中 1001 是我的 usbfs 组的 id,请根据实际情况修改

if [ -d /proc/bus/usb ]
then
domount usbfs usbdevfs /proc/bus/usb usbfs -onodev, noexec, nosuid, devgid=1001, devmode=664
fi

3. 重启机器,再运行virtualbox的时候就可以使用usb了

4. usb 启动

VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/HardDisks/UsbDisk.vmdk -rawdisk /dev/sdc -register

http://www.geektang.com/2009/03/debianvirtualboxusb.html

2009年4月15日星期三

fontconfig

fontconfig

这里是一些常用到属性的列表,关于所有的属性请 manpage

# family - String - 就是一般所看到的字型的名称了, 如 Arial
# style - String - 字型的 style, 像是 Regular, Bold, Italic...
# spacing - Int - 字型的宽度, Proportional 是有不同的宽度, monospace 是单一的宽度 (如 terminal 的字型)
# antialias - Bool - 决定该字型是否要被 anti-alias 绘制; 只能用在向量字型上 # hinting - Bool - 决定该字型是否要打开 hinting
# autohint - Bool - 决定是否要用 Freetype 自己的 hint 方法来 hint 字型, 还是用预设的方法来 hint
# rgba - Bool - 决定是否要用 subpixel 的方式来画字, 可以是 none (只用灰阶), rgb, bgr, vrgb, vbgr

match 主要有两种用法,一种是 pattern match, 另一种是 font match. 前者会把所有的字型 match 出来,所以针对它的更改会套用到所有的字型的选择方式上。后者只是它是针对个别字型的属性作修改。

<match target="pattern/font">
...
</match>

中间放的可以是一连串的 test, 然后是一连串的 edit. test 的用法是:
<test qual="any|all|first|not_first" name="属性" compare="eq|not_eq|less|less_eq|more|more_eq|contains|not_contains">
...
</test>
any 指的是说, 只要字型的该属性 list 之中有一项有符合要 test 的值, test 就会成立。all 的话要 list 之中所有的都符合,first 要第一个符合, not_first 要除了第一个以外有符合的。通常只会用到 any, 预设也是 any. name 里面填的就是前面所提的属性, 如 name="family". compare 是比较的条件, eq 是相等, less 是小于, 以此类推。 <test> 所包住的那个值就是要用来比较的值,包括: int, double, string, matrix, bool 等等。一旦 test 的条件都成立, 就会进行到 edit 的阶段,代表编辑符合条件上述 test 条件的属性:

<edit name="属性" mode="assign|assign_replace|prepend|append|prepend_first|append_last">

注意在 fontconfig 中, 属性 (property) 可以是一个 list, 亦即一个属性可有许多的值。 assign 是说把 match 到的值取代掉, assign_replace 是说把该 list 的所有值取代成指定的值, prepend 则是插在 list 中被 match 到的那个值的前头, 以此类推。</edit></test>

参考:
Fontconfig用户手册
http://hi.baidu.com/jmlover/blog/item/5ce6a6864e29cf3f67096e0a.html
Fontconfig配置详解
http://hi.baidu.com/jmlover/blog/item/effef6036bb210ed08fa930a.html

字体设置 (简体中文)
http://wiki.archlinux.org/index.php/%E5%AD%97%E4%BD%93%E8%AE%BE%E7%BD%AE

2009年4月14日星期二

修改 linux 分区卷标相关命令

修改 linux 分区卷标相关命令
modify filesystem partition labels in linux.

package required
要安装的包
sudo apt-get install e2fsprogs
sudo apt-get install reiserfsprogs
sudo apt-get install xfsprogs
sudo apt-get install jfsutils
sudo apt-get install mtools
sudo apt-get install ntfsprogs

ext2/ext3/ext4
sudo e2label /dev/sdb1 my_label

reiserfs
sudo reiserfstune -l my_label /dev/sdb1

xfs
xfs_admin -l my_label /dev/sdb1

jfs
sudo jfs_tune -L my_label /dev/sdb1

fat16/fat32
sudo mlabel -i /dev/sdb1 ::my_label

ntfs
sudo ntfslabel /dev/sdb1 my_label

man CMD for details.
更详细的说明请看手册页。

Partitions generally need to be unmounted before you can fiddle with them, so unmount the partition of the device you want to change the label for.
卸载要操作的分区先。

2009年4月13日星期一

shell 提示符颜色

shell 提示符颜色

PS1="\[\033[1;36;31m\t \033[1;35;32m\w \033[1;31;34m\$ \033[0m\]"
转义序列要用 \[ \] 括起来,\033[1;36;31m 是最小的转义单位,也有用\e[1;36;31m的,可能是不同的 shell 的原因,

字体属性对照表:1、0、4、22、25、24、27、7,
字体属性定义表:黑体、非黑体、下画线、非下画线、闪烁、非闪烁、翻转、非翻转

前景颜色对照表:30、31、32、33、34、35、36和37
背景颜色对照表:40、41、42、43、44、45、46和47
颜色定义对照表:黑色、红色、绿色、黄色、蓝色、粉色、青色和白色

这是一些转义字符,下面详细解释:

\d :代表日期
\H :完整的主机名称
\h :仅取主机的第一个名字
\t :显示时间为24小时格式
\T :显示时间为12小时格式
\A :显示时间为24小时格式
\u :当前用户的账号名称
\v :BASH的版本信息
\w :完整的工作目录名称
\W :利用basename取得工作目录名称,所以只会列出最后一个目录
\# :下达的第几个命令
\$ :提示字符
\n :新建一行

2009年4月11日星期六

Debian lenny amd64 硬盘安装

Debian lenny amd64 硬盘安装

对 ubuntu 很无奈,因为舍不得以前好不容易配置,暂先留着。

1,先用 gparted 把以前用来放电影的分区弄出一点来,分 /,/usr,/var,/home 分区(共享以前的 swap 分区),

2,下载 debian lenny 的 businesscard,再加上用来硬盘引导的 vmlinuz, initrd.gz, 这里要注意的是 businesscard ISO 中的 vmlinuz 和 initrd.gz 并不能用来从硬盘引导安装 debian。

http://cdimage.debian.org/debian-cd/5.0.0/amd64/iso-cd/
http://ftp.debian.org/debian/dists/lenny/main/installer-amd64/current/images/hd-media/

3,修改 menu.lst, 这里很方便的是没有像 ubuntu 那样多的参数,很简洁。

title Debian Install
root (hd0,6)
kernel /vmlinuz
initrd /initrd.gz root=/dev/ram ramdisk_size=20480
boot

4,安装过程中选择好分区,连上网络,就开始装了,很简单。

初步配置

1,成为sudoer
$su
#visudo
#vim /etc/group

2,安装scim
$sudo aptitude install scim scim-pinyin scim-tables-zh scim-bridge-client-gtk scim-bridge-client-qt
$mkdir ~/.xinput.d
$cd ~/.xinput.d
$ln -s /etc/X11/xinit/xinput.d/scim-bridge ./en_US
$ln -s /etc/X11/xinit/xinput.d/scim-bridge ./zh_CN

3,关于 locale
增加其它locale
$sudo vim /etc/locale.gen
$sudo locale-gen

关于 locale 的变量和文件
$LANG '/etc/default/locale' #系统 locale
$LANGUAGE '' #gdm登录界面语言
'~/.dmrc' #gnome 会话中语言

$cat ~/.dmrc
[Desktop]
Session=default
Language=en_US.UTF-8 #gnome会话语言

PS:从上面可以看出,即便是用 export 使命设置了系统的 locale,gnome 会话还是使用默认的语言,要想改变 gnome 会话语言,要么在登录时改变,要么编辑 ~/.dmrc 文件。

3,安装wqy
到 wqy 官方下载矢量字体 .ttc,放在字体目录/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc,和它的一个 44-wqy-zenhei.conf 文件,放在 /etc/fonts/conf.avail,在conf.d 中建一个连接
$fc-cache -fv
PS:为什么要到官方下载字体文件呢,因为 debian 中的 wqy 包较老了,比官方的要少等宽字体。

4,中文选择
$touch ~/.fonts.conf
$vim ~/.fonts.conf

5,安装 nvidia
$apt-cache search nvidia
$sudo aptitude install nvidia-kernel-2.6.26-1-amd64 nvidia-settings nvidia-xconfig
$sudo nvidia-xconfig

或安装官方 nvidia
$sudo aptitude install build-essential linux-headers-2.6.26-1-amd64 linux-image-2.6.26-1-amd64
$sudo ./NVIDIA-Linux-x86_64-180.44-pkg2.run
$nvidia-xconfig

6,其它
$sudo aptitude install samba smbfs smbclient ntfs-3g dosfstools

$sudo aptitide install iceweasel axel rtorrent azureus filezilla

$sudo aptitide install smplayer audacious

$sudo aptitide install ia32-libs ia32-libs-gtk
$sudo dpkg --force-architecture -i linuxqq_v1.0.2-beta1_i386.deb
注:Linux QQ输入中文解决
复制 32位的 im-scim-bridge.so,im-scim.so 到 /usr/lib32/gtk-2.0/2.10.0/immodules/ ,备份/etc/gtk-2.0/gtk.immodules.32,新建gtk.immodules.32,内容见评论。

2009年3月30日星期一

python 参考

pthon 学习参考

中文:
下面两篇都有 pdf 下载,不过还是第一篇结构合理些。
程序员指南.pdf
核心编程 第二版.pdf

英文:
直接看 /usr/share/doc 中的文档吧,没有就自己安装,文档例子很多,很容易读。

2009年3月28日星期六

mplayer中的声道问题

mplayer中的声道问题
左声道
mplayer -af channels=1:1:1 filename.rmvb

右声道
mplayer -af channels=1:1 filename.rmvb

2009年3月27日星期五

启动管理器

gnu grub

stage1(mbr), stage1.5, stage2, menu.lst
manual: http://www.gnu.org/software/grub/manual/html_node/

grub4dos

mbr, grldr, menu.lst
wiki: http://grub4dos.sourceforge.net/wiki/

lilo

mbr, map, boot.b, lilo.conf
manpage: http://swoolley.org/man.cgi/lilo

syslinux

mbr, ldlinux.sys, syslinux.cfg
http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project

isolinux

mbr, isolinux.bin, isolinux.cfg
http://syslinux.zytor.com/wiki/index.php/The_Syslinux_Project

2009年3月26日星期四

bash shortcuts

http://blog.neu.edu.cn/sonic3021/archives/46

Bash快捷键
一般組合鍵

* Ctrl-U: 清除一行中游標之前的所有文字。
* Ctrl-H: 移除游標前的一個字元。
* Ctrl-D: 結束輸入。(如果您在 shell 下,就會跳出該 shell)
* Ctrl-C: 終止正在執行的程式。
* Ctrl-Z: 暫時停止程式。 (將該工作放到背景)
* Ctrl-S: 停止輸出到畫面上。(類似 Scroll Lock)
* Ctrl-Q: 回復輸出到畫面上。
* 上/下箭頭: 開始搜尋過去的命令。
* Ctrl-R: 開始漸進收尋過去的命令。
* TAB: 擴展要輸入的檔案到命令列上。
* Ctrl-V TAB: 輸入 TAB,而不是命令列擴展

Emacs 模式下的組合鍵

Bash組合鍵運行預設是emacs模式,但也可以改環境變數EDITOR 成Vi 模式。但是GNU/Linux 下大部分的文字應用程式預設都是emacs模式,建議學emacs模式比較方便。

* Ctrl-A 游標跳至行首,也可用 Home
* Ctrl-E 游標跳至行末,也可用 End
* Meta-B 游標倒退跳一個字
* Meta-F 游標向前跳一個字
* Ctrl-U 從游標倒退刪回至行首
* Ctrl-W 從游標倒退刪最後一個參數, 看起來跟 meta-backspace 一樣
* meta-d Kill from the cursor to the end of the current word, or, if between words, to the end of the next word.
* Ctrl-K 從游標向前刪至行尾
* Ctrl-Y 貼上bash刪除緩衝區裡的內容 或 Insert鍵
* Meta-Y Rotate the kill-ring, and yank the new top
* Ctrl-_ 回手(undo)

巨集

* Ctrl-x ( 開始紀錄巨集
* Ctrl-x ) 結束紀錄巨集
* Ctrl-x e 執行巨集

命令回溯運行

* !xyz回溯運行最後一個以xyz開頭的命令
* !?xyz回溯運行最後一個包含xyz 的命令
* !!回溯運行前一命令
* !號碼n回溯運行第n號命令
* !-號碼n(倒數第n號命令)
* !* 前一命令的所有參數(意即 前一命令去掉第一個字)
* !^ 前一命令的第一個參數
* !$ 前一命令的最後一個參數(這裡字是指以空白分開的 "詞" 而非 字元) 相當於 Meta-. 或 meta-_ 鍵

修改回溯命令內容

* ^被取代字元^取代字元
* :號碼 第幾參數 (第一參數是:0)。例:若前一命令共有三個參數 (共四個字),要去掉最後一個參數可用 !!:-2
* :p 光顯示命令而不執行
* :h Remove a trailing file name component, leaving only the head.
* :t Remove all leading file name components, leaving the tail.
* :r Remove a trailing suffix of the form .xxx, leaving the basename.
* :e Remove all but the trailing suffix.

在 bash 下也可以用 Ctrl-x Ctrl-e 來開啟編輯器來編輯命令。
Gnome-Terminal 鍵盤指定的問題

Gnome Terminal中 Alt鍵 被Menu bar 搶掉了,得用Esc鍵或其他鍵當Meta鍵

一般我們用

* back-space 產生 ASCII DEL
* delete 產生 跳出字元序列

這樣

* delete會取代傳統的 Ctrl-d : 往前刪
* back-space會取代傳統的 delete: 倒退刪

這樣 後退鍵 會倒退刪;刪除鍵 會往前刪。但 ESC-delete 就沒法工作 要用ESC-d