Showing posts with label Utils. Show all posts
Showing posts with label Utils. Show all posts

2009-05-05

Output of the free command

$ free
. total used free shared buffers cached
Mem: 514816 344028 170788 0 37820 200120
-/+ buffers/cache: 106088 408728
Swap: 1502036 96468 1405568
Mem:表示物理内存统计
-/+ buffers/cached:表示物理内存的缓存统计
Swap:表示硬盘上交换分区的使用情况,这里我们不去关心。
系统的总物理内存:255268Kb(256M),但系统当前真正可用的内存b并不是第一行free 标记的 16936Kb,它仅代表未被分配的内存。

第1行 Mem
total:表示物理内存总量。
used:表示总计分配给缓存(包含buffers 与cache )使用的数量,但其中可能部分缓存并未实际使用。
free:未被分配的内存。
shared:共享内存,一般系统不会用到,这里也不讨论。
buffers:系统分配但未被使用的buffers 数量。
cached:系统分配但未被使用的cache 数量。buffer 与cache 的区别见后面。
total = used + free

第2行 -/+ buffers/cached
used:也就是第一行中的used - buffers-cached 也是实际使用的内存总量。
free:未被使用的buffers 与cache 和未被分配的内存之和,这就是系统当前实际可用内存。
free 2= buffers1 + cached1 + free1 //free2为第二行、buffers1等为第一行

buffer 与cache 的区别:
A buffer is something that has yet to be "written" to disk.
A cache is something that has been "read" from the disk and stored for later use 第3行: 第三行所指的是从应用程序角度来看,对于应用程序来说,buffers/cached 是等于可用的,因为buffer/cached是为了提高文件读取的性能,当应用程序需在用到内存的时候,buffer/cached会很快地被回收。所以从应用程序的角度来说,可用内存=系统free memory+buffers+cached.

接下来解释什么时候内存会被交换,以及按什么方交换。
当可用内存少于额定值的时候,就会开会进行交换.
如何看额定值(RHEL4.0):
#cat /proc/meminfo
交换将通过三个途径来减少系统中使用的物理页面的个数: 
1. 减少缓冲与页面cache的大小,
2. 将系统V类型的内存页面交换出去, 
3. 换出或者丢弃页面。(Application 占用的内存页,也就是物理内存不足)。
事实上,少量地使用swap是不是影响到系统性能的。

下面是buffers与cached的区别。
buffers是指用来给块设备做的缓冲大小,他只记录文件系统的metadata以及 tracking in-flight pages.
cached是用来给文件做缓冲。
那就是说:buffers是用来存储,目录里面有什么内容,权限等等。
而cached直接用来记忆我们打开的文件,如果你想知道他是不是真的生效,你可以试一下,先后执行两次命令#man X ,你就可以明显的感觉到第二次的开打的速度快很多。
实验:在一台没有什么应用的机器上做会看得比较明显。记得实验只能做一次,如果想多做请换一个文件名。
#free
#man X
#free
#man X
#free
你可以先后比较一下free后显示buffers的大小。
另一个实验:
#free
#ls /dev
#free
你比较一下两个的大小,当然这个buffers随时都在增加,但你有ls过的话,增加的速度会变得快,这个就是buffers/chached的区别。
因为Linux将你暂时不使用的内存作为文件和数据缓存,以提高系统性能,当你需要这些内存时,系统会自动释放(不像windows那样,即使你有很多空闲内存,他也要访问一下磁盘中 的pagefiles)
使用free命令
将used的值减去 buffer和cache的值就是你当前真实内存使用
-------------- 操作系统来讲是Mem的参数.buffers/cached 都是属于被使用,所以它认为free只有16936.
应用程序来讲是(-/+ buffers/cach).buffers/cached 是等同可用的,因为buffer/cached是为
了提高 程序执行的性能,当程序使用内存时,buffer/cached会很快地被使用。 所以,以应用来看看,以(-/+ buffers/cache)的free和used为主.所以我们看这个就好了.另外告诉大家 一些常识.Linux为了提高磁盘和内存存取效率, Linux做了很多精心的设计, 除了对dentry进行缓存(用于 VFS,加速文件路径名到inode的转换), 还采取了两种主要Cache方式:Buffer Cache和Page Cache。 前者针对磁盘块的读写,后者 针对文件inode的读写。这些Cache能有效缩短了 I/O系统调用(比如read,write,getdents)的时间。 记住内存是拿来用 的,不是拿来看的.不象windows,无论你的真实物理内存有多少,他都要拿硬盘交换 文件来读.这也就是windows为什么常常提示虚拟空间不足的原因.你们想想,多无聊,在内存还有大部分 的时候,拿出一部分硬盘空间来充当内存.硬盘怎么会快过内存.所以我们看linux,只要不用swap的交换 空间,就不用担心自己的内存太少.如果常常swap用很多,可能你就要考虑加物理内存了.这也是linux看 内存是否够用的标准哦.

2009-04-17

ssh -t hostname vim /your/file

ssh -t

Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g., when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

2009-04-07

Valgrind for PowerPC on Debian

$ valgrind ./invalid_free
valgrind: Fatal error at startup: a function redirection
valgrind: which is mandatory for this platform-tool combination
valgrind: cannot be set up. Details of the redirection are:
valgrind:
valgrind: A must-be-redirected function
valgrind: whose name matches the pattern: strlen
valgrind: in an object with soname matching: ld.so.1
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld.so.1
valgrind:
valgrind: Possible fix: install glibc's debuginfo package on this machine.
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
$ aptitude install libc-dbg

2009-02-14

SSH Escape Char

man ssh and search Escape Char

2009-01-15

Jabber.no out of service?

周一开始 gtalk 不能登录 msn 了, 这几天也不行, 难道 jabber.no 报废了?

2009-01-14

Mac version of Picasa is only for Intel-based machines?

很兴奋 google 终于推出了 mac 版的 picasa, 刚下载了一个, 结果不能运行, 上网一查原来只支持 intel 版的 mac, 可怜俺的 ibook g4, 伤心 :(

2008-12-15

Thunderbird Add-on

  • Buttons!
  • Google Contacts
  • MinimizeToTray
  • Send Later
  • Message Filter Import/Export

2008-10-14

Less' history file

偶然发现看 man page 的时候 search 过的字符串是有 history 的, 猜想是 less 的功能, 查了一下根目录下的文件, 发现有一个 .lesshst, 查 less 的 manual, 里面有说到 .lesshst:

. . . Name of the history file used to remember search commands and shell commands between invocations of less. . .

2008-10-13

Compile GNU screen from source

  • $ git clone git://git.savannah.gnu.org/screen.git
  • $ cd screen/src
  • $ aclocal --force
  • $ libtoolize --copy --force
  • $ autoconf --force
  • $ autoheader --force
  • $ automake --add-missing --copy --force-missing
  • $ ./configure --prefix=/usr/local/screen-dev --enable-colors256
  • $ make && make install
N.B.: Run mktar.pl to make traditional screen-X.X.X.tar.gz

See full screen man pages on Fedora Core 3

ubuntu 6.06 上看 man pages 的时候能全屏显示, 但 Fedora 3 上却不能, 研究一番, 可以自己编译 man-db 来解决:

编译 man-db 可能需要依赖 gdbm-devel 或者 db4-devel (ubuntu 上对应 libgdbm-dev 或者 libdb-dev).

2008-07-31

Hotspot Shield

Public networks (both wired and wireless) are great. After all, what would life be without connecting while at airports, hotels and coffee shops? However, the danger to your personal data exists even if you connect to a fee based open network. Your passwords, credit card numbers, and any data you send can be seen and associated with you personally. Standard antivirus software won't protect you as this threat is on the network, not your laptop or iPhone.

That's why AnchorFree is pleased to offer Hotspot Shield. Our application keeps your Internet connection secure and anonymous on public networks.

2008-06-28

256 color terminals

  • PuTTY 0.60: Settings > Window > Colours > Allow terminal to use xterm-256color mode
  • Ubuntu 6.06: apt-get install ncurses-term
  • Set TERM=xterm-256color
  • Compile screen: configure --enable-colors256
  • Edit .screenrc:
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"
  • Start screen: screen -T xterm-256color
References: 256 color emacs + putty, 256 color xterm (including some 256 color schemes for vim)

Red Hat Liberation Fonts - Free

在 WinXP 上, Liberation Mono (and Bold) 10 号字体跟 Windows 的 Fixedsys 大小相当.

2008-06-27

Webmin

Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely. See the standard modules page for a list of all the functions built into Webmin, or check out the screenshots.

2008-06-06

Quick Reference Cards

Quick Reference Cards - http://www.digilife.be/

2008-06-05

Hex Editors

  • apt-cache search -n hex
  • apt-get install hexedit
  • apt-get install hexer
  • apt-get install hexcurse
  • apt-get install ncurses-hexedit
--
hex edit editor

2008-05-17

Ubuntu 8.04

前天收到了从 Netherland 寄来的 Ubuntu 8.04 的 CD, 里面已经 officially 包含了 Wubi 安装程序, 在 Windows XP 上安装了一下, 很顺畅, 没遇到什么麻烦, 只是在安装过程中有个进度条竟然到了 128%, 应该是个小 bug. 启动之后使用正常, 只发现一点儿小问题: 音量控制不起作用.

2008-05-09

PuttyCyg

PuttyCyg - code.google.com

--
putty cygwin