这个blog是方便自己收集备份网上好的技术文档,方便查看之用,无原创文章!转载请注意参考原始文章版权声明!

2009年3月6日星期五

# [debian] 见识linux的强大的兼容性 见识linux的强大的兼容性

刚手机没电关机了,习惯直接插在电脑上充,不小心发现文件浏览器里一下多了3个可移动卷 24.0Mb 486.4Mb 6.5Mb 手机的隐藏分区也可以看见 windows连linux分区都无法识别(要装别的软件,非原生态)

# [读书笔记] Debian Debian Packages

弄deb
Debian packages are produced by the dpkg package management utility. Like RPM, dpkg follows a
series of instructions that are given to it via a single text file. In Debian, this file is known as a control file
(the parallel with RPM being the SPEC file), and it contains much the same kind of information as that
you have already seen in the previous RPM example. There’s a control file included in the example
Debian package, which you will learn how to build in this section.
Creating a single Debian package can be fairly straightforward, thanks to the automated Debian helper
scripts. In this case, dh_make can be used from the command line in order to create a new package,
given an existing source code project to work with. For example, you can copy the existing hello-
1.0.tar.gz into a new directory and use it as the basis for a brand-new Debian package.
Copy the hello-1.0.tar.gz code into a working directory and unpack it:
$ tar xvfz hello-1.0.tar.gz
Inside the newly extracted directory, you’ll find the familiar example source code. To create a Debian
package, you can call the dh_make script from within this directory:
$ dh_make -e jcm@jonmasters.org -f ../hello-1.0.tar.gz
Although there are many option flags available for dh_make (see the man page for a lengthy descrip-
tion), you need only two to get started. In the above command, -e informs dh_make that the email
address of the package author is jcm@jonmasters.org, while the -f option specifies the location of the
original unmodified sources for the current source tree.
When you run dh_make, you will be asked what type of package you would like to create:
Type of package: single binary, multiple binary, library, kernel module or cdbs?
[s/m/l/k/b]
Since you are creating a single binary package, you want the s option (the others are more complex and
documented elsewhere). Here is the output from a typical invocation of dh_make:
$ dh_make -e jcm@jonmasters.org -f ../hello-1.0.tar.gz
Type of package: single binary, multiple binary, library, kernel module or cdbs?
[s/m/l/k/b] s
Maintainer name : Jon Masters
Email-Address : jcm@jonmasters.org
Date : Mon, 01 Jan 2007 14:54:00 +0000
Package Name : hello
Version : 1.0
License : blank
Type of Package : Single
Hit to confirm:
Done. Please edit the files in the debian/ subdirectory now. You should also
check that the hello Makefiles install into $DESTDIR and not in / .

[读书笔记] does one thing and does it well [读书笔记] does one thing and does it well

喜欢linux就是由于它的自由。
有很多人说 windows 不是很好用么?((删去数字)经过深入思考,我觉得还是刚开始就接触linux好吧,否则,人的思维惰性很难对付)不知道自由是什么的人是不会想到去追求自由的。(莫谈国事)
有点体会到Unix的哲学了。
最重要的 简单即是美!

[源码] v7中 echo.c

http://www.google.com/codesearch
http://minnie.tuhs.org/UnixTree/V7/usr/
#include
main(argc, argv)
int argc;
char *argv[];
{
register int i, nflg;
nflg = 0;
if(argc > 1 && argv[1][0] == '-' && argv[1][1] == 'n') {
nflg++;
argc--;
argv++;
}
for(i=1; i
fputs(argv[i], stdout);
if (i < argc-1)
putchar(' ');
}
if(nflg == 0)
putchar('\n');
exit(0);
}

# [读书笔记] Where to Get Unix and GNU Source Code

昨天还在想去看一些gnu小软件如wget的源代码呢,今天就下下来了,动作还蛮及时的
You may wish to have copies of the programs we use in this book for your own experimentation and review. All
the source code is available over the Internet, and your GNU/Linux distribution contains the source code for the
GNU utilities.
Unix Code
Archives of various "ancient" versions of Unix are maintained by The UNIX Heritage Society (TUHS),
http://www.tuhs.org.
Of most interest is that it is possible to browse the archive of old Unix source code on the Web. Start with
http://minnie.tuhs.org/UnixTree/. All the example code in this book is from the Seventh Edition
Research UNIX System, also known as "V7."
The TUHS site is physically located in Australia, although there are mirrors of the archive around the world—see
http://www.tuhs.org/archive_sites.html. This page also indicates that the archive is available for
mirroring with rsync. (See http://rsync.samba.org/ if you don't have rsync: It's standard on GNU/Linux
systems.)
You will need about 2–3 gigabytes of disk to copy the entire archive. To copy the archive, create an empty
directory, and in it, run the following commands:
mkdir Applications 4BSD PDP-11 PDP-11/Trees VAX Other
rsync -avz minnie.tuhs.org::UA_Root .
rsync -avz minnie.tuhs.org::UA_Applications Applications
rsync -avz minnie.tuhs.org::UA_4BSD 4BSD
rsync -avz minnie.tuhs.org::UA_PDP11 PDP-11
rsync -avz minnie.tuhs.org::UA_PDP11_Trees PDP-11/Trees
rsync -avz minnie.tuhs.org::UA_VAX VAX
rsync -avz minnie.tuhs.org::UA_Other Other
You may wish to omit copying the TRees directory, which contains extractions of several versions of Unix, and
occupies around 700 megabytes of disk.
You may also wish to consult the TUHS mailing list to see if anyone near you can provide copies of the archive
on CD-ROM, to avoid transferring so much data over the Internet.
The folks at Southern Storm Software, Pty. Ltd., in Australia, have "modernized" a portion of the V7 user-level
code so that it can be compiled and run on current systems, most notably GNU/Linux. This code can be
downloaded from their web site.[7]
[7] http://www.southern-storm.com.au/v7upgrade.html
It's interesting to note that V7 code does not contain any copyright or permission notices in it. The authors wrote
the code primarily for themselves and their research, leaving the permission issues to AT&T's corporate licensing
department.

git资料汇总

github
githost

to be continued

(转载)在linux下设置开机自动启动程序的方法

http://hi.baidu.com/lovehmp/blog/item/cb76ec6ecf2eefde80cb4af6.html

2008年03月11日 星期二 上午 11:15下面用自启动apache为例;
自启动脚本:
/usr/local/apache2/bin;
./apachectl start
文件位于/etc/rc.d/init.d下,名为apached, 注意要可执行.
#chmod +x /etc/rc.d/init.d/apached //设置文件的属性为可执行
#ln -s /etc/rc.d/init.d/apached /etc/rc3.d/S90apache //建立软连接,快捷方式
#ln -s /etc/rc.d/init.d/apached /etc/rc0.d/K20apache
在Red Hat Linux中自动运行程序
1.开机启动时自动运行程序
Linux 加载后, 它将初始化硬件和设备驱动,然后运行第一个进程init。init根据配置文件继续引导过程,启动其它进程。通常情况下,修改放置在 /etc/rc或 /etc/rc.d 或/etc/rc?.d 目录下的脚本文件,可以使init自动启动其它程序。例如:编辑 /etc/rc.d/rc.local文件,在文件最末加上一行"xinit"或"startx",可以在开机启动后直接进入X-Window。
2.登录时自动运行程序
用户登录时,bash首先自动执行系统管理员建立的全局登录script:/etc/profile。然后bash在用户起始目录下按顺序查找三个特殊文件中的一个:/.bash_profile、/.bash_login、/.profile,但只执行最先找到的一个。
因此,只需根据实际需要在上述文件中加入命令就可以实现用户登录时自动运行某些程序(类似于DOS下的Autoexec.bat)。
3.退出登录时自动运行程序
退出登录时,bash自动执行个人的退出登录脚本/.bash_logout。例如,在/.bash_logout中加入命令"tar -cvzf c.source.tgz *.c",则在每次退出登录时自动执行 "tar" 命令备份 *.c 文件。
4.定期自动运行程序
Linux有一个称为crond的守护程序,主要功能是周期性地检查 /var/spool/cron目录下的一组命令文件的内容,并在设定的时间执行这些文件中的命令。用户可以通过crontab 命令来建立、修改、删除这些命令文件。
例如,建立文件crondFile,内容为"00 9 23 Jan * HappyBirthday",运行"crontab cronFile"命令后,每当元月23日上午9:00系统自动执行"HappyBirthday"的程序("*"表示不管当天是星期几)。
5.定时自动运行程序一次
定时执行命令at 与crond 类似(但它只执行一次):命令在给定的时间执行,但不自动重复。at命令的一般格式为:at [ -f file ] time ,在指定的时间执行file文件中所给出的所有命令。也可直接从键盘输入命令:
$ at 12:00
at>mailto Roger -s ″Have a lunch″ < plan.txt
at>Ctr-D
Job 1 at 2000-11-09 12:00
2000-11-09 12:00时候自动发一标题为"Have a lunch",内容为plan.txt文件内容的邮件给Roger。
­
#!/bin/bash
RESTART="........" #里面写相应服务代码
START="......."
STOP=".........."
case "$1" in
restart)
$RESTART
echo "......"
;;
start)
$START
echo "......"
;;
STOP)
$STOP
echo "......"
;;
*)
echo "Usage: $0 {restart ** start ** stop}"
exit 1
esac
exit 1
脚本写完要修改一下权限 chmod u+x test.sh
­
首先,linux随机启动的服务程序都在/etc/init.d这个文件夹里,里面的文件全部都是脚本文件(脚本程序简单的说就是把要运行的程序写到一个文件里让系统能够按顺序执行,类似windows下的autorun.dat文件),另外在/etc这个文件夹里还有诸如名为rc1.d,rc2.d一直到 rc6.d的文件夹,这些都是linux不同的runlevel,我们一般进入的Xwindows多用户的运行级别是第5级,也就是rc5.d,在这个文件夹下的脚本文件就是运行第5级时要随机启动的服务程序。需要注意的是,在每个rc(1-6).d文件夹下的文件其实都是/etc/init.d文件夹下的文件的一个软连接(类似windows中的快捷方式),也就是说,在/etc/init.d文件夹下是全部的服务程序,而每个rc(1-6).d只链接它自己启动需要的相应的服务程序!
要启动scim(某一程序),我们首先要知道scim程序在哪里,用locate命令可以找到,scim在 /usr/bin/scim这里,其中usr表示是属于用户的,bin在linux里表示可以执行的程序。这样,我就可以编写一个脚本程序,把它放到 /etc/init.d里,然后在 rc5.d里做一个相应的软链接就可以了。
这个脚本其实很简单,就两行:
#!/bin/bash
/usr/bin/scim
第一行是声明用什么终端运行这个脚本,第二行就是要运行的命令。
还需要注意的一点是,在rc5.d里,每个链接的名字都是以S或者K开头的,S开头的表示是系统启动是要随机启动的,K开头的是不随机启动的。这样,你就可以知道,如果我要哪个服务随机启动,就把它名字第一个字母K改成S就可以了,当然,把S改成K后,这个服务就不能随机启动了。因此,我这个链接还要起名为 SXXX,这样系统才能让它随机启动。