ubuntu重启x server

最近ubuntu老出问题,动不动界面就不响应鼠标了,不知怎么回事,所以需要重启x,查了下这个 发现很有意思,一个fadora论坛,2004年有人问个问题,2008年被人给翻出来回答了下。 我试了一下,这个是可以的 ctrl + alt + f1 切换到终端,然后执行 sudo kill $(cat /tmp/.X0-lock) 以下是原文 ...

November 9, 2009 · notsobad

sh or bash

我需要对一些字体文件做些处理,字体名里面有些特殊字符,如空格,写了下面的脚本, 然后调用 “sh fonts.sh“, 却总是出问题,研究了好久,才发现是sh和bash的区别,这段代码用bash调用就没问题 #chmod +x fonts.sh #./fonts.sh #bash ./fonts.sh sh 和bash的区别 543 ~/www/fonts>cat fonts.sh #! /bin/bash IFS=$(echo -en “\n\b”) for i in $(find . -name \*.[Tt][Tt][Ff]); do echo “$i” done unset IFS ...

August 26, 2009 · notsobad

sed 获取html中链接

sed的tutorials http://sed.sourceforge.net/grabbag/scripts/ http://sed.sourceforge.net/grabbag/tutorials/ 一个获取html中链接的sed脚本 #! /bin/sed -nf # Join lines if we have tags that span multiple lines :join /<[^>]$/ { N; s/[ ]\n[ ]/ /; b join; } # Do some selection to speed the thing up /<[ ]\([aA]|[iI][mM][gG]\)/!b # Remove extra spaces before/after the tag name, change img/area to a s/<[ ]\([aA]|[iI][mM][gG]|[aA][rR][eE][aA]\)[ ]\+/<a /g # To simplify the regexps that follow, change href/alt to lowercase # and replace whitespace before them with a single space s/<a\([^>]\)[ ][hH][rR][eE][fF]=/<a\1 href=/g s/<a\([^>]*\)[ ][aA][lL][tT]=/<a\1 alt=/g # To simplify the regexps that follow, quote the arguments to href and alt s/href=\([^" ...

August 5, 2009 · notsobad

用gnome-web-photo进行网页截屏

参考下这里: http://ubuntuforums.org/showthread.php?t=1085872 还有这里: [http://groups.google.com/group/python- cn/browse_thread/thread/f25350d5e4d415af/08140024364b819d?lnk=gst&q;=html#](http://groups.google.com/group/python- cn/browse_thread/thread/f25350d5e4d415af/08140024364b819d?lnk=gst&q=html#) 使用gnome-web-photo进行网页截屏,效果相当好,不过保存为jpg格式失败了 514 ~/script/sh>gnome-web-photo --format "png" http://blog.notsobad.cn blog.png Registering '@mozilla.org/module-loader/python;1' (libpyloader.so) Registering '@mozilla.org/network/protocol/about;1?what=python' (pyabout.py) 515 ~/script/sh>animate blog.png 516 ~/script/sh>gnome-web-photo --mode=photo --format "jpeg" http://blog.notsobad.cn blog.jpg Registering '@mozilla.org/module-loader/python;1' (libpyloader.so) Registering '@mozilla.org/network/protocol/about;1?what=python' (pyabout.py) JPEG parameter struct mismatch: library thinks size is 372, caller expects 356

August 3, 2009 · notsobad

sh, bash, dash

ubuntu下的sh是到dash(the Debian Almquist Shell)的链接 原因参考这里 https://wiki.ubuntu.com/DashAsBinSh 502 ~>ls /bin/bash -l -rwxr-xr-x 1 root root 729040 2009-03-02 22:22 /bin/bash 503 ~>ls /bin/sh -l lrwxrwxrwx 1 root root 4 2008-11-05 02:05 /bin/sh -> dash 504 ~>ls /bin/dash -l -rwxr-xr-x 1 root root 87924 2008-11-05 15:51 /bin/dash 505 ~>echo $SHELL /bin/bash 以前以为sh就是到/bin/bash的链接,昨天就遇到了问题 The Debian policy manual has long mandated that “shell scripts specifying ‘/bin/sh’ as interpreter must only use POSIX features”; in fact, this requirement has been in place since well before the inception of the Ubuntu project. Furthermore, any shell scripts that expected to be portable to other Unix systems, such as the BSDs or Solaris, already honoured this requirement. Thus, we felt that the compatibility impact of this change would be minimal. ...

July 29, 2009 · notsobad

ubuntu 9.04源

ubuntu 9.04上交的源, 我这里速度很快, 北京网通的 deb http://ftp.sjtu.edu.cn/ubuntu/ jaunty main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu/ jaunty-backports main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu/ jaunty-proposed main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu/ jaunty- security main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu/ jaunty-updates main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ jaunty main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ jaunty-backports main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ jaunty-proposed main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ jaunty-security main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ jaunty-updates main multiverse restricted universe

June 12, 2009 · notsobad

ubuntu 9.04 的新notify的python示例

ubuntu的通知机制 参考: https://wiki.ubuntu.com/NotifyOSD https://wiki.ubuntu.com/NotificationDevelopmentGuidelines 下面是一个简单的python脚本,利用这个新的notify。 效果: https://wiki.ubuntu.com/NotificationDevelopmentGuidelines?action=AttachFile&do=get&target=icon-summary-body.png #!/usr/bin/python import sys import time import pynotify if __name__ == '__main__': if not pynotify.init ("update-notifications"): sys.exit (1) # try the icon-summary-body case n = pynotify.Notification ( "Inital notification", "This is the original content of this notification-bubble.", "notification-message-IM") n.show () time.sleep (3); # simulate app activity # update the current notification with new content n.update ("Updated notification", "Here the same bubble with new title- and body-text, even the icon can be changed on the update.", "notification-message-email") n.show (); time.sleep (6); # wait longer now # create a new bubble using the icon-summary-body layout n = pynotify.Notification ( "Initial layout", "This bubble uses the icon-title-body layout.", "notification-message-IM"); n.show () time.sleep (3); # simulate app activity # now update current bubble again, but change the layout n.update ("Updated layout", "After the update we now have a bubble using the title-body layout.") n.show ()

May 17, 2009 · notsobad

dns cache

ubuntu8.10, 网通宽带,无线路由 速度非常慢,可以感觉到4-5秒的延时,明显是dns查询的时间。 装了dnsmasq,然后修改resolv.conf 23:39:13@/etc/ppp> cat /etc/resolv.conf # Generated by NetworkManager nameserver 127.0.0.1 不过网络重新连接后还是会被网通的dns覆盖掉, 如下即可 之后重启网络,速度飞快

April 30, 2009 · notsobad