显示标签为“Linux”的博文。显示所有博文
显示标签为“Linux”的博文。显示所有博文

2010年11月4日星期四

/proc/cpuinfoの見方

# cat /proc/cpuinfo |egrep 'physical id|core' |sort

1个物理CPU,4个Core,单线程

core id         : 0
core id         : 1
core id         : 2
core id         : 3
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
physical id     : 0
physical id     : 0
physical id     : 0
physical id     : 0


2个物理CPU,2core,2线程

core id         : 0
core id         : 0
core id         : 1
core id         : 1
core id         : 2
core id         : 2
core id         : 3
core id         : 3
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
physical id     : 0
physical id     : 0
physical id     : 0
physical id     : 0
physical id     : 1
physical id     : 1
physical id     : 1
physical id     : 1

2010年10月8日星期五

小技巧:如何把竖着排列的数据转换成横着排列

最开始想到的是用 xargs 命令,这样就可以把数据显示出来了。

cat filename  | xargs

但是xargs是专为执行命令开发的,所以当数据头尾有双引号或者单引号是会被删掉的。
之后想到的是用替换命令把行尾的回车替换成空格

cat filename | sed -e 's/\n/ /'
可惜sed对回车的正规表达式支持不够。

最后我改用perl,perl的正规表达式很强,该有的都有,不该有的也有:)命令如下
cat filename | perl -pe 's/\n/ /'

perl对处理文字方面的确很强。可以与其他命令串联组合使用,很实用。

2010年9月23日星期四

在Linux下安装无线网卡

LInux有一个名为NdisWrapper的工具转换Windows的无线驱动。

1.下载NdisWrapper程序
  从Google上搜索NdisWrapper,并下载。 我的为 ndiswrapper-1.56.tar.gz
2. 复制到 /usr/local/src
3. 解压
  tar zxvf ndiswrapper-1.56.tar.gz
4. 编译并安装
  cd ndiswrapper-1.56
  make
  make install
如果没有安装开发环境,要先安装
我的环境是CentOS,用以下命令
  yun groupinstall 'Development Tools'
5. 下载无线网卡的驱动
  我用的是buffalo的WLI-U2-KAMG54
6. 解压
  下载文件为wdrv-1052.exe,是用lha压缩的 (type wdrv-1052.exe 可查看到)
  下载Linux下的lha包
  rpm -ivh lha-xxxx.rpm 安装lha
  lha e  wdrv-1052.exe
7. 安装驱动
  cd到相应的驱动的目录下,下面还有win98, win200, vista三个版本,我使用了win2000
 下面有好几个文件,使用以 .inf  结尾的文件 netkamg.inf, netkamgl.inf
  ndiswrapper -i netkamg.inf
  ndiswrapper -i netkamgl.inf
8. 启动无线卡
  ndiswrapper -m # 建立一个名为wlan0的假名
  ifconfig wlan0 up  # 启用wlan0
  ifconfig  # 确认启动
  iwlist wlan0 s  # 搜索无线网络
9. 之后你就可以用iwconfig设置无线参数使用他了

2010年7月9日星期五

Linux画面解像度設定

我的显示器经常不能识别出来,很多时候都是800x600的解析度。
下面是1024x768时的设定,供参考

在Centos里面无需手写,用system-config-display来设置。

cat /etc/X11/xorg.conf
# Xorg configuration created by system-config-display

Section "ServerLayout"
Identifier "single head configuration"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "jp106"
Option "XkbLayout" "jp"
EndSection

Section "Monitor"

### Comment all HorizSync and VertSync values to use DDC:
Identifier "Monitor0"
ModelName "LCD Panel 1024x768"
### Comment all HorizSync and VertSync values to use DDC:
HorizSync 31.5 - 48.0
VertRefresh 56.0 - 65.0
Option "dpms"
EndSection

Section "Device"
Identifier "Videocard0"
Driver "savage"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection


另外用

gtf 1024 768 60

# 1024x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 64.11 MHz
Modeline "1024x768_60.00" 64.11 1024 1080 1184 1344 768 769 772 795 -HSync +Vsync

可以得到modeline的值,有需要可把这行粘帖到Monitor区里面

2010年6月2日星期三

Linux環境で日本語文字化け対応

たまにシステム内にShiftJISのロケールがなかったりします。
その時はmanマニュアルを参照すると文字化けします。

対処としては下記のように

function manj() { LANG=ja_JP.UTF-8 man $* | iconv -f utf8 -t sjis | less; }

それでmanの代わりにmanjを使えば日本語正しく表示されます。