2008年10月9日星期四

升级 Ubuntu 8.10 后无法使用网络的问题

今天将系统从 Ubuntu 8.04 升级到 8.10 beta,基本上一切正常。只是本来在公司用得好好的网络链接,回到宿舍后却突然无法使用了。

使用 ifconfig 发现 eth0 没有从路由器上获得 IP 地址。在 /var/log/syslog 中看到系统不断地重复输出(3秒一次)

Oct 7 22:34:54 ubuntu NetworkManager: disconnected by the system bus.
Oct 7 22:34:57 ubuntu NetworkManager: nm_dbus_manager_start_service(): Could not acquire the NetworkManager service as it is already taken.

通过浏览日志发现,系统在启动的时候其实已经通过 DHCP 获得了 IP 地址,而且 Activation (eth0) Stage 的五个步骤也全部成功完成。但是随后输出一下日志

Oct 7 22:20:22 ubuntu NetworkManager: (eth0): carrier now OFF (device state 8 )
Oct 7 22:20:22 ubuntu NetworkManager: (eth0): device state change: 8 -> 2
Oct 7 22:20:22 ubuntu NetworkManager: (eth0): deactivating device.
Oct 7 22:20:22 ubuntu NetworkManager: eth0: canceled DHCP transaction, dhcp client pid 6853

不知道为什么会突然 carrier OFF。考虑到网上很多用户反映 Ubuntu 8.10 的 NetworkManager 不好用,不能排除新版本的 NetworkManager 依旧存在某些 bug。

如果需要快速恢复系统的网络链接,一个快捷的方法是编辑 /etc/network/interfaces 文件。我打开文件后发现其中内容只有 lo 的配置:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

于是为 eth0(有线链接)和 eth1(无线链接)加上配置,如下:

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp

保存之后执行
sudo /etc/init.d/networking restart
即可恢复。但是这时 NetworkManager 不再管理网络链接,点击其图标会提示 device is unmanaged。

如果希望保留 NetworkManager 的特性,还可以编辑 /etc/NetworkManager/nm-system-settings.conf,将其中的

[ifupdown]
managed=false

修改成为

[ifupdown]
managed=true

即可。

http://www.dreamcode.org/blog/posts/32.html原贴地址

2008年9月19日星期五

非常漂亮的GNOME主题

这是我最近使用GNOME桌面主题:Glow,确实非常漂亮。因为其自带了很多款配色,在统一的Widget样式上,你可以找到自己喜欢的配色。 

应朋友要求,所以写篇有关主题的安装与配置。


—–

这款主题名叫:Glow,来自GNOME-Look.org,与一般的GTK+2的主题不同,它需要另外一个系统并没有自带的GTK+引擎才能使用。因此在安装主题前,需要安装这个名为Aurora的GTK+引擎。

Aurora Gtk Engine可以在这里下载到:

http://www.gnome-look.org/content/show.php/Aurora+Gtk+Engine?content=56438

下载的压缩包里面有两个文件,解压后,其中aurora-1.4.tar.gz是引擎相关的,gtkrc_themes.tar.bz2是引擎自带的三个主题,你可以自己试用之。


linuxdesktop.cn/">

将其中的aurora-1.4.tar.gz解包,假设解压至主目录~/aurora-1.4。

接下来我们要编译aurora了,确认你已经安装好了相关开发包,如果没有的话,请打开终端执行sudo apt-get install gnome-core-devel

准备好以后,就开始编译吧!打开你的终端,然后执行下面的指令:

cd ~/aurora-1.4
./configure --prefix=/usr --enable-animation(其中enable-animation这个参数用于启用动画效果,aurora引擎具备一些动画效果)
make
sudo make install(或者你可以用sudo checkinstall来打包)



安装完成后,就可以去下载Glow主题了。

访问:http://www.gnome-look.org/content/show.php/Glow?content=85996

下载其中的GTK2 Theme(如果你是xfce桌面,选择Xfwm4),这里强烈建议安装Emerald边框,这样才能达到一致的效果。

安装Glow主题和Emerald的边框不必多言,到“系统”->“首选择”->“外观”即可安装。至于Emerald,首先保证你sudo apt-get install emerald,然后打开Emerald Theme Manager即可安装。

安装后,根据你自己喜欢的配色,选择喜爱的Glow吧!其中我选择的是Glow Water,即截图中显示的主题。还有各种亮色、暗色、绿色、红色等配色,一定有你喜欢的。


linuxdesktop.cn/">

至于图标主题的话,我使用的是Linux下普遍的Tango主题,大家也可以根据自己的喜好使

2008年8月28日星期四

ubuntu8.04解决flash不能显示中文的问题

修改/etc/fonts/conf.d/49-sansserif.conf内容如下,解决flash不能显示中文的问题:
代码:







sans-serif


serif


monospace


文泉驿正黑


2008年8月23日星期六

给VirtualBox的vdi文件瘦身

用VirtualBox,随着时间推移,其VDI文件越来越大,其中有很多是无效的数据,因此想办法去掉

第一步,下载SDelete,是MS出的,从http://www.microsoft.com/technet/sysinternals/Security/SDelete.mspx下载后,放到虚拟的WINDOWS里,在WINDOWS的命令行里运行

sdelete -c c:

目的是把硬盘里的空闲区域用0来填充

第二步,下载vditool,从http://www.virtualbox.org/download/testcase/vditool下好后,在命令行下运行,./vditool,显示其用法

vditool Copyright (c) 2004-2005 InnoTek Systemberatung GmbH.

Usage: vditool [Params]
Commands and params:
NEW Filename Mbytes - create new image;
DD Filename DDFilename - create new image From DD format image;
CONVERT Filename - convert VDI image From old format;
DUMP Filename - debug dump;
RESETGEO Filename - reset geometry information;
COPY FromImage ToImage - make image copy;
COPYDD FromImage DDFilename - make a DD copy of the image;
SHRINK Filename - optimize (reduce) VDI image size.

可以看到SHRINK这个参数可以减少VDI的大小,还有一个DD参数,可以从DD文件创建VDI,方便测试自己写的操作系统

运行./vditool SHRINK vdifilename,可以比较慢,主要看VDI文件的大小,不过这样做之后,大小就可以减少了

2008年8月20日星期三

ubuntu删除旧内核的shell脚本

随着ubuntu的更新,特别是其内核的更新,系统中就 会存留很多版本的内核,要知道每个都很大,不但浪费硬盘空间,而且在启动的时候,grub的选项里会出现很多个内核,很是不好,所以就需要删除旧版本的已 经不用的内核。一下的shell脚本就可以帮你轻松搞定问题,这个脚本是转载学长。

#!/bin/sh
#Program:
# Let user uninstall unused kernels which installed as debian package form.
#Author:
# mtyy110
if [ "`whoami`" != 'root' ]; then
echo 'Requires superuser privilege.'
exit 1
fi
dpkg --get-selections | grep 'linux-' | grep -v 'deinstall' | grep "\-[0-9]\.[0-9]\{1,2\}\.[0-9]\{1,2\}\-"
while [ 1 ]
do
total=`dpkg --get-selections | grep 'linux-' | grep -v 'deinstall' | grep "\-[0-9]\.[0-9]\{1,2\}\.[0-9]\{1,2\}\-" | wc -l`
read -p "Which version would you like to uninstall?(0 to quit)" version
if [ $version = "0" ]; then
break
fi
tmp=`echo $version | grep "^[0-9]\.[0-9]\{1,2\}\.[0-9]\{1,2\}\-\{0,1\}[0-9]\{0,2\}$" | wc -l`
if [ $tmp -eq 0 ]; then
echo "Not an available version format,please input full version."
continue
fi
sum=`dpkg --get-selections | grep 'linux-' | grep -v 'deinstall' | grep "\-[0-9]\.[0-9]\{1,2\}\.[0-9]\{1,2\}\-" | grep "$version" | wc -l`
if [ $sum -eq 0 ]; then
echo "Not find version $version.Ignored."
continue
fi
tmp=`uname -r | grep "$version" | wc -l`
if [ $tmp -eq 1 ]; then
read -p "This will uninstall the kernel current used:`uname -r`.Are you sure?(y/N)" choice
if [ "$choice" != 'y' -a "$choice" != 'Y' ]; then
continue
fi
fi
if [ $total -le $sum ]; then
read -p "This will uninstall all the kernels in the system.Are you sure?(y/N)" choice
if [ "$choice" -o 'y' -a "$choice" -o 'Y' ]; then
continue
fi
fi
apt-get remove `dpkg --get-selections | grep 'linux-' | grep -v 'deinstall' | grep "\-$version" | cut -f 1`
read -p "Continue to uninstall other kernel?(Y/n)" choice
if [ "$choice" = 'n' -o "$choice" = 'N' ]; then
break
fi
dpkg --get-selections | grep 'linux-' | grep -v 'deinstall' | grep "\-[0-9]\.[0-9]\{1,2\}\.[0-9]\{1,2\}\-"
done
exit 0

2008年8月18日星期一

wine字体调整方法

1、从c:\windows\fonts\里拷贝一个simsun.ttc到~/.wine/drive_c/windows/fonts/

2、修改/加入 ~/.wine/system.reg
[System\\CurrentControlSet\\Hardware Profiles\\Current\\Software\\Fonts]
"LogPixels"=dword:00000070

这里是改变dialog window buttom的字体大小


3.修改/加入 ~/.wine/windows的dir/win.ini
[Desktop]
menufontsize=13
messagefontsize=13
statusfontsize=13
IconTitleSize=13

这边是改变其他字体的大小

另外:
修改~/.wine/system.reg

[Software\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes] 1144897563

"MS Shell Dlg"="SimSun"
"MS Shell Dlg 2"="SimSun"

可以解决某些按钮字体的问题

在某些系统中,以上方法都不能解决字体默认为simsun,最后发现,系统最先使用simfang.ttf,所以可以这样做:
ln -s SimSun.ttc simfang.ttc
因为simfang.ttc在simfang.ttf前,所以使用了simsun字体

wine Ms Office 2003

1. 将richedit20.dll和richedit32.dll还有msxml3.dll三个文件在winecfg里面设为native(windows).

2.上网下载以上三个文件的安装包:

http://media.codeweavers.com/pub/crossover/office/support/richedit30.exe

http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=28494391-052b-42ff-9674-f752bdca9582

3.执行安装

richedit30.exe
msiexec /i msxml3.msi

4.运行Office的Setup.exe

建议安装选择查看细节,把“输入法”那块给取消掉,要不然会安装微软拼音,退出OFFICE后不会退出输入法,得手动结束ctfmon.exe进程。

经我试验最新版的wine可以不用做每二步与第三步……