More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  孤叶飘零's Little HomePhotosProfileFriendsMore Tools Explore the Spaces community

孤叶飘零's Little Home

No list items have been added yet.
Updated 7/29/2008
Updated 7/15/2008
Updated 7/16/2008
Updated 4/25/2008
October 09

What kinds of testing should be considered?

  • Black box testing - not based on any knowledge of internal design or code. Tests are based on requirements and functionality.
  • White box testing - based on knowledge of the internal logic of an application's code. Tests are based on coverage of code statements, branches, paths, conditions.
  • unit testing - the most 'micro' scale of testing; to test particular functions or code modules. Typically done by the programmer and not by testers, as it requires detailed knowledge of the internal program design and code. Not always easily done unless the application has a well-designed architecture with tight code; may require developing test driver modules or test harnesses.
  • incremental integration testing - continuous testing of an application as new functionality is added; requires that various aspects of an application's functionality be independent enough to work separately before all parts of the program are completed, or that test drivers be developed as needed; done by programmers or by testers.
  • integration testing - testing of combined parts of an application to determine if they function together correctly. The 'parts' can be code modules, individual applications, client and server applications on a network, etc. This type of testing is especially relevant to client/server and distributed systems.
  • functional testing - black-box type testing geared to functional requirements of an application; this type of testing should be done by testers. This doesn't mean that the programmers shouldn't check that their code works before releasing it (which of course applies to any stage of testing.)
  • system testing - black-box type testing that is based on overall requirements specifications; covers all combined parts of a system.
  • end-to-end testing - similar to system testing; the 'macro' end of the test scale; involves testing of a complete application environment in a situation that mimics real-world use, such as interacting with a database, using network communications, or interacting with other hardware, applications, or systems if appropriate.
  • sanity testing or smoke testing - typically an initial testing effort to determine if a new software version is performing well enough to accept it for a major testing effort. For example, if the new software is crashing systems every 5 minutes, bogging down systems to a crawl, or corrupting databases, the software may not be in a 'sane' enough condition to warrant further testing in its current state.
  • regression testing - re-testing after fixes or modifications of the software or its environment. It can be difficult to determine how much re-testing is needed, especially near the end of the development cycle. Automated testing tools can be especially useful for this type of testing.
  • acceptance testing - final testing based on specifications of the end-user or customer, or based on use by end-users/customers over some limited period of time.
  • load testing - testing an application under heavy loads, such as testing of a web site under a range of loads to determine at what point the system's response time degrades or fails.
  • stress testing - term often used interchangeably with 'load' and 'performance' testing. Also used to describe such tests as system functional testing while under unusually heavy loads, heavy repetition of certain actions or inputs, input of large numerical values, large complex queries to a database system, etc.
  • performance testing - term often used interchangeably with 'stress' and 'load' testing. Ideally 'performance' testing (and any other 'type' of testing) is defined in requirements documentation or QA or Test Plans.
  • usability testing - testing for 'user-friendliness'. Clearly this is subjective, and will depend on the targeted end-user or customer. User interviews, surveys, video recording of user sessions, and other techniques can be used. Programmers and testers are usually not appropriate as usability testers.
  • install/uninstall testing - testing of full, partial, or upgrade install/uninstall processes.
  • recovery testing - testing how well a system recovers from crashes, hardware failures, or other catastrophic problems.
  • failover testing - typically used interchangeably with 'recovery testing'
  • security testing - testing how well the system protects against unauthorized internal or external access, willful damage, etc; may require sophisticated testing techniques.
  • compatability testing - testing how well software performs in a particular hardware/software/operating system/network/etc. environment.
  • exploratory testing - often taken to mean a creative, informal software test that is not based on formal test plans or test cases; testers may be learning the software as they test it.
  • ad-hoc testing - similar to exploratory testing, but often taken to mean that the testers have significant understanding of the software before testing it.
  • context-driven testing - testing driven by an understanding of the environment, culture, and intended use of software. For example, the testing approach for life-critical medical equipment software would be completely different than that for a low-cost computer game.
  • user acceptance testing - determining if software is satisfactory to an end-user or customer.
  • comparison testing - comparing software weaknesses and strengths to competing products.
  • alpha testing - testing of an application when development is nearing completion; minor design changes may still be made as a result of such testing. Typically done by end-users or others, not by programmers or testers.
  • beta testing - testing when development and testing are essentially completed and final bugs and problems need to be found before final release. Typically done by end-users or others, not by programmers or testers.
  • mutation testing - a method for determining if a set of test data or test cases is useful, by deliberately introducing various code changes ('bugs') and retesting with the original test data/cases to determine if the 'bugs' are detected. Proper implementation requires large computational resources.
September 10

实例解说Linux中fdisk分区使用方法

  一、fdisk 的介绍;

  fdisk - Partition table manipulator for Linux ,译成中文的意思是磁盘分区表操作工具;本人译的不太好,也没有看中文文档;其实就是分区工具;

  fdsik 能划分磁盘成为若干个区,同时也能为每个分区指定分区的文件系统,比如linux 、fat32、 linux 、linux swap 、fat16 以及其实类Unix类操作系统的文件系统等;当然我们用fdisk 对磁盘操作分区时,并不是一个终点,我们还要对分区进行格式化所需要的文件系统;这样一个分区才能使用;这和DOS中的fdisk 是类似的;

  二、合理规划您的硬盘分区;

  在操作分区之前,我们要明白硬盘分区一点理论,比如硬盘容量和分区大小的计算;对一个硬盘如何规划分区等,请参考如下文档,谢谢;

  《合理规划您的硬盘分区》

  三、fdisk -l 查看硬盘及分区信息;

  通过《合理规划您的硬盘分区》 ,我们知道主分区(包括扩展分区)的总个数不能超过四个;也不能把扩展分区包围在主分区之间;根据这个原则,我们划分硬盘分区就比较容易的多;也能为以后减少不必要的麻烦;

  1、通过fdisk -l 查看机器所挂硬盘个数及分区情况;

[root@localhost beinan]# fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 9729 55617030 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux
/dev/hda10 7752 9729 15888253+ 83 Linux
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux

  通过上面的信息,我们知道此机器中挂载两个硬盘(或移动硬盘),其中一个是hda 另一个是sda ;如果我们想查看单个硬盘情况,可以通过 fdisk -l /dev/hda1 或者fdisk -l /dev/sda1 来操作;以fdisk -l 输出的硬盘标识为准;

  其中 hda有三个主分区(包括扩展分区),分别是主分区 hda1 hda2 和hda3(扩展分区) ;逻辑分区是 hda5到hda10;

  其中 sda 有两个主分区(包括扩展分区),分别是 hda1 和hda2 (扩展分区);逻辑分区是 sda5 hda6 ;

  硬盘总容量=主分区(包括扩展分区)总容量

  扩展分区容量=逻辑分区总容量

  通过上面的例子,我们可以得知 hda=hda1+hda2+hda3,其中hda3=hda5+hda6+hda7+hda8+hda9+hda10 …… ……

  2、关于fdisk -l 一些数值的说明;

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  这个硬盘是80G的,有255个磁面;63个扇区;9729个磁柱;每个 cylinder(磁柱)的容量是 8225280 bytes=8225.280 K(约为)=8.225280M(约为);

分区序列 引导 开始 终止 容量 分区类型ID 分区类型
Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 9729 55617030 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux
/dev/hda10 7752 9729 15888253+ 83 Linux

  说明:

  硬盘分区的表示:在Linux 是通过hd*x 或 sd*x 表示的,其中 * 表示的是a、b、c …… …… x表示的数字 1、2、3 …… …… hd大多是IDE硬盘;sd大多是SCSI或移动存储

  引导(Boot):表示引导分区,在上面的例子中 hda1 是引导分区;

  Start (开始):表示的一个分区从X cylinder(磁柱)开始;

  End (结束):表示一个分区到 Y cylinder(磁柱)结束;

  id和System 表示的是一个意思,id看起来不太直观,我们要在fdisk 一个分区时,通过指定id来确认分区类型;比如 7表示的就NTFS 分区;这个在fdisk 中要通过t功能来指定。下面的部份会提到;

  Blocks(容量):这是我翻译的,其实不准确,表示的意思的确是容量的意思,其单位是K;一个分区容量的值是由下面的公式而来的;

  Blocks = (相应分区End数值 - 相应分区Start数值)x 单位cylinder(磁柱)的容量

  所以我们算一下 hda1的 Blocks 的大小 :

  hda1 Blocks=(765-1)x8225.280=6284113.92 K = 6284.113.92M

  注:换算单位以硬盘厂家提供的10进位算起,如果以操作系统二进制来算,这个分区容量应该更少一些,得出的这个值和我们通过 fdisk -l 看到的 /dev/hda1的值是大体相当的,因为换算方法不一样,所以也不可能尽可能的精确;再加上分区时的一点损失之类,有时或大或小是存在的;

  我们查看分区大小或者文件的时候,还是用十进制来计算比较直观;推算办法是 byte 向前推小数点三位就是K ,K单位的值向前推小数点三位就是M,M向前推小数点三位就是G…… …… 一般也差不了多少;这么算就行;

  3、估算一个存储设备是否被完全划分;

  我们估算一个硬盘是否完全被划分,我们只要看 fdisk -l 输出的内容中的 cylinders(柱体) 上一个分区的End 和下一个分区的Start是不是一个连续的数字,另外要看一下每个硬盘设备的fdisk -l 的开头部份,看一下他的 cylinders(柱体)的值;

  比如hda设备,我们看到的是 9729 cylinders ;我们通过 hda的分区表可以看到上一个分区的End的值+1 就是下一个分区的Start 的值;比如 hda2的Start的值是 hda1 的End 的值+1,这证明 hda1 和hda2 中间没有空白分区,是连续的,以此类推;在 hda10,我们看到 End 的值是9729 ,而在fdisk -l头部信息中也有9729 cylinders,证明这个硬盘已经完全划分;

Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux

  我们再看看 sda 移动储是不是被完全划分了;sda有 125个cylinders (柱体),有一个主分区和一个扩展分区构成;在扩展分区中,我们看到End的值为125,而这个移动硬盘的cylinder也是125,这能说明这个硬盘不可能再添加任何主分区了;根据我们上面所说的 sda1 sda2 sda5 sda6 之间未有任何未划分空间,但sda6 的cylinders (柱体)的End值却是 76 ,而 sda总的cylinders (柱体)有125个,由此看来sda 在 sda6后面有未划分区域;

  至于sda 有多少未划分空间,我们算一下就知道了;扩展分区总容量是 806400 K ,大约是 806.400M左右,而逻辑分区 sda5 和sda6 的大小加起来是 400M左右,所以还仍有400M左右未划分空间,并且只能划分为链逻辑分区;

  四、fdisk 对硬盘及分区的操作,进入fdisk 对硬盘操作阶段;

  我们可以对硬盘进行分区操作,前提是您把fdisk -l 弄明白了;通过fdisk -l ,我们能找出机器中所有硬盘个数及设备名称;比如上面的例子,我们会看到两个设备一个是/dev/hda ,另一个是/dev/sda ;

  fdisk 操作硬盘的命令格式如下:

  [root@localhost beinan]# fdisk 设备

  比如我们通过 fdisk -l 得知 /dev/hda 或者 /dev/sda设备;我们如果想再添加或者删除一些分区,可以用

  [root@localhost beinan]# fdisk /dev/hda

  或

  [root@localhost beinan]# fdisk /dev/sda

  注 在以后的例子中,我们要以 /dev/sda设备为例,来讲解如何用fdisk 来操作添加、删除分区等动作;

  1、fdisk 的说明;

  当我们通过 fdisk 设备,进入相应设备的操作时,会发现有如下的提示;以 fdisk /dev/sda 设备为例,以下同;

[root@localhost beinan]# fdisk /dev/sda
Command (m for help): 在这里按m ,就会输出帮助;
Command action
   a toggle a bootable flag
   b edit bsd disklabel
   c toggle the dos compatibility flag
   d delete a partition 注:这是删除一个分区的动作;
   l list known partition types 注:l是列出分区类型,以供我们设置相应分区的类型;
   m print this menu 注:m 是列出帮助信息;
   n add a new partition 注:添加一个分区;
   o create a new empty DOS partition table
   p print the partition table 注:p列出分区表;
   q quit without saving changes 注:不保存退出;
   s create a new empty Sun disklabel
   t change a partition's system id 注:t 改变分区类型;
   u change display/entry units
   v verify the partition table
   w write table to disk and exit 注:把分区表写入硬盘并退出;
   x extra functionality (experts only) 注:扩展应用,专家功能;

  其实我们常用的只有注有中文的,其它的功能我们不常用(呵,主要是我不会用,否则早会卖弄一下了);x扩展功能,也不是常用的;一般的情况下只要懂得 d l m p q t w 就行了;

  下面以实例操作来详述,没有例子没有办法就,新手也看不懂;

  2、列出当前操作硬盘的分区情况,用p;

Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux

  3、通过fdisk的d指令来删除一个分区;

Command (m for help): p 注:列出分区情况;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
Command (m for help): d 注:执行删除分区指定;
Partition number (1-6): 6 注:我想删除 sda6 ,就在这里输入 6 ;
Command (m for help): p 注:再查看一下硬盘分区情况,看是否删除了?
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help):

  警告:删除分区时要小心,请看好分区的序号,如果您删除了扩展分区,扩展分区之下的逻辑分区都会删除;所以操作时一定要小心;如果知道自己操作错了,请不要惊慌,用q不保存退出;切记切记!!!!在分区操作错了之时,千万不要输入w保存退出!!!

  4、通过fdisk的n指令增加一个分区;

Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
Command (m for help): n 注:增加一个分区;
Command action
   l logical (5 or over) 注:增加逻辑分区,分区编号要大于5;为什么要大于5,因为已经有sda5了;
   p primary partition (1-4) 注:增加一个主分区;编号从 1-4 ;但sda1 和sda2都被占用,所以只能从3开始;
p
Partition number (1-4): 3
No free sectors available 注:失败中,为什么失败?

  注:我试图增加一个主分区,看来是失败了,为什么失败?因为我们看到主分区+扩展分区把整个磁盘都用光了,看扩展分区的End的值,再看一下 p输出信息中有125 cylinders;最好还是看前面部份;那里有提到;

  所以我们只能增加逻辑分区了;

Command (m for help): n
Command action
   l logical (5 or over)
   p primary partition (1-4)
l 注:在这里输入l,就进入划分逻辑分区阶段了;
First cylinder (51-125, default 51): 注:这个就是分区的Start 值;这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;
Command (m for help):

  5、通过fdisk的t指令指定分区类型;

Command (m for help): t 注:通过t来指定分区类型;
Partition number (1-6): 6 注:要改变哪个分区类型呢?我指定了6,其实也就是sda6
Hex code (type L to list codes):L 注:在这里输入L,就可以查看分区类型的id了;
Hex code (type L to list codes): b 注:如果我想让这个分区是 W95 FAT32 类型的,通过L查看得知 b是表示的是,所以输入了b;
Changed system type of partition 6 to b (W95 FAT32) 注:系统信息,改变成功;是否是改变了,请用p查看;
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 75 201568+ b W95 FAT32

  6、fdisk 的退出,用q或者 w;

  其中 q是 不保存退出,w是保存退出;

  Command (m for help): w
  或
  Command (m for help): q

  7、一个添加分区的例子;

  本例中我们会添加两个200M的主分区,其它为扩展分区,在扩展分区中我们添加两个200M大小的逻辑分区;

Command (m for help): p 注:列出分区表;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
Command (m for help): n 注:添加分区;
Command action
   e extended
   p primary partition (1-4)
p 注:添加主分区;
Partition number (1-4): 1 注:添加主分区1;
First cylinder (1-125, default 1): 注:直接回车,主分区1的起始位置;默认为1,默认就好;
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-125, default 125): +200M 注:指定分区大小,用+200M来指定大小为200M
Command (m for help): n 注:添加新分区;
Command action
   e extended
   p primary partition (1-4)
p 注:添加主分区
Partition number (1-4): 2 注:添加主分区2;
First cylinder (26-125, default 26):
Using default value 26
Last cylinder or +size or +sizeM or +sizeK (26-125, default 125): +200M 注:指定分区大小,用+200M来指定大小为200M
Command (m for help): n
Command action
   e extended
   p primary partition (1-4)
e 注:添加扩展分区;
Partition number (1-4): 3 注:指定为3 ,因为主分区已经分了两个了,这个也算主分区,从3开始;
First cylinder (51-125, default 51): 注:直接回车;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): 注:直接回车,把其余的所有空间都给扩展分区;
Using default value 125
Command (m for help): p
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ 83 Linux
/dev/sda2 26 50 201600 83 Linux
/dev/sda3 51 125 604800 5 Extended
Command (m for help): n
Command action
   l logical (5 or over)
   p primary partition (1-4)
l 注:添加逻辑分区;
First cylinder (51-125, default 51):
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:添加一个大小为200M大小的分区;
Command (m for help): n
Command action
   l logical (5 or over)
   p primary partition (1-4)
l 注:添加一个逻辑分区;
First cylinder (76-125, default 76):
Using default value 76
Last cylinder or +size or +sizeM or +sizeK (76-125, default 125): +200M 注:添加一个大小为200M大小的分区;
Command (m for help): p 列出分区表;
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
   Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ 83 Linux
/dev/sda2 26 50 201600 83 Linux
/dev/sda3 51 125 604800 5 Extended
/dev/sda5 51 75 201568+ 83 Linux
/dev/sda6 76 100 201568+ 83 Linux

  然后我们根据前面所说通过t指令来改变分区类型;

  最后不要忘记w保存退出;

  五、对分区进行格式化,以及加载;

  先提示一下;用 mkfs.bfs mkfs.ext2 mkfs.jfs mkfs.msdos mkfs.vfatmkfs.cramfs mkfs.ext3 mkfs.minix mkfs.reiserfs mkfs.xfs 等命令来格式化分区,比如我想格式化 sda6为ext3文件系统,则输入;

  [root@localhost beinan]# mkfs.ext3 /dev/sda6

  如果我想加载 sda6到目前系统来存取文件,应该有mount 命令,但首先您得建一个挂载目录;比如 /mnt/sda6 ;

[root@localhost beinan]# mkdir /mnt/sda6
[root@localhost beinan]# mount /dev/sda6 /mnt/sda6
[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 8.4G 2.0G 81% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda10 16G 6.9G 8.3G 46% /mnt/hda10
/dev/sda6 191M 5.6M 176M 4% /mnt/sda6

  这样我们就能进入 /mnt/sda6目录,然后存取文件了

September 08

linux学习笔记(四)

#################################################################
使用sudo解决root密码问题
vi /etc/sudoers
jinshuai    ALL=NOPASSWD:ALL
添加监控
10 * * * * /usr/bin/rsync --timeout=30 -avz /etc/sudoers 202.108.37.132::monitor/202.108.35.184/ >/dev/null &

#################################################################
分区的inode满了

/var分区无法建立文件或目录,系统提示"No space left on device"。通过命令df -k检查空间,发现空间并没满。而且通过日志文件记录的不断增加也能确定空间还有剩余。这样问题也许出现在Inodes节点的使用上,通过命令df -i发现/var分区的Inodes节点果然全部使完。显然某个目录下有大量文件。仔细检查确定/var/spool/clientmqueue下有 115092个系统退信文件。删除后重起服务,一切正常。
使用这个命令删除这些文件
find /var/spool/clientmqueue/ -type f -exec rm {} \;

logwatch总是填满/tmp的解决办法:
vi /etc/log.d/conf/logwatch.conf
修改TmpDir = /tmp

#################################################################
linux下如何配置网络?

用netconfig
“IP address:”就是要配置的IP地址
“Netmask:”子网掩码
“Default gateway(IP):”网关
“Primary nameserver:”DNS服务器IP。
永久更改ip 
ifconfig eth0 新ip 
然后编辑/etc/sysconfig/network-scripts/ifcfg-eth0,修改ip

修改主机名 
vi /etc/sysconfig/network,修改HOSTNAME一行为HOSTNAME=主机名,重启后也能生效
在终端下输入hostname YourNewHostname,也能暂时生效;重起后失效。
(vi /etc/hostname)

手动添加默认网关 
linux
以root用户,执行:
route add default gw 网关的IP 
route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.1
route add -host 192.168.1.1 gw 192.168.0.1

查看路由
route get 192.168.1.1
netstat -r

route add default gw 192.168.1.8
route del default gw 192.168.1.1

想更改网关 
1 vi /etc/sysconfig/network-scripts/ifcfg-eth0 
更改GATEWAY 
2 /etc/init.d/network restart 
查看本机的IP,gateway,DNS
IP: 
以root用户登录,执行ifconfig。其中eth0是第一块网卡,lo是默认的设备 
Gateway: 
以root用户登录,执行netstat -rn,以0.0.0.0开头的一行的Gateway即为默认网关 
也可以查看/etc/sysconfig/network文件,里面有指定的地址! 
DNS: 
more /etc/reslov.conf,内容指定如下: 
nameserver 202.96.69.38 
nameserver 202.96.64.38 

查看与本机相连的每个ip的进程数量:
/bin/netstat -anp | awk '/ESTABLISHED/ { split($5,ip,":"); print ip[1]}' | uniq -c | sort -r | head -10
查看ip地址:
/sbin/ifconfig -a | /bin/awk '/inet / && !/127.0/ { split($2,ip_array,":"); printf ("%s",ip_array[2])} END {print}'

设置多播
/sbin/route add -net 224.0.0.0 netmask 240.0.0.0 dev eth3
查看网卡流量
watch -n1 ifconfig
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

查看端口和进程的对应关系
lsof -i

阻止ping
如果没人能ping通您的系统,安全性自然增加了。为此,可以在/etc/rc.d/rc.local文件中增加如下一行:
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

#################################################################
如何进linux单用户

LILO
在 LILO 引导提示(如果你使用的是图形化 LILO,你必须按 [Ctrl]-[x] 来退出图形化屏幕后再进入 boot: 提示)后键入:
linux single
回车就可以进单用户了

GRUB
在出现启动菜单的时候按e键
然后选中 kernel /boot/vmlinuz-2.4.21-32.ELsmp ro root=LABEL=/ 这一行
按e键然后在末尾输入single
按b键引导就进单用户了

/sbin/grub-install /dev/sda
安装grub引导

#################################################################
rsync问题汇总

1、程序产生的文件umask不生效
   修改 /etc/bashrc 中umask = 002
   我用php产生的程序属性是正常的,可以多测试看看

2、rsync属性问题
   rsync本身不支持umask设置,在传输的时候可以增加  --chmod=ug=rw  属性。
#################################################################
检查是否有不正常的进程引起的负载过高

1、登录后检查后台运行的进程
2、检查是否有/bin/mail进程,如果有执行如下命令:
   $> killall /bin/mail
   $> mv /bin/mail /bin/mail.bak
3、检查是否有update进程,如有执行如下命令:
   vi /etc/cron.daily/slocate.cron
   修改下面这一行,添加排除在外的目录:
   /usr/bin/updatedb -f "nfs,smbfs,ncpfs,proc,devpts" -e "/tmp,/var/tmp,/usr/tmp,/afs,/net"
   /usr/bin/updatedb -f "nfs,smbfs,ncpfs,proc,devpts" -e "/tmp,/var/tmp,/usr/tmp,/afs,/net,/usr/home,/data0"

#################################################################
NFS网络文件系统配置
一、安装文件
nfs-utils-verison.i386.rpm
portmap-version.i386.rpm
二、设置共享目录
/etc/exports文件用于配置共享目录
格式如下:
共享目录 客户端主机地址
/data1  10.48.1.100(sync,ro)
/data2  10.48.1.200(sync,rw)
sync: 设置NFS服务器同步写磁盘,这样不会轻易丢失数据,NFS服务器建议使用该选项
ro: 只读
rw: 可读写
三、启动NFS服务:
/etc/init.d/portmap start
/etc/init.d/nfs start
    开机自启动:
chkconfig --level 3 protmap on
chkconfig --level 3 nfs on
查看
chkconfig --list portmap
chkconfig --list nfs
四、显示NFS服务器的客户机与被挂载的目录
showmount -a
五、挂载NFS服务器上共享目录
mount 服务器ip:共享目录 /本地目录
mount | grep nfs
umount /本地目录
NFS安全设置
一、限定读写的权限(ro,rw)
二、限定客户端的来源IP
三、将重要资料档拥有者设为root
    如果不做任何设定的话,NFS client端的root是没什麽权限的,意即对远端的档案权限可能比一般使用者还低。换句话说NFS Server端的档案若是拥有者为root,将有较高的安全性
四、尽量保证两个系统拥有共享目录的id和uid都是相同

#################################################################
根据/var/log/cron恢复root的crontab
awk -F"(" '/root/ {print $3}' /var/log/cron | awk -F")" '{print $1}'| sort | uniq -c | sort -rn

#################################################################
交换分区swap操作
swapoff -a
swap -a /dev/sda5
tune2fs -j /dev/sdf1 将ext2文件系统转换为ext3文件系统

杀死正在使用的某个文件或者目录的所有进程
fuser -kiuv /somedir
-i ask before killing
-k kill processes accessing that file
-u display user ids
-v verbose output

kill pid
killall 程序名
killall -HUP inetd
kill -9 0杀死该用户登陆所产生所有进程包括历史记录

cp -av soure_dir target_dir #将整个目录复制,两目录完全一样
more #分页命令,一般通过管道将内容传给它,如ls | more

du -sm /root #计算/root目录的容量并以M为单位 (-S表示对整个目录,包括子目录)
du /usr默认以k为单位
du -sh dirname
-s 仅显示总计
-h 以K、M、G为单位,提高信息的可读性。KB、MB、GB是以1024为换算单位, -H以1000为换算单位。

find -name /path file    # 查找/path目录下是否有文件file
find / -name httpd.conf  # 查找/目录下是否有文件http.conf
find / -amin -10         # 查找在系统中最后10分钟访问的文件
find / -atime -2         # 查找在系统中最后48小时访问的文件
find / -empty            # 查找在系统中为空的文件或者文件夹
find / -group cat        # 查找在系统中属于group cat的文件
find / -mmin -5          # 查找在系统中最后5分钟里修改过的文件
find / -mtime -1         # 查找在系统中最后24小时里修改过的文件
find / -nouser           # 查找在系统中属于作废用户的文件
find / -user fred        # 查找在系统中属于FRED这个用户的文件

清除一个安装目录中清除所有的临时文件、中间件和配置文件
make mrproper

最后将在编译过程中的垃圾文件进行清理,命令如下:
make clean

#################################################################
RPM包的操作
  1. 用RPM安装软件包 :rpm -ivh 软件文件名
  例如 rpm -ivh fvwm95-2.0.43a.chinese-1.i386.rpm 屏幕上就会输出该软件包的名称和安装的进度条:
  fvwm95 ###############
  当进度条走到底,中文fvwm95(一种X-Window的界面)就安装完了,再运行X-Window,全中文的fvwm95就在我的眼前。

  2. 用RPM反安装软件包:rpm -e 软件名
  例如:rpm -e fvwm95

  3. 用RPM升级软件包:rpm -Uvh 软件升级版文件名
  例如:rpm -Uvh fvwm95-2.1.0a.chinese-1.i386.rpm
    RPM自动反安装原来的老版本,将升级版的软件安装入系统。
rpm -q检查看是否存在
rpm -qa | grep kernel
rpm -qf /bin/ps
rpm中的文件安装到哪里去了
rpm -qpl aaa.rpm
rpm --rebuild重新安装
rpmbuild --rebuild *.src.rpm
对于第三种[xxx.src.rpm],安装也很简单
拷贝到目标目录,然后执行
#rpmbuild --rebuild xxx.src.rpm 编译文件
然后进入#cd /usr/src/redhat(or other)/RPMS/i386/
执行 #rpm -ivh xxxxx.rpm 安装
上面的方法是对Redhat 8.0以及Mandrake9.0来说的,如果是低于这个版本。应该用
#rpm --rebuild *.src.rpm

#################################################################
UNIX下常见的压缩格式
.tar,.tar.gz,.bz2,.tar.bz2,.bz,.gz是什么文件,如何解开他们?
他们都是文件(压缩)包。
.tar:把文件打包,不压缩:tar cvf *.tar dirName 解开:tar xvf *.tar
.tar.gz:把文件打包并压缩:tar czvf *.tar.gz dirName 解开:tar xzvf *.tar.gz
.bz2:解开:bzip2 -d *.bz2
.bz:解开:bzip -d *.bz
.gz:解开:gzip -d *.gz
如果是bzip2格式,则执行如下命令:
#tar xjvf linux-2.4.23.tar.bz2
解压到指定目录tar zxvf igenus_2_20030516_snap.tgz -C /var/www/html
zcat /mnt/floppy/modules.cgz | cpio -i --list
    mv /tmp/modules.cgz /tmp/modules.cpio.gz
    gzip -d ./modules.cpio.gz
    cat /tmp/modules.cpio | cpio -ivd
cp ./2.4.21-4.ELsmp/a320raid.o /lib/modules/2.4.21-4.ELsmp/kernel/drivers/scsi/

      # gzip -dc modules.cgz > modules.cpio
      # cpio -idumv < modules.cpio

#################################################################
root密码丢失解决
GRUB:在引导装载程序菜单上,键入 [e] 来进入编辑模式。
你会面对一个引导项目列表。查找其中类似以下输出 的句行:
kernel /vmlinuz-2.4.18-0.4 ro root=/dev/hda2
按箭头键直到这一行被突出显示,然后按 [e]。
你现在可在文本结尾处空一格再添加 single 来告诉 GRUB 引导单用户 Linux 模式。
按[Enter] 键来使编辑结果生效。
你会被带会编辑模式屏幕,从这里,按 [b], GRUB 就会引导单用户 Linux 模式。
结束载入后,你会面对一个与以下相似的 shell 提示:
sh-2.05#
现在,你便可以改变根命令,键入:
bash# passwd root

把lilo启动改成grub启动
/sbin/grub-install /dev/sda

#################################################################
时间与时区设置
步骤如下:
# timeconfig "Asia/Shanghai" 设置时区(不用UTC)
这时会将/usr/share/zoneinfo/Asia/Shanghai拷贝为/etc/localtime
# date 查看一下时间,时区应变为CST
Thu Dec 26 00:37:40 CST 2002
date -s设置时间
# date MMDDhhmm[CCYY] 可设置时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
timeconfig "/usr/share/zoneinfo/Asia/Shanghai" 实际上是把该文件拷贝为/etc/localtime,所以我们可以直接

以链接的形式来设置时区
设置时间2004年5月16号10点54分
date 051610542004
如果安装了ntp-4.1.1-1,就不用自己设置时间了,执行
下面这条命令可以机器时间与NTP服务器校准。该服务器
在香港,可以从教育网访问。如果需要经常校准机器时间
就去设置NTP Client或者将下面的命令加入到cron任务中。
在Internet上提供ntp服务的站点有clepsydra.dec.com 、 ben.cs.wisc.edu、t ruechimer.waikato.ac.nz
# /usr/sbin/ntpdate clock.cuhk.edu.hk
/usr/sbin/ntpdate time.nist.gov
修改系统时间 
date -s "2004-05-16 cst",cst指时区,时间设定用date -s 18:10 
让linux自动同步时间(shunz) 
vi /etc/crontab 
加上一句: 
00 0 1 * * root rdate -s time.nist.gov 
date #显示当前日期时间
date -s 20:30:30 #设置系统时间为20:30:30
date -s 2002-3-5 #设置系统时期为2003-3-5
clock –r #对系统Bios中读取时间参数
clock --systohc #将系统时间(如由date设置的时间)写入Bios
clock --hctosys #将硬件时间写为系统时间
clock -w

#################################################################
在Linux下访问硬盘分区的内容,必须先用mount命令将分区加载到Linux的某个目录下才能
访问。
先用“fdisk -l”命令(某些版本可能需要用“fdisk -l
硬盘设备名”)查看硬盘分区情况,操作如下:
$ fdisk -l
Disk /dev/hda: 255 heads, 63 sectors, 4865 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 386 3100513+ b Win95 FAT32
/dev/hda2 * 387 388 16065 83 Linux
/dev/hda3 389 4865 35961502+ f Win95 Ext'd (LBA)
/dev/hda5 389 399 88326 82 Linux swap
/dev/hda6 400 1445 8401963+ b Win95 FAT32
/dev/hda7 1446 1963 4160803+ b Win95 FAT32
/dev/hda8 1964 2491 4241128+ 83 Linux
/dev/hda9 2492 3537 8401963+ b Win95 FAT32
/dev/hda10 3538 4347 6506293+ b Win95 FAT32
/dev/hda11 4348 4865 4160803+ 83 Linux
可以看到,硬盘上有5个Windows分区,分别是/dev/hda1、/dev/hda6、/dev/hda7、/dev/hda9/、/dev/hda10。
  mount命令的一般使用方法如下:
  mount -t 分区格式 分区位置 加载位置
  要访问/dev/hda1的内容,可以用以下代码进行加载:
$ mount -t vfat /dev/hda1 /mnt/c
-t vfat表示类型是vfat(Windows 95 FAT32)分区格式;/dev/hda1是被加载的分区位置;
/mnt/c代表Linux里/mnt目录下的名字为c的目录,如果不存在,则先用mkdir命令建立这个目录。
如果要求对分区进行写操作,
则用以下命令:
$ mount -rw -t vfat /dev/hda1 /mnt/c
其中的-rw参数表示Read和Write。
mount用法(sakulagi,sxsfxx)
fat32的分区 mount -o codepage=936,iocharset=cp936 /dev/hda7 /mnt/cdrom
ntfs的分区 mount -o iocharset=cp936 /dev/hda7 /mnt/cdrom
iso文件 mount -o loop /abc.iso /mnt/cdrom
软盘 mount /dev/fd0 /mnt/floppy
USB闪存 mount /dev/sda1 /mnt/cdrom
所有/etc/fstab内容 mount -a
可以指定文件格式"-t 格式", 格式可以为vfat, ext2, ext3等.
访问DVD mount -t iso9660 /dev/dvd /mnt/cdrom或mount -t udf /dev/dvd /mnt/cdrom
注意:dvd的格式一般为iso9660或udf之一

让系统使用默认的彩色文件显示
Linux终端下的不同类型文件的彩色显示让我们感觉非常方便,但有时可能不小心丢失这一
功能,在配置文件中加入alias ls="ls --color -F -N"就能保证这一功能的正常使用。

  在unix系统中root账户是具有最高特权的。如果系统管理员在离开系统之前忘记注销root
账户,那将会带来很大的安全隐患,应该让系统会自动注销。通过修改账户中“TMOUT”参
数,可以实现此功能。TMOUT按秒计算。编辑你的profile文件(vi
/etc/profile),在"HISTFILESIZE="后面加入下面这行:
  TMOUT=300
  300,表示300秒,也就是表示5分钟。这样,如果系统中登陆的用户在5分钟内都没有
动作,那么系统会自动注销这个账户。你可以在个别用户的“.bashrc”文件中添加该值,
以便系统对该用户实行特殊的自动注销时间。

查看系统信息 
cat /proc/cpuinfo - CPU (i.e. vendor, Mhz, flags like mmx) 
cat /proc/interrupts - 中断 
cat /proc/ioports - 设备IO端口 
cat /proc/meminfo - 内存信息(i.e. mem used, free, swap size) 
cat /proc/partitions - 所有设备的所有分区 
cat /proc/pci - PCI设备的信息 
cat /proc/swaps - 所有Swap分区的信息 
cat /proc/version - Linux的版本号 相当于 uname -r 
uname -a - 看系统内核等信息 

删除目录下所有文件包括子目录 
rm -rf 目录名 

切换X桌面(lnx3000) 
switchdesk KDE或者switchdesk GNOME 

显示 xwindows的语言
cp /etc/sysconfig/i18n $HOME/.i18n 
修改 $HOME/.i18n 文件,如 
LANG="en_US",xwindow会显示英文界面, 
LANG="zh_CN.GB18030",xwindow会显示中文界面。 
这样就可以改变个人的界面语言,而不影响别的用户

把弹出的光盘收回来
#eject -t   (eject cdrom)

快速观看开机的硬件检测
dmesg | more  (more为分页的命令)

查看目录的大小 
du -sh dirname 
-s 仅显示总计 
-h 以K、M、G为单位,提高信息的可读性。KB、MB、GB是以1024为换算单 位,
-H以1000为换算单位。 

字符模式下设置/删除环境变量 
bash下 
设置:export 变量名=变量值 
删除:unset 变量名 

vim中显示颜色或不显示颜色 
vi ~/.vimrc; 如果有syntax on,则显示颜色,syntax off,则不显示颜色 

在redhat9中,对系统的服务器的设置:
/etc/services这个文件里你可修改想要的端口号.重启守护进程
vi /etc/xinet.d/telnet
添加

用什么工具做入侵检测 
snort

Linux下检测程序内存泄漏的工具 
cchecker或是efence库都可以 

#################################################################
linux下系统和网络的监测工具

1,Tcpdump能够截获当前所有通过本机网卡的数据包。它拥有灵活的过滤机制,可以确保得到想要的数据。由于Tcpdump只能收集通过本机的数据,因此它的应用受到了一些限制,大多应用在网关或服务器自我检测上。
例如,在作为网关的主机上,想知道本地网络中IP地址为192.168.0.5的主机现在与外界通信的情况,就可以使用如下命令:
tcpdump -i eth0 src host 192.168.0.5
我只想知道192.168.0.5当前正在访问哪些Web站点,可以用下面这条命令:
tcpdump -i eth0 src host 192.168.0.5 and dst port 80

2,Nmap设计的初衷是系统管理员可以方便地了解自己的网络运行情况,例如有多少台主机在运行、分别提供什么样的服务。因此,它扫描的速度非常快,尤其适合大型网络。在对网络进行扫描时,Nmap主要利用ICMP echo探测主机是否开启。凡是了解TCP/IP协议的都知道,对于一个TCP端口,无论是否使用防火墙进行过滤,该主机都会对该端口发出的请求做出一定响应。所以即使配置了严格的防火墙规则,nmap照样可以找到这些主机例如,在一台IP地址为192.168.0.1的Linux主
机上执行下列命令:
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
它的作用就是对所有ICMP echo不予理睬,也就是让通常用来测试网络的Ping命令失效。这样至少可以抵挡POD(Ping of Death)的攻击。在任何一台机器上Ping这台主机,得到的都会是请求超时,如:
这台主机是否下线了?用Nmap探测试试看:
nmap -sP 192.168.0.1
nmap -sP 192.168.0.0/24 //24表明目标是一个网络而非单个主机
nmap 192.168.0.5 (探测开启了那些端口,那些服务)
nmap -O 192.168.0.5 (-O探测使用的操作系统)

3,Netstat主要用于Linux/Unix主机察看自身的网络状况,如开启的端口、在为哪些用户服务以及服务的状态等等。此外,它还显示系统路由表、网络接口状态等。可以说,它是一个综合性的网络状态察看工具,不过中规中举。
netstat 显示了当前所有已建立的连接
netstat -a显示所有在侦听的连接

4,lsof 可以显示目前打开该端口号的程序

#################################################################
计算机系统有两个时钟,一个是BIOS,或者CMOS,或者说“硬件时钟”,还有一个就是“系统(操作系统)时钟”,如果这两个时钟的设置上有问题,或者Linux 的时钟配置文件不正确的话,就会产生系统时钟差 8 小时的问题。
让我们先查看 /etc/sysconfig/clock 的内容:
[root@www /root]# cat /etc/sysconfig/clock
ZONE=Asia/Shanghai ;/usr/share/zoneinfo 下面的文件。
UTC=false ; 硬件时钟是否为 UTC 或者说 GMT 时钟。
ARC=false ;如果是在 Alpha 机器上,则设置为 true 。
把硬件时钟设置为 UTC 的好处就是他能自动设置夏时制,缺点时,在安装有多重操作系统启动的机器上,在另外的

操作系统上时钟会错误。
Linux 的时钟设置文件为:/etc/localtime ,实际上这个文件是 /usr/share/zoneinfo 目录下对应文件的符号连
接。假设我们所处的地区位于上海,那么只要运行以下的命令就可以设置时区了。
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Linux 启动时,其中的一个脚本(/etc/rc.d/rc.sysinit)会运行 /sbin/hwclock 程序,把当前的硬件时钟复制为
系统时间。hwclock 假定硬件时钟已经设置为本地时钟,除非带有 --utc 参数。脚本文件会读取
/etc/sysconfig/clock 文件的设置,因此我们不需要修改脚本,直接修改这个配置文件就可以了,根据需要把其中的 UTC 行,设置为 true 或者 false。
设置硬件时钟时,首先使用 date 命令("date MMDDhhmmYYYY.ss") 设置好系统时钟,然后使用 "/sbin/hwclock --systohc" 把硬件时钟设置为和当前系统时间一致。
如果你在某些应用下面的时间是错误的,那么你在运行 Red Hat Linux 5.0 或 5.1,解决的办法是建立
/usr/lib/zoneinfo 到 /usr/share/zoneinfo 的符号连接:
ln -s /usr/share/zoneinfo /usr/lib/zoneinfo

小结:时钟设置的问题本身比较简单,但是它涉及到几个基本的配置文件:
/etc/rc.d/rc.sysinit
/etc/sysconfig/clock
/etc/localtime
/usr/share/zoneinfo

让linux自动同步时间(shunz)
vi /etc/crontab
加上一句:
00 0 1 * * root rdate -s time.nist.gov

#################################################################
计算机文件命令执行时间
time cp * /home/hanyang
date;cp * /home/hanyang(从拷贝时间的到结束时间)

取消^M字符
   当你FTP一些DOS文件到unix下时,你经常会看见每行文件后面有个讨厌的^M 字符,
   有两个简单的方法可以取消它。
   用"vi"打开此文件,在Command mode下敲入:
     :%s/^V^M//g
   或者,在UNIX SHELL下敲入:
     sed 's/^V^M//g' foo > foo.new
rpcinfo -p查询rpc的服务端口

查看xinetd所打开的服务系统的服务
chkconfig --list
chkconfig apache off

sysctl -w vm.pagecache="1 15 20"

32位的机器就是地址空间为32的二进制数字
转换后备缓存(Translation Lookaside Buffers:TLB)

#################################################################
查看80端口的连接数
netstat -anlp | awk '/22/ && /tcp/ { split($5,ip,":"); print ip[1]}'

将ext2转为ext3
/sbin/tune2fs -j /dev/hdbX

去掉多余的回车符
sed 's/^M//' test.sh > back.sh, 注意^M是敲ctrl_v ctrl-m得到的
或者 dos2unix filename

如何得到网卡的MAC地址
arp -a | awk '{print $4}'
ifconfig eth0 | head -1 | awk '{print $5}'

如何得到网卡的IP地址(mb)
ifconfig eth0 |awk '/inet addr/ {split($2,x,":");print x[2]}'

#################################################################
RH9下GCC的安装
三种方法选一:
(1)利用CD上rpm安装
CD-1:compat-gcc-7.3-2.96.118.i386.rpm
CD-1:compat-gcc-c++-7.3-2.96.118.i386.rpm
CD-1:libgcc-3.2.2-5.i386.rpm
CD-2:compat-gcc-g77-7.3-2.96.118.i386.rpm
CD-2:compat-gcc-java-7.3-2.96.118.i386.rpm
CD-2:compat-gcc-objc-7.3-2.96.118.i386.rpm
CD-2:gcc-3.2.2-5.i386.rpm
CD-2:gcc-c++-3.2.2-5.i386.rpm
CD-2:gcc-g77-3.2.2-5.i386.rpm
CD-2:gcc-gnat-3.2.2-5.i386.rpm
CD-2:gcc-java-3.2.2-5.i386.rpm
CD-2:gcc-objc-3.2.2-5.i386.rpm
比如碰到系统提示:
warning : gcc-3.2.2-5.i386.rpm : V3 DSA signature :MOKEY key ID db42a60e
error : Failed dependencies :
binutils >=2.13.90.0.18-9 is needed by gcc-3.2.2-5
glibc-devel >=2.3.2-11.9 is needed by gcc-3.2.2-5...
就先安裝glibc-devel包,依此类推
(2)更好的方法就是在X-window下选“主菜单”──>“系统设置”──>“添加/删除应用程序”──>“开发工具”

中的gcc并安装它
(3) up2date gcc便可自动解决dependency问题

#################################################################
linux开机检测新硬件程序
自动检查新硬件的服务是Kudzu,用户可以用“ntsysv”命令启动该服务。下次重启就会找到用户的新网卡。
"bps"代表的是bit per second,也就是比特位每秒,而“Bps”代表的是Byte per second,是字节每秒,也就是说,1Bps=8bps,

last命令默认是找/var/log/wtmp文件可以通过-f参数指定文件
last -f /var/log/wtmp.1 | more 来查看之前的登陆信息

#################################################################
恢复linux误删的文件
# mkdir hda8 注:创建一个目录
# mount -t reiserfs /dev/hda8 hda8 注:把/dev/hda8 挂载到hda8目录上;
# df -h 注:查看/dev/hda8是否挂载上了;
# cd hda8 注:进入hda8目录;
# dd if=/dev/sda1 conv=noerror > sda1.img 注:做 /dev/sda1 的整个分区的镜像;
# losetup -f 注:查询哪个loop设备是空的
/dev/loop0 注:发现有一个空的是/dev/loop0
# losetup /dev/loop0 sda1.img
注:把sda1.img 镜象关联到/dev/loop0的设备中
# reiserfsck --rebuild-tree -S -l undelete.log /dev/loop0
注:通过reiserfsck 来修复,-S 表示整个分区,-l 后面是接日志输出,最后是/dev/loop0设备;因为我们前面把sda1.img 关联到了/dev/loop0设备中,这样/dev/loop0就拥有了sda1.img的所有属性;这和直接通过下面命令修复的效果是一样的;但这样通过镜像装载修复的方法主要是为了安全;
# reiserfsck --rebuild-tree -S -l undelete.log /dev/sda1
注:这样直接操作也行,如果 /dev/sda1上有bad block就麻烦了;可能会损伤到/dev/sda1 数据的安全,明白了吧;
# mkdir recoversda1 注:创建一个目录;
# mount /dev/loop0 recoversda1 注:把/dev/loop0挂载到 recoversda1 上;
# more undelete.log 注:查看恢复日志;
# cd recoversda1 注:进入recoversda1目录查看数据恢复情况;

#################################################################
linux下增加硬盘
#fdisk /dev/sdb
进入fdisk模式:
Command (m for help):p  //查看新硬盘的分区
Command (m for help):n  //创建新分区

可以用m命令来看fdisk命令的内部命令;n命令创建一个新分区;d命令删除一个存在的分区;p命令显示分区列表;

t命令修改分区的类型ID号;l命令显示分区ID号的列表;a命令指定启动分区;w命令是将对分区表的修改存盘让它

发生作用。

Command action
   e   extended   //输入e为创建扩展分区
   p   primary partition (1-4)   //输入p为创建主分区,这里我们选择p

Partion number(1-4):1  //第一个扩展分区,按你需求可以最多分4个主分区
First Cylinder(1-1014,default 1):  1  //第一个主分区起始的磁盘块数
Last cylindet or +siza or +sizeM or +sizeK: +1024MB  //可以是以MB为单位的数字或者以

磁盘块数,这里我们输入+1024MB表示分区大小为1G。
#mkfs -t ext3 -c /dev/sdb1
#mkdir www //创建/www目录,我们将把新的分区挂到www下
#mount /dev/sdb1 /www  //将/dev/sdb1挂载到/www
# df  //用df命令进行查看
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2              3771316   1388956   2190788  39% /
/dev/sda1               101089      9463     86407  10% /boot
none                     62988         0     62988   0% /dev/shm
/dev/sdb1               485906      8239    452580   2% /www  //看到了,这就是我们刚

才新挂载的分区
#vi /etc/fstab
在文件的末尾填加如下内容:
/dev/sdb1               /www                    ext3    defaults        1 2 
-------------------------------------------------------------

linux学习笔记(三)

磁盘限额:

1、对分区做磁盘限额,是某个分区的属性

2、硬限制: 完全的限制

软限制:  警告

3、 对磁盘空间做限制,也可以做生成的文件数做限制

需要修改/etc/fstab文件: 启动自动加载的信息

4、 对象可以某个用户或某个组

分区  加载点  文件系统类型 选项  fsck dump

mount -a : 

设置磁盘限额:

1、分区、格式化

2、修改/etc/fstab   option: defaults,usrquota

3、在需要做磁盘限额的目录生成文件:touch aquota.user

4、quotacheck -avu  :提示信息为扫描的文件数量可以

5、 新建测试用户 abc1

6、针对用户设置限额:edquota -u abc1

7、修改blocks  soft hard : 单位是k

8、启用分区的限额:qoutaon /sdb1

9、设置目录适当的权限

10、切换用户测试 dd if

mount -o remount /boot

chmod o+w

edquota -p abc1 abc2 abc3

abc2 abc3用户的限额与abc1一致的

显示目录大小: du

/etc/fstab option: defaluts,usrquota,grpquota

在限额目录下生成文件:touch aquota.group

quotacheck -auvg

组中每个用户生成的文件都生效

限制生成文件数:inode

对某个用户如果同时设置了空间的限额和文件数的限额,其中
任何个一个达到,都不能再写。硬链接不生效

在执行edquota -p user1 user2 user3后

再修改user1的限额,不影响user2, user3,需要重新执行

对目录做限额:

目录所在分区不做磁盘限额

1、生成iso文件,文件的大小是目录限额最大大小

dd if=/dev/zero of=1.iso bs=1M count=10

2、把iso文件与环路设备建立关联

losetup /dev/loop0 1.iso

3、生成文件系统:

mkfs -t ext3 /dev/loop0

4、 加载环路设备:

mount -o loop /dev/loop0 abc (abc是需要做限额的目录)

losetup -d /dev/loop0

特殊文件权限:

suid sgid   t :

suid : 4  sgid: 2 t: 1

setuid:属性在显示有可能是S或s

S:表示没有x属性
s:有x属性

chmod 4644 f1

t:t属性是设置给其它用户(粘滞属性),设置给目录

 chmod o+t filename (T t)

chmod 7777 f1

粘滞属性作用: 共享目录防删除 :所有用户都有写的权限

,每个用户都只能删除属于自己的文件

T: 没有x属性

t: 有x属性

查找含有suid的文件:

查找文件:find

find . -name ntp.conf : 在当前目录查找,再在当前目录
下的子目录查找

find . -maxdepth 1 -name ntp.conf : 1:当前目录

find -user username

find / -perm +4000

find . -type f | xargs rm -rf

b:  block 磁盘 :

c: 字符设备: 显示设备 :连接读写

l: link (软链接文件)

ls :

ls -l | grep ^d

grep -v :  不包含指定关键字的

locate

wall :  发送消息

write username tty  回车  输入消息

fuser  查看相关进程

fuser -km /abc

fuser -mv /abc

lsof /abc

linux学习笔记(二)

用户管理:

创建用户:useradd username

adduser username : 链接文件

用户信息:/etc/passwd

查看所有用户cat /etc/passwd

wc :统计文本文件

wc -l /etc/passwd

grep: 查找文本文件,查找含有指定关键字的所有行

grep username /etc/passwd :查找是否含有指定用户

/etc/passwd : 文件格式

1、用户名:x

2、x: 密码不保存在/etc/passwd,保存在/etc/shadow

3、uid:  用户标识

通过uid可以区分用户的状态:

1、管理员用户:uid 0   root

2、1-499: 内置账号

3、>=500: 普通用户 : UID是连接+1

4、gid: 组ID : 集中赋权限

gid默认是与uid相同

5、用户的说明信息 : 添加说明信息

建立用户时可以加入说明信息:useradd -c "String"
username

6、用户的主目录: 用户登录系统时最先进入目录是主目录

自动生成用户的主目录,主目录位置/home有一个与用户同名

的目录

7、登录时的shell: 命令解释器 bash

指定特定的信息:

指定UID:useradd -u 2000 user5

useradd -u 2000 -o user6 : 允许用户的uid重复

指定GID: 要求GID要存在

useradd -g gid username : 要求gid是存在的

useradd -c "" username :说明信息

修改用户的主目录:useradd -d /users/user12 user12

修改shell :  要求shell在/etc/shells文件中存在

useradd -s /bin/ksh username

useradd -u 4001 -g 0 -c "user18"  -d /users/user18 -s /bin/csh user18

修改用户信息:

修改建立用户的默认信息:/etc/default/useradd

直接修改用户的信息:usermod

useradd -s /bin/bash user20

-l: 用户改名

usermod -l newname oldname

用户主目录:

切换用户:su -  username:  切换用户同时应用新用户的环境量

主目录下的信息: 保存有用户的环境变量信息 ls -a

环境变量的配置:

全局修改、针对特定用户

全局修改:/etc/profile    /etc/bashrc

区别: 用户登录时应用:/etc/profile

/etc/bashrc: 新打开新终端时生效

查看当前的路径信息:

PATH=$PATH:/jdk1.5/bin 分隔符是冒号(分号)

export PATH

linux下的当前目录是不做为命令查找目录,需要手工加入

export PATH=

./command : 当前

source /etc/bashrc

source /etc/profile :

. filename : 文件本身不需要执行权限,立即执行

/etc/profile : source /etc/profile :在当前窗口生效

只修改某个用户:修改用户主目录下环境变量文件()

新建的用户默认拷贝的是/etc/skel目录下的所有文件

组: 

显示组的信息:/etc/group文件 

在redhat中新建用户时默认生成同名的组

用户默认是属于同名组: 

用户属于多个组

用户的组: 主组  辅助组

默认用户只能有一个主组,但可属于多个辅助组

useradd -g 主组名称 -G 辅助组名称列表用逗号隔开 username

useradd -g hh5 -G 4004,4005,4006 hh5

显示用户的ID :

id 命令可以列出用户的uid及所有的gid

id username:

groups username: 查看用户所属组(主组在前)

显示当前用户:whoami

显示所有的在线用户:who     w

如果是远程连接: 相当于登录时以伪终端登录

允许root用户做telnet连接:

修改允许的伪终端的值 vi /etc/securetty

只要是还有可用的伪终端时root就可以做远程telnet 连接

vi /etc/xinetd.d/telnet

disable = no

service xinetd restart

禁用root做远程的ssh: vi /etc/ssh/sshd_config

PermitRootLogin  no

service sshd restart

删除用户: 删除组时: 不是用户的主组

修改用户的主组: usermod -g newgroup  username

userdel username : 不删除用户的主目录

userdel -r username: 同时删除用户的主目录 

ls -l dirname: 显示目录的内容

ls -ld dinname: 显示目录本身的信息

ls -l : 连续十个字符 

第一个字符代表文件的类型:

1、普通文件 -
2、目录 d

3、字符设备 c

4、块设备 b

5、链接文件  l

文件的所有者,文件的所属组

所有者是创建文件的用户,所属组所有者所在的主组

数字:表示 节点数量 inod值 

touch f1 --- f1inod ---

f2

f3

硬链接表示时是- (file)

ln 源文件  链接文件

ln -s 源文件 链接文件 

权限: 常用的权限有三种: 读 写 执行

用字表示: r w x

三种权限赋给三类用户:所有者 所属组 其它用户

默认的文件的权限:rw-r--r--

默认的目录的权限: rwx-r-xr-x

r: 对于文件: 可以显示文件的内容

w: 对于文件: 可以修改文件

x: 对于文件: 可以执行文件

r:  对于目录: 可以列出目录的内容

w: 对于目录: 可以在目录中生成文件或目录

x: 对于目录: 用户可以进入目录

修改权限 :chmod o-x dirname

默认权限是由umask决定:umask的默认值是0022

0666
0022

0777
0022

r: 4  w: 2 x : 1

文件的默认权限是644,目录的默认权限是755

修改umask值 :umask 0044

suid sgid: 

suid: 执行文件时以文件的所有者身份运行,默认是当前用户

passwd : 普通用户是能够修改自己的密码

密码保存在/etc/shadow

chmod u-s /usr/bin/passwd : 普通用户不能修改自己的密码

sgid:

linux学习笔记(一)

共分4个部分:

   系统管理、网络服务、应用、系统管理:

linux常用命令:

1、ls : 列列出文件 : 所有文件

隐藏文件:ls -a

隐藏文件:名称是.开头的文件 

.:当前目录

..: 上一级目录 

ls -l: 显示文件或目录详细信息

ls -lh: 以可读的形式显示文件大小 

2、显示目录:pwd

3、生成目录:mkdir (make directory) : 相对目录或是绝对目录

mkdir /lx 

mkdir /abc

mkdir -p  /1/2/3/4/5 :自动生成上一级目录 

4、切换目录:cd (change directory)

cd /1 (cd..)

cd .. : 进入上一级目录有空格

5、生成文件:

生成空文件:touch f1

6、拷贝:cp

cp /etc/*.conf .

cp -rf :支持拷贝文件和目录 (cp -f:提示)

cp : 不能拷贝文件

7、删除: rm : 直接删除是有提示

分区管理:
文件系统:

分区管理 :

分区类型:

1、主分区

2、扩展分区

主分区+扩展分区<=4

3+1:

多于4个分区在扩展分区上分逻辑分区:

分区标识:  硬件标识:

IDE: IDE : 主:hda hdb   IDE2: hdc hdd

hda:IDE1 主

主分区和扩展分区:hda1 hda2 hda3 hda4

扩展分区:不能直接使用

逻辑分区:hda5

查看当前已加载的分区的情况:df -h

显示文件系统类型: df -hT

文件系统: ext3 (ext2)

ext3: 带有日志支持(快速恢复) :

分区命令:mkfs (make file system)

mkfs -t ext3 /dev/hda5 (格式化)

加载分区:

mount /dev/hda5 /dirname  (加载点)

iso:

mount -o loop isofile.iso /dirname

生成iso文件: dd 生成指定大小的文件

dd if=/dev/zero of=1.iso bs=1M count=10

显示分区信息:fdisk -l

网络客户端工具:

1、显示ip地址信息:

ifconfig

2、修改IP地址:

netconfig

直接配置文件:vi /etc/sysconfig/network-scripts/ifcfg-eth0

不是立即生效:ifdown eth0  ifup eth0

3、在一个物理网卡一绑定多个IP地址

生成设备文件:

cd /etc/sysconfig/network-scripts/

cp ifcfg-eth0 ifcfg-eth0:1

多个拷贝

编辑配置文件

ifup 设备文件名

通过图形界面修改IP地址:

redhat-config-network: 简化命令neat

重启网络服务:service network restart

远程管理:

一、telnet :  不安全,默认是不启动的

启动telnet服务器:通过xinetd服务控制

验证telnet服务是否打开 :  23端口

显示本机端口的状态:

netstat -an | grep 23

直接telnet hostip port

1、cd /etc/xinetd.d

2、vi telnet

disable = yes (no)

3、重启xinetd服务

二、SSH

ssh监听的端口:22

关掉ssh服务:service sshd stop

三、通过图形界面:vnc

配置VNC:

启动服务: service vncserver start (stop restart)

vncserver  :启动多个图形界面

172.16.200.33:1

四、通过 FTP服务实现:

配置ftp server: 

port: 21:管理端口  20: 数据端口

连接连接方式:主动式 被动式

1、启动FTP服务:

FTP SERVER: FTP服务器端工具: vsftp: very secure

service vsftpd start (stop restart)

2、FTP用户:默认ftp 密码:任意或不输入

3、文件在服务器放置的位置:/var/ftp

4、FTP命令:下载文件 get filename

修改默认的下载的位置:lcd

显示服务端的位置:pwd

显示本地文件:! ls

! mkdir /ftp

下载多个文件 :mget *.conf : 下载之前有提示信息

不需要提示信息:prompt off (on)

linux下的ftp工具:ftp

lftp: 默认是以匿名账号连接(ftp) :支持自动补齐(tab)

可以显示下载速度:dd if=/dev/zero of=11.iso bs=10M count=100

支持下载目录:mirror dirname :下载目录

mirror -R dirname : 上传目录

lftp -u f1 hostip

图形界面的FTP工具:gftp

wget : 参数 () :

分区:

1、添加硬盘:
2、显示硬件标识  fdisk -l
3、 fdisk /dev/sdb
4、n:新建分区   p:主 e:扩展  w:保存

n: 启始柱面
大小 :+20m
w

5、新建立的分区是不能使用的,重启系统

6、格式化 mkfs -t ext3 /dev/sdb1

mkfs.ext3 /dev/sdb5

7、加载文件系统:

mkdir h1

mount /dev/sdb5 /h1

8、fdisk -l 把分区信息保存下来 ()

可以直接还原

9、大小: 数据库服务器 (调优) ***查询手册

10、加载分区: 中文:

mount -iocharset cp936 (gb2312)

11、加载优盘mount /dev/sda1 /dirname

手工检测:kudzu

fdisk -l

mount /dev/cdrom /dirname

查看光盘对应的设备文件:ls -l /dev/cdrom

查看硬盘大小 :fdisk -l

查看内存大小: free -m  包括交换分区

分区大小:df -h

查看CPU信息:cat /proc/cpuinfo

查看操作系统版本 :cat /etc/redhat-release

显示内核版本 :uname -r

增加交换分区大小:

1、直接生成交换分区 fdisk

2、通过ISO文件

生成iso文件

mkswap filename.iso

编辑/etc/fstab 永久生效

加入信息

/:
swap: 交换分区不是必须的

1、磁盘限额

2、RAID配置(软件)

3、启动配置

临时修改交换分区 swapon filename.iso

swapoff iso

How to Manage the Perfect Project

Want to complete projects successfully? On-time,within budget, and involving the appropriate people to ensure integration? These project management steps will ensure you practice effective project management.

1. Select the project. Assemble the team that must own the project to create a positive implementation and integration.

2. Define the internal or external customer's requirements from the outcome or output of the project.

3. Define the scope of the project and the outcome desired. As part of this definition, determine where the project begins and ends. What's the first step? What's the last?

4. Define measurable goals that will enable you to know that the project is accomplished. Define your budget for the project. Determine the people and hours that are required to complete the project.

5. Determine how you will communicate progress and accomplishments, and gather input from organization members who are not on the team.

6. Flow chart the current process.Or, for a specific project, list the steps necessary to accomplish the project.

7. Measure how the current project is performing right now, if this is an ongoing project. Study the data to adjust your goals and expectations.

8. Determine whether additional information, resources or people are needed to complete the project.Bring the people and resources identified into the group.

9. Create an action plan to complete the project's steps. Assign the appropriate people to complete each step. Create a due date for when each step will be accomplished.Make sure people have the time needed allocated to the project.

10. Determine an ongoing method to track whether the steps are accomplished as planned. Hold weekly meetings, set up a centrally-located planning calendar, widely distribute meeting minutes, or list the steps on a public white board.

11. Implement the action plan. Document the methods used to accomplish each step. You will want to be able to share the steps and goals and duplicate the successful ones, if this is an ongoing or periodically repeated project.

12. Determine how the team will measure, record, and track the effectiveness of the project implementation and planning process for the future.

13. Using the data collected, evaluate results. How did the project meet expectations and satisfy planners and participants? If not, why not? Document for future projects.

14. Celebrate the accomplishments of the team.

15. Determine how the lessons learned and steps experienced during this project can be applied to projects in the future.Find a method for integrating "best practice" steps for project management.

Tips:

1.Involve the appropriate people who own the process and can make or break the success of your implementation and integration.

2. Document your steps so that the team that follows or implements your project next year has the appropriate information they need to duplicate your successful steps and planning process.

3. Keep any forms,flyers, advertisements, communication documents, team minutes, and all other data related to the project in a file that can be accessed for the next project planning.

How to Manage a Project

Congratulations! You've just been appointed to manage a project. How do you get started? What steps do you do next? How do you maximize your chances for success? The project management steps below guide you through the process of managing any project,step by step.

1. Define the Scope

The first, and most important,step in any project is defining the scope of the project.What is it you are supposed to accomplish by managing this project? What's the project objective?Equally important is defining what is not included in the scope of your project.If you don't get enough definition from your boss, clarify the scope your self and send it back upstairs for confirmation.

2. Determine Available Resources

What people,equipment, and money will you have available to you to achieve the project objective? As a project manager, you usually will not have direct control of these resources,but will have to manage them through matrix management. Find out how easy or difficult that will be to do.

3. Check the Timeline

When does the project have to be completed? As you develop your project plan you may have some flexibility in how you use time during the project, but deadlines usually are fixed. If you decide to use overtime hours to meet the schedule, you must weigh that against the limitations of your budget.

4. Assemble Your Project Team

Get the people on your team together and start a dialog. They are the technical experts. That's why their functional supervisor assigned them to the project. Your job is to manage the team.

5.List the Big Steps

What are the major pieces of the projects? If you don't know, start by asking your team. It is a good idea to list the steps in chronological order but don't obsess about it; you can always change the order later.

6. List the Smaller Steps

List the smaller steps in each of the larger steps.Again, it usually helps you remember all the steps if you list them in chronological order. How many levels deep you go of more and more detailed steps depends on the size and complexity of your project.

7.Develop a Preliminary Plan

Assemble all your steps into a plan.What happens first?What is the next step? Which steps can go on at the same time with different resources? Who is going to do each step?How long will it take? There are many excellent software packages available that can automate a lot of this detail for you.Ask others in similar positions what they use.

8.Create Your Baseline Plan

Get feedback on your preliminary plan from your team and from any other stakeholders.Adjust your timelines and work schedules to fit the project into the available time.Make any necessary adjustments to the preliminary plan to produce a baseline plan.

9.Request Project Adjustments

There is almost never enough time,money or talent assignment to a project. Your job is to do more with the limited resources than people expect.However, there are often limits placed on a project that are simply unrealistic.You need to make your case and present it to your boss and request these unrealistic limits be changed. Ask for the changes at the begining of the project. Don't wait until it's in trouble to ask for the changes you need.

10.Work Your Plan, But Don't Die for It