日志分类:Linux

Unix /Linux 下字符大小写转换

2008-08-11,Monday | 分类:Linux, Sun & Solaris | 90 views

SAM那里学来一个trick,记录一下

方法一:

$ cat target_file.txt|dd conv=ucase  #小写转大写

$ cat target_file.txt|dd conv=lcase  #大写转小写

方法二:

#tr [:lower:] [:upper:] < target_file.txt #小写转大写

Opera 9.5正式发布

2008-06-12,Thursday | 分类:Linux, 互联网, 工具 | 标签: | 174 views

访问http://www.opera.com,包含了一堆的新特性,正好FireFox 3在这个月就要推出了,都下载回来比较一下吧。事实经常证明:用两个浏览器是非常明智的,尤其是在你不知道哪个会Crash的情况下。

Debian 下新安装好的Opera,默认的中文字体常常让人失去活下去的勇气,下面是解决办法:

新建一个user.css内容如下
html,body,*{
font-family:”WenQuanYi Bitmap Song” !important;
}

重启opera,然后在opera的工具栏里选择View(查看)里的Style(样式)选择刚才的user.css即可.

选择工具栏的Tools(工具)选择Preferences(属性)点Advanced(高级),选择左边的Fonts(字体)把Browser那几个改为WenQuanYi Bitmap Song.

xfonts-wqy字体这么装:sudo aptitude install xfonts-wqy

感谢EEPXE的提醒,Ubuntu中文论坛里的OPERA中文字体解决办法:http://forum.ubuntu.org.cn/viewtopic.php?t=70843

nmap扫描器在电影中的身影

2008-05-22,Thursday | 分类:Linux, 互联网, 工具 | 标签: | 97 views

今天看到了这个页面,列举了nmap扫描器在好莱坞电影中的应用,好事的影迷把这些一闪而过的电影片断捕捉下来,细细琢磨。(我也有这个毛病)

其中在Matrix reloaded 中Trinity攻陷电站,并将城市的供电终止则具有完整的入侵流程现实在屏幕上,如下图:

1.jpg

2.jpg

Wikipedia 上有此次入侵的完整介绍:

In a scene about two-thirds of the way through the film The Matrix Reloaded (approx 1h47m17s), the character Trinity hacks into a power station’s computer network. To do so, she first runs the network utility nmap against a computer on the network. Nmap reports that port 22, the standard port for SSH remote logins, is open. Trinity then runs the fictional program sshnuke which, according to her terminal, attempts to exploit the CRC-32 bug in the SSH version 1 server software. CRC-32 is a real bug in SSH version 1 that allows hackers to gain access to a computer using a buffer overflow attack.

Trinity’s attack using sshnuke is successful, and she gains root access to the system. Trinity enters the password “Z1ON0101″. (Note the substitution of the number “1″ for the letter “I”, a transliteration common in leetspeak and efforts to strengthen passwords against a dictionary attack.)

eee pc 上安装Debian testing

2008-04-06,Sunday | 分类:Linux, 个人 | 标签: | 97 views

eeepc近来的使用率不高,但考虑到过段时间要离开成都,可能会用到,遂把原来的系统格了,安装了Debian testing。重装后的系统手感甚佳,下面就记录一些有用的信息。

<打造适合eeepc的debian gnu/linux系统 > 这篇文章把Debian的安装分析的比较透彻,属于比较优质的DIY了,不过不太适合我,毕竟eee pc的使用率不高,没必要弄的过于复杂。

<eeeuser论坛上Gekko的方法 >主要参考的就是这篇文章,安装过程比较顺利。

1, 准备U盘,空间需求不大,大于20M就可以了。如果你有SD卡那就更好了。
下载Gekko修改后的img文件:
http://bbqsrc.net/eeepc/debian/sid-usb.img.gz ,完成后:
1) gunzip /path/to/sid-usb.img.gz
2) root用户: dd if=/path/to/sid-usb.img of=/dev/sdX, sdX应为整个U盘的路径,如sda,而不是sda1之类的。也就是说整个U盘的数据都覆盖了,如果你不希望这样的话,最好做好备份。

2, eeepc插上U盘,启动的时候按tab,从U盘启动。安装过程与网络安装debian的方式无异。此过程能自动识别有线和无线网卡,如果无线方式,essid的识别会有问题,最好在安装中选择手工输入essid,而不是自动搜索。

3, 安装的时候无需配置swap分区,这是为了ssd硬盘的寿命着想。因为扩了内存到1G,所以也对性能没有影响。使用ext3或者ext2文件系统都可以,/分区的mount option可以选择 noatime 。最后在选择安装软件包的时候,仅选择basic的包,这样安装的过程能快些,等启动了系统后再安装xfce4 ,这个小巧的桌面系统比较适合eee pc。

4, 安装好系统后,sources.list文件已经被设定OK了,不过是lenny的源(testing)。建议加入etch的源,因为gqview这个看图软件,lenny里面没有。所以下一步就可以进行后期处理了。
/etc/apt/source.list如下:

#———————————————–
# deb http://debian.cn99.com/debian/ lenny main
deb http://debian.cn99.com/debian/ lenny main non-free contrib
deb-src http://debian.cn99.com/debian/ lenny main non-free contrib
deb http://debian.cn99.com/debian/ etch main non-free contrib
deb-src http://debian.cn99.com/debian/ etch main non-free contrib
## eeepc repository
deb http://eeepc.debian.net/debian lenny main contrib non-free
deb http://security.debian.org/ lenny/updates main contrib non-free
deb-src http://security.debian.org/ lenny/updates main contrib non-free
#———————————————–

aptitude安装必要的软件:xfce4 vim-gnome kopete xpdf kpdf kchmviewer xchm qterm lftp openssh-server curl tor privoxy python2.5 mplayer gqview fcitx (这些都是我常用的)个别软件安装过程可以看这里。 独立安装firefox 和openoffice,我是直接从其他电脑的Debian系统上拷贝过来的。中文字体可以安装VeraSansYuanTi ttf-wqy-zenhei xfonts-wqy。最近找到一个好的英文字体,在vim和term中使用比较好看:raizer font。下载和安装参考下面的链接:
http://www.raize.com/DevTools/Tools/RzFont.asp

5, 安装madwifi,否则无线网卡无法正常工作。不清楚为何安装过程中能检查到无线,而安装后就不行了。
参考下面的链接:http://madwifi.org/wiki/UserDocs/Distro/Debian/MadWifi

我做这步的时候不是很顺利,dmesg提示:

wifi%d: unable to attach hardware: ‘Hardware revision not supported’ (HAL status 13)

后来这样解决的:
# apt-get install madwifi-eeepc-source
# apt-get install madwifi-tools
# m-a prepare
# m-a a-i madwifi
也就是使用madwifi-eeepc-source而不是madwifi-source

6,安装后的系统无法正常关机 ,关机后,系统电源灯和wifi灯都是亮的。解决办法如下:
1) (root) aptitude install acpi-suppport
2) 编辑 /etc/default/acpi-support 文件 编辑MODULES为 MODULES=”snd_hda_intel ”

7, 此时的系统已经基本可用了,我就不想折腾了。xfce4的确很省系统资源,开FireFox看网页,openoffice编辑文档,也就耗费到600M的内存就最高了。这个小机器处理能力有限,其实没必要这么虐待它,够用就好。摄像头目前因为一个bug的原因尚不可用,就没急着弄了, 有兴趣的看这里的配置过程。

安装ntp软件:
#aptitude install ntpdate
#ntpdate pool.ntp.org

8, 上张截屏:

eeepc debian system

9, 启动速度没有原有的系统快,不过已经足够了,15s就可以到xfce4了。对了,别忘了切掉exim4这个阑尾。

DiaryVGC.py加入了windows支持

2008-03-27,Thursday | 分类:Linux, python, 工具 | 标签: | 70 views

上传到Google Code上去了,这样保存的也许能长久一些。

DiaryVGC == Diary Vim Google Calendar

http://code.google.com/p/diaryvgc/downloads/list

下一步就看看怎么增加修改同步功能了。

VIM Calendar 插件 与 Google Calendar同步diary的脚本

2008-03-26,Wednesday | 分类:Linux, python, 工具 | 标签: | 130 views

不辞职不知道柴米贵,不编程不知道码字累

最近学习python,写了个脚本作为练习。

脚本用途:VIM Calendar 插件生成的Diary同步到Google Calendar

编写动机:一直以来我都用Google Calendar记录每日流水帐,记录每一天都做了什么。以前工作的时候,这个习惯非常好,尤其是在定期给客户写维护报告的时候。一些细节的琐碎事情都能借助Google Calendar的搜索功能准确定位时间。缺陷就是要联网的时候才能写,否则就要临时编辑个文件,时间久了,想要从这些乱七八糟的本地文件里面找到有用的信息真是痛苦。最近使用了VIM Calendar插件,发现可以写diary,记录流水帐再好不过。缺点就是检索和查看都比较困难,于是就萌生了同步diary到Google Calendar的想法。

运行平台:已经支持Linux/windows

脚本原理:
VIM Calendar插件会在用户目录下的diary目录中按照日期的目录结构生成日记文本,如:/home/money/diary/2008/3/21.cal,每一个文件代表一天的日记。脚本会扫描/home/money/diary目录下的文件,并生成/home/money/diary/vimlog.txt文件作为记录,随后依次上传每个文件的内容到Google Calendar。当然事先要有一个Google Calendar的帐号提供给脚本。为了不与Google Calendar默认的日历冲突(Primary),脚本会在自动创建一个Title为”VIM”的子日历,随后所有的操作都是在此子日历上起作用,比方说上传diary和删除diary。
上传diary的过程中使用的Google Gdata的python API。

脚本运行:
./diaryvgc.py - -user=username - -pw=password - -dir=/home/money/diary [-d] -h –help
–user 指定Google Calendar Account的用户名,不必加后面的@gmail.com后缀
–password 指定Google Calendar Account用户的密码,没必要加引号
–dir 指定diary存放的目录,因为就这一个参数,脚本就没有使用配置文件了。并且配置文件存放Google Account的密码也并不安全。
-d 这个是可选参数,如果不使用,则同步diary到Google Calendar。如果指定了-d 则将 Google Calendar的VIM子日历中条目全部删除。
-h 或 –help 打印usage

上传diary:
./diaryvgc.py –user=username –pw=password –dir=/home/money/diary
删除Google Calendar中 VIM子Calendar中的所有条目:
./diaryvgc.py –user=username –pw=password –dir=C:\diary -d

说明:
1.支持增量同步。第一次运行时将所有diary同步到Google Calendar,随后只检查新增的diary。这个功能依靠文件vimlog.txt中的记录实现。
2.需要Google Gdata Pytho API支持。现已经把脚本所需的package一起放到程序里面了。只要在Linux下有python(应该都有吧),就没问题了。
3.diary以’All Day’的形式加入到Google Calendar中。避免了Google Calendar自动分析diary,造成上传日记内容不完整的情况。
4.因未加入同步控制,所以启动后会将diary全部upload到Google Calendar。如果你的diary很多的话,要耐心,因为它的速度依赖于网络。

后期计划:
1, 增加windows平台支持(已经支持)
2, 增加Diary修改的检测,修改后的diary可以同步到Google Calendar。
3, 增加同步控制

脚本下载:

http://code.google.com/p/diaryvgc/downloads/list

相关资源:
VIM Calendar 插件下载: http://www.vim.org/scripts/script.php?script_id=52
Google Gdata API : http://code.google.com/apis/gdata/

Pages: 1 2 3 4 5 Next