存档

作者存档

快捷键——杀人于无形

2011年3月25日 zhubaining 没有评论

Ubuntu

  • Ctrl+Alt+T:呼出Terminal
  • Ctrl+Alt+L:锁屏
  • WIN+Tab: 很酷地切换窗口
  • Alt+F2:呼出“Run Application”窗口,类似Windows里面的“Run”窗口
  • Alt+鼠标单击:在窗口的任何地方都可以抓住并拖动窗口

Linux Terminal——谁用谁知道!

  • Ctrl+L:终端重绘
  • Ctrl+U:删除到行首
  • Ctrl+W: 删除左边的单词
  • Ctrl+Y:将buffer里面的内容粘贴到命令行
    • 举例:
      • $ command opt1 opt2 opt3  (写完命令又不想立马执行,就可以先按下Ctrl+U)
      • (做其他事情)
      • 再按下Ctrl+Y就可以把上面这个命令粘贴
  • Ctrl+A、Ctrl+E:到行首、行末
  • Ctrl+F、Ctrl+B:前进/后退一个字符
  • Ctrl+左箭头、Ctrl+右箭头: 前进/后退一个单词
  • ALT+. 、ESC+. 、!$:引用上个命令的最后一个参数
    • 举例:
      • $ ls /etc/abc.conf
      • $ cat (ALT+.)
  • !!:引用上一个命令(整条命令)
    • 举例:$ sudo !!
  • !*:引用上一个命令的所有参数
    • 举例:
      • $ /path/to/command /etc/a  /tmp/b
      • $ rm !*   (=rm /etc/a  /tmp/b)
  • !:N:引用上一个命令的第N个参数
    • 举例:
      • $ ls asdb /etc/asfdasfd
      • $ rm !:1  (=rm asdb)

Firefox

  • 地址补全:
    • 在地址栏,输入domain后:
      • 按下Ctrl+Enter:进行http://www.domain.com补全
      • 按下Shift+Enter:进行http://www.domain.net补全
      • 按下Ctrl+Shift+Enter:进行http://www.domain.org补全
    • 这个补全特性可以在这里修改。

Windows

  • WIN+L: 锁屏幕

Microsoft Word

  • Alt+X: 选中字符后,可以查看编码,再次按下即可还原
  • Ctrl+Enter: 插入分页符
  • Ctrl+B: 设置为粗体
  • Ctrl+I: 设置为斜体
  • Ctrl+U: 加下划线
  • Ctrl+Alt+鼠标选中:块选中
http://
分类: linux 标签: , , ,

firefox: 别整天解析域名了

2011年3月18日 zhubaining 1 条评论

用Firefox上网时,发现经常卡在解析域名的阶段,有时候刚刚访问过的网站,再次访问又要解析域名,真是无法忍受。

于是,使用常规武器:STFW,发现可以尝试修改Firefox的配置,让它将dns缓存一下。

发现效果并不理想,于是尝试安装dnsmasq。要让本机的dns请求先到这个dnsmasq,就需要修改/etc/resolv.conf:

zhubaining@zhubaining-laptop:~$ cat /etc/resolv.conf
nameserver 127.0.0.1
nameserver x.x.x.x

插入“nameserver 127.0.0.1”这一行。

不过悲剧是,一般住所或者公司都用的是DHCP,而DHCP会修改这个文件,导致你插入的这一行丢失。 很多地方都说修改/etc/dhcp3/dhclient.conf,增加prepend那一行:

#supersede domain-name “fugue.com home.vix.com”;
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;

但现实是残酷的,发现这招并不奏效。
于是乎,自己很土地写了下面这个很土的脚本,在crontab里面每分钟执行一次:

#!/bin/bash
grep 127.0.0.1 /etc/resolv.conf
if [ $? = 1 ]; then
echo ‘nameserver 127.0.0.1′ >tmp.conf
cat /etc/resolv.conf >> tmp.conf
cp tmp.conf /etc/resolv.conf
fi

执行这么频繁的原因是,我的网络在公司里容易断掉,比如去一次会议时,漫游一把就断了,虽然很悲惨,但这个已经是我努力后的结果了。

故事并没有结束。在访问网络红人磊磊的博客时,发现卡在dns请求那里更久,wireshark抓包后发现:

原来是不停地查询IPV6地址。

好吧,先把这个IPV6地址的查询给禁掉吧: 在about:config里面,将network.dns.disableipv6设置为true.

OK,世界终于快起来了。

分类: linux 标签: , , , ,

从百度空间搬家到WordPress

2011年3月17日 zhubaining 没有评论

试着将百度空间的博客文章搬到这里,google了几把,发现了一个工具:

http://www.yhustc.com/exp/other/BlogMover.zip

按照用法,解压、执行其中的一个脚本,发现出错:

python hi-baidu-mover.py -s http://hi.baidu.com/百度账号

就试着改成:

python hi-baidu-mover.py -s http://hi.baidu.com/百度账号/blog

结果ok了。

脚本执行过程中,屏幕不停地报错:

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe9 in position 117: ordinal not in range(128)
Traceback (most recent call last):
File “/usr/lib/python2.6/logging/__init__.py”, line 768, in emit
msg = self.format(record)
File “/usr/lib/python2.6/logging/__init__.py”, line 648, in format
return fmt.format(record)
File “/usr/lib/python2.6/logging/__init__.py”, line 436, in format
record.message = record.getMessage()
File “/usr/lib/python2.6/logging/__init__.py”, line 306, in getMessage
msg = msg % self.args
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe9 in position 117: ordinal not in range(128)

暂不理睬,一会儿功夫,文章抓完了,生成了一个XML文件:

-rw-r–r–  1 zhubaining zhubaining 292403 2011-03-15 00:50 hibaidu_03152011-0050.xml

于是就往WordPress里面导入:

先要安装一个用于导入的插件:WordPress Importer,激活后,在管理后台Tools=> Import里面选择WordPress,然后上传那个xml文件。

不幸的是,报错了:

Sorry, there has been an error.
This does not appear to be a WXR file, missing/invalid WXR version number

看来是抱怨文件缺少wxr版本号,vim打开xml文件后,确实没发现,怎么办?

WordPress不是可以导出xml文件么,那就马上导出一个标准版本。经过对两个xml文件的比对,确实发现少了一行,于是加上蓝色的那一行:

<language>en</language>
<wp:wxr_version>1.0</wp:wxr_version>
<wp:category><wp:cat_name><![CDATA[Jishu]]></wp:cat_name></wp:category>

再次上传,这下OK了。

导入了不少文章,发现有几篇是乱码,直接查看那个xml文件,里面确实也是。一开始以为是由于百度空间博客里面的分类是汉字导致,都改成英文的分类名,重试一次还是乱码。算了,那几篇就人肉复制粘贴过来吧。

还有一个比较倒霉的问题,就是原来文章里面那些图由于防盗链,在这里没法正常显示了。下来准备写个脚本把这些图片从百度空间抓下来,转存一下,然后再把文中的图片链接修改一下。

更新:

解决办法:

  1. 将数据库dump以收集要修改图片URL,同时也是一个事前备份
  2. 进入wordpress的uploads目录:$ cd /var/www/zhubaining/wp-content/uploads/2011/03/
  3. 抓取百度空间的图片:for i in `grep -E ‘http://hiphotos.baidu.com/zhubaining/pic/item/[0-9a-z]{24}\.jpg’ db.sql -o`; do wget $i; done;
  4. 将文章里面的url替换掉:mysql> update wp_posts set post_content=replace(post_content, ‘http://hiphotos.baidu.com/zhubaining/pic/item/’,'http://zhubaining.com/wp-content/uploads/2011/03/’);

顺带发现:抓取了一个图片,尝试打开看看是否正确,没想到图片查看器报错“Error interpreting JPEG image file (Not a JPEG file: starts with 0×89 0×50)”,file了一把,提示是“PNG image”,改名成png就ok了。
原来,虽然百度空间的图片都是以jpg结尾的,但实际上并不都是jpg,比如png、bmp等什么的都有,貌似是按照你上传格式直接保存(可能还判断了图片的大小,太大的话应该会压缩的)。

Intel AGN 5100网卡在Ubuntu下频繁断网的解决办法

2011年2月22日 zhubaining 2 条评论

环境:

  • Ubuntu版本:Ubuntu 10.04
  • 网卡:Intel Corporation PRO/Wireless 5100 AGN [Shiloh]

现象:

在公司,无线网络过几分钟就断掉,然后Network Manager会自动重连,而且可以从tray icon看到wifi信号强度在不停地变动。重启动到Windows下,网络完全正常。在住处的tp-link网络中,也是正常的。

dmesg里面有这样的信息:

[  418.852590] wlan0: deauthenticating from 00:1d:70:98:55:90 by local choice (r
eason=3)
[  418.855585] wlan0: deauthenticating from 00:1d:70:98:55:90 by local choice (r
eason=3)
[  418.856969] wlan0: direct probe to AP 00:26:99:b9:75:10 (try 1)
[  418.913234] wlan0: direct probe responded
[  418.913239] wlan0: authenticate with AP 00:26:99:b9:75:10 (try 1)
[  418.919710] wlan0: authenticated
[  418.919731] wlan0: associate with AP 00:26:99:b9:75:10 (try 1)
[  418.925702] wlan0: RX AssocResp from 00:26:99:b9:75:10 (capab=0×431 status=0
aid=38)
[  418.925705] wlan0: associated

看起来像是断掉之后,又连接到另外一个AP。

解决过程:

尝试一公司的网络有问题?

致电公司的IT服务热线,汇报情况,人家说先记录,然后转给相关部门进行处理。当然,一般都是没有然后。

尝试二:n模式?

搜索了一下,有人说是不能使用n模式,按照所示方法,修改配置文件,重启了机器,发现不奏效。

尝试三:更新驱动程序?

继续搜索,又有人说可能是网卡驱动程序的问题,就尝试更新一下,但是通过搜索发现intel的官方linux无线站点http://www.intellinuxwireless.org上说:

Note: The iwlwifi driver has been merged into mainline kernel since 2.6.24. If you are using kernels after this release, please use the intree (drivers/net/wireless/iwlwifi) driver directly.

自己看一下版本:

$ uname -a
Linux zhubaining-laptop 2.6.32-28-generic #55-Ubuntu SMP Mon Jan 10 21:21:01 UTC 2011 i686 GNU/Linux

但是我不甘心,还是下载了最新的驱动,发现跟/lib/firmware/iwlwifi-5000-2.ucode一模一样。

尝试四:更换Network Manager!

继续搜索,有人说是Ubuntu自带的Network Manager有问题,建议使用wicd,立刻apt-get install wicd装上。

接着,在Network Manager把连接断掉,再用wicd进行连接,发现总是停在获取ip地址那里。继续搜索,有人说要把Network Manager卸载掉,于是乎sudo apt-get remove network-manager,这下用wicd终于连接上了。

真相:

这是一个bug里面也有人提到,用wicd来暂时绕过这个问题。

结论:

这个故事告诉我们,一定要有解决问题的耐心和自信心,坚持不懈地搜啊搜啊搜啊,一定会成功。

想想我在做了前两个尝试失败之后,就只能忍受:不停地在网络断了之后,运行自己写的一个脚本,执行公司的网络准入程序、建立ssh翻山通道以及别的几件事。本来还准备写个稍微智能一些的脚本,实现在网络断掉后自动执行脚本。甚至一度想再装一个Win7,将工作平台转移到Windows上…

分类: linux 标签:

IT工人高效工作指南

2011年1月27日 zhubaining 4 条评论

(本文以具体的软件和工具为例叙述,不过基本原理和方法是通用的,敬请举一反三。)

邮件规则

分类存放:设定最基本的分类放置规则是最基本的一条,就是把特定的邮件放到特定的文件夹里面,这样看起来很清楚。

重点提醒:很多人每天都要收到很多邮件,如果你要接收一些系统自动发送的监控邮件,那么一天成千上万封都很正常。这时候,就要对收到的邮件分一下轻重缓急:一般来说,一封邮件当中,如果你出现在“接收人”和“抄送”里的话,那么这封邮件就是要优先查看的。一个方法就是,通过设定邮件规则,使得这种邮件到来时,让outlook弹出一个“新邮件通知”的对话框,方便你及时处理。

会话显示:outlook邮件所有的目录都可以将邮件按照会话的形式层级地显示出来,这样就可以直观地看到对一个话题的来回讨论。但是,当你是话题的发起者,并且你没有显式地把你写到邮件接收者里面,并且邮件接收者里面没有包含你的一个邮件组的话,你只能看到你收到的邮件被会话展示,因为发起讨论的这封邮件只是放到了“已发送邮件”里面。解决方案还是利用邮件规则,在“发送邮件后”,将邮件复制一份到收件箱的一个目录:

搜索邮件

即使用了邮件规则对邮件进行了分类,即使outlook本身就有搜索邮件的功能,当邮件多了还是无济于事,因为成千上万的邮件分散在不同的目录,人工找或者用这个搜索都很麻烦。这时,你需要功能强大的桌面搜索工具,谷歌、百度和微软等大佬们都提供了免费的工具。如果要对Outlook邮件进行搜索的话,推荐使用微软的Windows Search,毕竟你要搜索微软自己的东西嘛。我之前用过谷歌的桌面搜索,可能存在和Outlook兼容的问题,崩溃了好几次。

当然,这个桌面搜索不局限于搜索邮件,它还可以搜索你的硬盘上的各种文档。试想一下,即使你现在只知道要找的内容其中一两个关键字,就可以很快地从成千上万个邮件或者文档当中把它拎出来,那是多么爽的一件事。

日历与提醒

事情很多的时候,如果不做好日程管理和提醒,那么肯定会出现遗漏。现在,假如你按照下面这样做了,那么基本上就不会有问题了:

  1. 会议邀请:不要在直接用IM或者邮件通知会议,而是使用Outlook的“会议邀请”功能,这样,当你发送出去后,别人的日历里面自动添加了这个日程,outlook在会议开始前所有人会有弹窗提醒。他好,你也好。此外,你还可以知道多少人确定要出席会议,当会议的时间地点出现变更,你还可以方便的更新。还有一个很有意思的功能,就是可以用Outlook发起一个简单的投票。
  2. 手机提醒:光有outlook日历提醒还是不够的,这是因为:有时候你不在电脑跟前;另外,你可能还有个人事务需要提醒,不想也设置到outlook日历里面去,将工作和私事混在一起。现在以谷歌日历和Nokia手机为例,提出一个综合解决方案:平时你还是在Outlook里面添加各种工作日程,但是对于私事,你要将他们添加到谷歌日历。接着,在电脑上安装Google Calendar Sync,将Outlook里面的工作相关日程同步到你的谷歌日历里面,然后在手机上安装Mail for Exchange,将谷歌日历里面的事务同步到你的手机上。这样你的所有事务都会在手机里面管理,还可以设置在事务到达前让手机振铃提醒。(Google Calendar Sync只支持32位的Outlook 2003, 2007, 2010,拉风的64位同学可以尝试一下gSyncit)

我的切身经历是,如果你不做好提醒,不管怎么样,都会忘事,所以我在慢慢地养成习惯:如果现在得知一个接下来要做的事情,不管是半天以后,还是几天以后,我都会先添加到日历里面再说。对于那些周期性的事务,比如亲朋好友的生日、交各种费用等,更是如此。爱ta,就把ta存到谷歌日历当中。

* 想起一个天才同事的IM签名写着:“早起的唯一靠谱的方案就是早睡”,类比到这里就是,”不忘事唯一的办法就是做好提醒“

个人知识的积累

不管是遇到的一个问题的解决方法,还是要收藏一个网址,或者临时的一个想法,我现在都会把它存储到网络上。一方面不会丢,方便找出来接着编辑,另外一方面,可以搜索。

总之原则是:决不将数据存储到本地。

具体可以参照我的百度空间旧文:积累自己的个人知识库

OpenSSH也支持clone功能

2010年12月22日 zhubaining 没有评论

使用SecureCRT的同学应该对它的“session克隆”功能不会陌生吧,尤其是你们采用了类似RSA SecureID之类的动态密码,你就会更加喜欢这个功能了。

可惜SecureCRT没有Ubuntu版本,所以一段时间内我就只能忍受:每次重新打开一个tab就拿出动态密码的token,再对照输入一下,这个确实太痛苦了。

还是本着“技术要为人类服务”的思想,昨天搜索了一把,果然有解决方案。其实OpenSSH已经支持了重用同一个连接的功能,具体操作方法如下:

修改~/.ssh/config(如果没有则新建一个),追加以下的内容:

Host *
ControlMaster auto
ControlPath /tmp/%r@%h:%p

现在输入密码ssh登录一下你的host,然后再ssh一下,这次是不是不用输入密码了。
参考:
http://www.revsys.com/writings/quicktips/ssh-faster-connections.html

分类: linux 标签:

logo也要升级!

2010年11月21日 zhubaining 没有评论

一个品牌logo的要素中,有一点首当其冲,那就是必须容易辨识,但事实告诉我们,并非所有的企业或者logo设计者都能意识到这一点。

之前就发现几个知名企业的logo并不符合这样的基本要求,后来发现他们都升级了,比如比亚迪:

比亚迪的新logo同时带来了新的slogan:Build Your Dreams,很巧妙的把BYD的含义平滑地升华。

国产品牌吉利的车标也不符合要求:

这个和比亚迪的logo一样,就是显得很简陋,logo中都包含字母,但是都很难看清。大家可能会说,上面这个图看起来效果还不错啊,但大家明天上街实际观察一下,就会发现它这个logo很难辨识。

不出所料,若干天前偶尔就看到吉利360万全球征集新车标,而且目前似乎已经找到了新车标。

前一阵刚登陆纳斯达克的搜房网可谓风头正劲,不过我觉得它的logo也需要升级:

构图和配色都不够精致,丝毫不能彰显品牌形象,显得有点儿粗制滥造,尤其是字体,感觉好像是直接选择了系统自带的字体,然而,一般来说,没有一个知名品牌logo的字体不是精心自制的。

所以,我几乎可以断定它将来要升级logo,有人要跟我打赌么?

搜房网老总如有同感,我想您一定会毫不犹豫地赠送几万股股票作为感谢,对吧?

分类: IT之外 标签:

同步你的微博

2010年11月20日 zhubaining 4 条评论

想把twitter上说的话自动同步到其他微博账号,比如新浪微博、腾讯微博、百度说吧等?谢天谢地,有好心人已经做了个不错的同步脚本。

在这里下载脚本:http://www.54chen.com/tw2other-54chen-0916.tar.gz

具体使用方法参考:http://www.54chen.com/web-ral/twitter.html

在config.php里面设置目标微博账户信息,比如:


$services = array ("sina" => array ('username' => 'zhubaining', 'password' => 'secret' ),

"baidu" => array ('username' => 'zhubaining', 'password' => 'secret' ),

值得一提的是,可以通过修改配置,过滤掉retweet和reply之类,因为这些消息对于非twitter好友们没有意义,因为没有上下文:

打开config.php,修改$twitterSyncLevel变量:


/**
 * 0:不过滤
 * 1:过滤回复别人的tweet
 * 2:过滤RT别人的推
 * 3:只同步自己的tweet,推中不包含RT,@字样
 *
 */
$twitterSyncLevel = 3;

其原理是如下的正则表达式:

switch ($this->syncLevel) {
 //过滤回复别人的tweet
 case 1 :
 return '/^@.*/m';
 break;

 //过滤RT别人的推
 case 2 :
 return '/^RT\s@.*/m';
 break;

 //只同步自己的tweet,推中不包含RT,@字样
 case 3 :
 return '/RT\s|@/';
 break;

 default :
 return NULL;
 break;
 }

设为3的话确实有点儿暴力,因为包含RT和@的都不会被同步,尤其是@太常见了,这个问题可以暂时用全角@来回避。

设置完了,就可以按照步骤,执行php index.php同步了。聪明的你一定想到了把它放进crontab里面定时执行,很好。
试了几次,发现一个严重的囧问题:每次执行,都会把之前的老tweet重复发了一遍,以至于百度说吧里面都被我刷屏了,有群众都抱怨了。
于是研究了一下那个脚本,发现它是通过在“statuses/user_timeline.json?start_id=N”里面指定N来实现“不重复同步”的目的,那么,它必然要把上次的id保存下来,果然,发现这个文件:


$ cat  tweet.id

5.63894430991E+15

登陆twitter网站,查看俺的最后一条tweet的id是5638944309907456,于是猜到了问题所在:id太大!联想到我的是32bit环境,对,超过了int的范围。

root@yudi:~# uname -a
Linux yudi 2.6.18.8-linode22 #1 SMP Tue Nov 10 16:12:12 UTC 2009 i686 GNU/Linux

在仔细看看脚本,发现使用了twitter返回的json结构中的””id”:5638944309907456“,然后json_decode,于是乎,就出现了浮点数。
怎么办呢?第一反应就是在decode前,把这个元素变成字符串型,这样就不”失真“了,正准备实现hack手段时,一不小心发现了json里面还有个””id_str”:”5638944309907456″“,太好了,就直接用它吧。
修改代码:

$ diff Twitter.php Twitter_new.php

120c120

<         if (! isset ( $json [0] ['id'] )) {

---

>         if (! isset ( $json [0] ['id_str'] )) {

124c124

<         $this->writeTweetId ( $json [0] ['id'] );

---

>         $this->writeTweetId ( $json [0] ['id_str'] );

重新运行了几遍脚本,这下终于和谐了。

用高科技制造同步脚本,用脚本骚扰更多的人!现在就行动吧!

趣闻:

  1. 在调试的过程中,为了防止再次扰民,还特意申请了一个百度说吧的马甲来做实验。
  2. 在给新浪微博和百度说吧一次同步数条信息的时候,发现新浪微博系统处理请求数度稍逊,同步了,但是半天还没显示出来。

更新:

  • 刚才又看到twitter的返回json里面包含如下的字段,看来可以用更高明的方法了:
["retweeted"]=>
 bool(false)
 ["in_reply_to_user_id"]=>
 NULL
  • 发现用一些工具如echofon发的“retweet with comment”,其实不是retweet,也就是说retweeted=false.
分类: linux, web技术 标签:

[fw]About Virutal Memory

2010年9月26日 zhubaining 没有评论

What is virtual memory, how is it implemented, and why do operating systems use it?

Real, or physical, memory exists on RAM chips inside the computer. Virtual memory, as its name suggests, doesn’t physically exist on a memory chip. It is an optimization technique and is implemented by the operating system in order to give an application program the impression that it has more memory than actually exists. Virtual memory is implemented by various operating systems such as Windows, Mac OS X, and Linux.

So how does virtual memory work? Let’s say that an operating system needs 120 MB of memory in order to hold all the running programs, but there’s currently only 50 MB of available physical memory stored on the RAM chips. The operating system will then set up 120 MB of virtual memory, and will use a program called the virtual memory manager (VMM) to manage that 120 MB. The VMM will create a file on the hard disk that is 70 MB (120 – 50) in size to account for the extra memory that’s needed. The O.S. will now proceed to address memory as if there were actually 120 MB of real memory stored on the RAM, even though there’s really only 50 MB. So, to the O.S., it now appears as if the full 120 MB actually exists. It is the responsibility of the VMM to deal with the fact that there is only 50 MB of real memory.

Now, how does the VMM function? As mentioned before, the VMM creates a file on the hard disk that holds the extra memory that is needed by the O.S., which in our case is 70 MB in size. This file is called a paging file (also known as a swap file), and plays an important role in virtual memory. The paging file combined with the RAM accounts for all of the memory. Whenever the O.S. needs a ‘block’ of memory that’s not in the real (RAM) memory, the VMM takes a block from the real memory that hasn’t been used recently, writes it to the paging file, and then reads the block of memory that the O.S. needs from the paging file. The VMM then takes the block of memory from the paging file, and moves it into the real memory – in place of the old block. This process is called swapping (also known as paging), and the blocks of memory that are swapped are called pages. The group of pages that currently exist in RAM, and that are dedicated to a specific process, is known as the working set for that process.

As mentioned earlier, virtual memory allows us to make an application program think that it has more memory than actually exists. There are two reasons why one would want this: the first is to allow the use of programs that are too big to physically fit in memory. The other reason is to allow for multitasking – multiple programs running at once. Before virtual memory existed, a word processor, e-mail program, and browser couldn’t be run at the same time unless there was enough memory to hold all three programs at once. This would mean that one would have to close one program in order to run the other, but now with virtual memory, multitasking is possible even when there is not enough memory to hold all executing programs at once.

However, virtual memory can slow down performance. If the size of virtual memory is quite large in comparison to the real memory, then more swapping to and from the hard disk will occur as a result. Accessing the hard disk is far slower than using system memory. Using too many programs at once in a system with an insufficient amount of RAM results in constant disk swapping – also called thrashing, which can really slow down a system’s performance.

Summary:

  1. the purpose of virtual memory is to “enlarge” the physical memory.
  2. Thanks to virtual memory, you can either run a program which requires more memory than you physically deployed, or run several programs simultaneously even if the total memory requirements cannot be physically meeted.
  3. virtual memory tech is implemented by a so-called paging file that residents in the disk.
分类: 计算机基础 标签:

unix目录权限的含义

2010年9月20日 zhubaining 没有评论

unix基础知识,温故知新。

WHO WHAT THE PERMISSIONS ALLOW
USER Read (r) The account owner can list the files in the directory.
Write (w) The account owner can create or delete files in the directory.
Execute (x) access files in that directory by name (such as Web page files).
GROUP Read (r) Everyone in the designated group can list the files in the directory.
Write (w) Everyone in the group can create or delete files in the directory.
Execute (x) Everyone in the group can change (cd) into the directory and access files in that directory by name (such as Web page files).
OTHER Read (r) Anyone can list the files in the directory.
Write (w) Anyone can create or delete files in the directory.
Execute (x) Anyone can change (cd) into the directory and access files in that directory by name (such as Web page files).

去掉r权限,则无法列目录,但是可以cd或者通过名称访问文件:

[someone@eb tmp]$ ll -l
total 8
drwxrwx-wx 2 root root 4096 Sep 20 14:31 someone
drwxrwxrwt 3 someone someone 4096 Mar 10 2009 uscreens
[someone@eb tmp]$ ll someone
ls: someone: Permission denied
[someone@eb tmp]$ cd someone
[someone@eb someone]$ ls
ls: .: Permission denied
[someone@eb someone]$ cat a.txt
[someone@eb someone]$ cd ..
[someone@eb tmp]$ cat someone/a.txt
[someone@eb tmp]$

去掉x权限,我们发现无法cd:

[root@eb tmp]# ll
total 8
drwxr–r-x 2 root root 4096 Sep 20 14:31 someone
drwxrwxrwt 3 someone someone 4096 Mar 10 2009 uscreens

[root@eb tmp]# chmod o-x someone
[root@eb tmp]# ll
total 8
drwxr–r– 2 root root 4096 Sep 20 14:31 someone
drwxrwxrwt 3 someone someone 4096 Mar 10 2009 uscreens
[root@eb tmp]# su someone
[someone@eb tmp]$ cd someone

bash: cd: someone: Permission denied

ll没有问题,但是cat里面的问题就出错了:

[someone@eb tmp]$ ll someone
total 0
?——— ? ? ? ? ? a.txt

[someone@eb tmp]$ cat someone/a.txt
cat: someone/a.txt: Permission denied

分类: linux 标签: