实例解说 fdisk 使用方法

提要:fdisk 是一款功能强大的分区工具,也是目前在Unix类操作系统中最流行的工具之一;分区工具老字号;本篇只介绍其最简单的分区操作功能;


一、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<BR><BR>Disk /dev/hda: 80.0 GB, 80026361856 bytes<BR>255 heads, 63 sectors/track, 9729 cylinders<BR>Units = cylinders of 16065 * 512 = 8225280 bytes<BR><BR>&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<BR>/dev/hda1&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 765&nbsp;&nbsp;&nbsp;&nbsp; 6144831&nb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p;&nbsp;&nbsp;&nbsp; 6657&nbsp;&nbsp;&nbsp; 11719386&nbsp;&nbsp; 83&nbsp; Linux<BR>/dev/hda9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6658&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7751&nbsp;&nbsp;&nbsp;&nbsp; 8787523+&nbsp; 83&nbsp; Linux<BR>/dev/hda10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7752&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9729&nbsp;&nbsp;&nbsp; 15888253+&nbsp; 83&nbsp; Linux<BR><BR>Disk /dev/sda: 1035 MB, 1035730944 bytes<BR>256 heads, 63 sectors/track, 125 cylinders<BR>Units = cylinders of 16128 * 512 = 8257536 bytes<BR><BR>&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<BR>/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<BR>/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<BR>/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<BR>/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 76&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200781&nbsp;&nbsp; 83&nbsp; 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<BR>255 heads, 63 sectors/track, 9729 cylinders<BR>Units = cylinders of 16065 * 512 = 8225280 bytes

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

分区序列&nbsp;&nbsp;&nbsp; 引导&nbsp;&nbsp;&nbsp; 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bsp; 15888253+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 83&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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<BR>256 heads, 63 sectors/track, 125 cylinders<BR>Units = cylinders of 16128 * 512 = 8257536 bytes<BR><BR><BR>&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<BR>/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp;&nbsp; c&nbsp; W95 FAT32 (LBA)<BR>/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 806400&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<BR>/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<BR>/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 76&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200781&nbsp;&nbsp; 83&nbsp; 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&nbsp;&nbsp;&nbsp; 设备

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

[root@localhost beinan]# fdisk&nbsp;&nbsp;&nbsp;&nbsp; /dev/hda<BR><BR>[root@localhost beinan]# fdisk&nbsp; /dev/sda

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

1、fdisk 的说明;

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

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

其实我们常用的只有注有中文的,其它的功能我们不常用(呵,主要是我不会用,否则早会卖弄一下了);x扩展功能,也不是常用的;一般的情况下只要懂得 d l m p q t w 就行了;下面以实例操作来详述,没有例子没有办法就,新手也看不懂;

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


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





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




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

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



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




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

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

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





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




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





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

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

Command (m for help): w<BR><BR>Command (m for help): q





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

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

Command (m for help): p 注:列出分区表;<BR><BR>Disk /dev/sda: 1035 MB, 1035730944 bytes<BR>256 heads, 63 sectors/track, 125 cylinders<BR>Units = cylinders of 16128 * 512 = 8257536 bytes<BR><BR>&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<BR><BR>Command (m for help): n 注:添加分区;<BR>Command action<BR>&nbsp;&nbsp; e&nbsp;&nbsp; extended<BR>&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<BR>p&nbsp; 注:添加主分区;<BR>Partition number (1-4): 1&nbsp;&nbsp; 注:添加主分区1;<BR>First cylinder (1-125, default 1):&nbsp;&nbsp; 注:直接回车,主分区1的起始位置;默认为1,默认就好;<BR>Using default value 1<BR>Last cylinder or +size or +sizeM or +sizeK (1-125, default 125): +200M&nbsp;&nbsp; 注:指定分区大小,用+200M来指定大小为200M<BR><BR>Command (m for help): n&nbsp; 注:添加新分区;<BR>Command action<BR>&nbsp;&nbsp; e&nbsp;&nbsp; extended<BR>&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<BR>p&nbsp; 注:添加主分区<BR>Partition number (1-4): 2&nbsp; 注:添加主分区2;<BR>First cylinder (26-125, default 26):<BR>Using default value 26<BR>Last cylinder or +size or +sizeM or +sizeK (26-125, default 125): +200M 注:指定分区大小,用+200M来指定大小为200M<BR><BR>Command (m for help): n<BR>Command action<BR>&nbsp;&nbsp; e&nbsp;&nbsp; extended<BR>&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<BR>e&nbsp; 注:添加扩展分区;<BR>Partition number (1-4): 3&nbsp; 注:指定为3 ,因为主分区已经分了两个了,这个也算主分区,从3开始;<BR>First cylinder (51-125, default 51):&nbsp; 注:直接回车;<BR>Using default value 51<BR>Last cylinder or +size or +sizeM or +sizeK (51-125, default 125):&nbsp;&nbsp; 注:直接回车,把其余的所有空间都给扩展分区;<BR>Using default value 125<BR><BR>Command (m for help): p<BR><BR>Disk /dev/sda: 1035 MB, 1035730944 bytes<BR>256 heads, 63 sectors/track, 125 cylinders<BR>Units = cylinders of 16128 * 512 = 8257536 bytes<BR><BR>&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<BR>/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<BR>/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201600&nbsp;&nbsp; 83&nbsp; Linux<BR>/dev/sda3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 604800&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<BR><BR>Command (m for help): n<BR>Command action<BR>&nbsp;&nbsp; l&nbsp;&nbsp; logical (5 or over)<BR>&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<BR>l&nbsp; 注:添加逻辑分区;<BR>First cylinder (51-125, default 51):<BR>Using default value 51<BR>Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M&nbsp; 注:添加一个大小为200M大小的分区;<BR><BR>Command (m for help): n<BR>Command action<BR>&nbsp;&nbsp; l&nbsp;&nbsp; logical (5 or over)<BR>&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<BR>l&nbsp; 注:添加一个逻辑分区;<BR>First cylinder (76-125, default 76):<BR>Using default value 76<BR>Last cylinder or +size or +sizeM or +sizeK (76-125, default 125): +200M 注:添加一个大小为200M大小的分区;<BR><BR>Command (m for help): p&nbsp; 列出分区表;<BR><BR>Disk /dev/sda: 1035 MB, 1035730944 bytes<BR>256 heads, 63 sectors/track, 125 cylinders<BR>Units = cylinders of 16128 * 512 = 8257536 bytes<BR><BR>&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Blocks&nbsp;&nbsp; Id&nbsp; System<BR>/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<BR>/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201600&nbsp;&nbsp; 83&nbsp; Linux<BR>/dev/sda3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 125&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 604800&nbsp;&nbsp;&nbsp; 5&nbsp; Extended<BR>/dev/sda5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 51&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 75&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; Linux<BR>/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 76&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 201568+&nbsp; 83&nbsp; 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<BR>[root@localhost beinan]# mount /dev/sda6 /mnt/sda6<BR>[root@localhost beinan]# df -lh<BR>Filesystem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 容量&nbsp; 已用 可用 已用% 挂载点<BR>/dev/hda8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11G&nbsp; 8.4G&nbsp; 2.0G&nbsp; 81% /<BR>/dev/shm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 236M&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; 236M&nbsp;&nbsp; 0% /dev/shm<BR>/dev/hda10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16G&nbsp; 6.9G&nbsp; 8.3G&nbsp; 46% /mnt/hda10<BR>/dev/sda6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 191M&nbsp; 5.6M&nbsp; 176M&nbsp;&nbsp; 4% /mnt/sda6

 

 

这样我们就能进入 /mnt/sda6目录,然后存取文件了;具体的权限方法,以及mount 更详细的用法,在以后我会专门写一个帖子;在一帖中放下所有的内容实在有点为难;后记:在本文写完后,我还要写另一个分区工具parted;在 Fedora 4.0 中cfdisk 被去掉了;所以不想介绍这个工具;

 

解决linux下不同图形环境的输入法切换问题

相关说明:

gedit /usr/share/doc/scim/README.Qt





SCIM supports three different input modes — XIM mode, GTK IM mode, and Qt 3 IM mode.  The Qt 3 IM mode needs an unofficial patch for Qt 3, because Trolltech has said that such patch can’t go into Qt 3 as it’s considered too intrusive.  Debian’s Qt maintainers has included this patch into Qt 3 packages since version 3:3.3.5-4.


Qt 4 has plans to officially support input methods, but the current status in Qt 4.3.2 is still not clear (at least to the author of this README).  And there is currently no Qt 4 IM module support for SCIM in Debian.


Therefore, Qt/KDE 3 applications can use either XIM mode or Qt 3 IM mode for SCIM.  These can be easily set and changed with the im-switch package.  The XIM mode support is included in scim package.  To use Qt 3 IM mode, you also need to install scim-qtimm package.  Qt/KDE 4 applications only have the option of XIM mode, but it should work just fine.


When using XIM mode in Qt 3, You need to pay extra attention on two things:


1. Both Qt and SCIM has their own settings for XIM style, so you need to make sure they match.  There are two commonly used XIM styles, usually called “on the spot” and “over the spot”.  To change the style in SCIM, run scim-setup (or choose “SCIM Input Method Setup” from your menu), and go to the “FrontEnd -> Global Setup” page.  The option to change XIM style is “Embed Preedit String into client window”, when it is selected, you are using “on the spot” style; and when it is not selected, you are using “over the spot” style.  To change the style in Qt, run qtconfig (or choose “Qt3 Configuration” from your menu), go to “Interface” tab, and choose the style in the “XIM Input Style” dropdown menu at the bottom.  You usually don’t need the “off the spot” or “root” style.


2. It is reported that some of the KDE applications don’t work very well when using “on the spot” style.  So if your application behaves strangely, you may want to try switching to “over the spot” style first.


(Last updated by Ming Hua, on Sat, 13 Oct 2007)

vim:textwidth=78:





其实可以在所有qt程序中点击鼠标右键后,有一个“select input method”,在里面选择scim或者scim-bridge后就好了,但这样子的问题是我每次都得选择。


所以可以设置环境变量:


export XMODIFIERS=”@im=SCIM”
export GTK_IM_MODULE=”scim”
export QT_IM_MODULE=”scim”

我的ubuntu用的是scim输入法,另外在KDE的程序中输入中文还要设置QT3 CONFIG或者QT4 CONFIG在interface(好象是这个选项)将on the spot 改为over the spot。

设置ubuntu登录窗口的分辨率

sudo gedit /etc/X11/xorg.conf


Section “Screen”
 Identifier “Default Screen”
 Monitor  “Configured Monitor”
 Device  “Configured Video Device”
 Defaultdepth 24
 SubSection “Display”
  Depth 24
  Virtual 1024 768
  Modes  “1024×768@85”
 EndSubSection
EndSection

记得修改前要备份。

给Ubuntu的KDevelop安装中文包

Ubuntu 安装了KDevelop后发现是英文界面,许多专业术语,四处查找,将安装中文包的方法叙述如下。


1、下载中文包,在该网页上显示了目前的本地化进度


2. 执行:msgfmt kdevelop.po -o kdevelop.mo


3. sudo cp kdevelop.mo /usr/share/locale-langpack/zh_CN/LC_MESSAGES/


4. 启动kdevelop


注意:
msgfmt在有的Ubuntu上可能没有安装,要是搜索安装msgfmt这个软件是找不到的,其实应该安装的是下列软件


sudo aptitude install gettext


就ok了

让ubuntu播放rm/rmvb

Linux下支持real产品视频(rm/rmvb)播放的播放器并不多,印象中有两款不错,第一款叫什么忘瓜了,不过还是官方的realplayer播放器是最好的。


现在realplayer 11 for linux已经发布,较以往的版本有较大进步,包括windows media(wmv)支持、改进的alsa驱动支持等,推荐使用mplayer出现影音不同步现象大的朋友使用。据说播放rmvb、rm效果较好!
Ubuntu 8.04安装Realplayer 11的注意事项:


1、下载地址:http://www.real.com/linux,默认是一个bin二进制包,redhat /centos/fedora等可以选择那个rpm包,用rpm -ivh安装。


2、赋予文件可执行权限:sudo chmod +x RealPlayer11GOLD.bin。


3、安装:sudo ./RealPlayer11GOLD.bin,按照提示进行就可以了。


注意一定要以根用户(sudo)安装,否则realplayer不能正常运行。

Ubuntu和Windows屏幕偏移问题"完美"解决方案

Windows下借助软件修正屏幕位置


FX5200显卡、PHLIPS 107T显示器,装好8.04后分辨率1024×768@85很正常,但就是屏幕左移半厘米左右,装好驱动倒是可以解决屏幕偏移问题,3D效果也可以用,但无奈受限驱动在1024×768的分辨率下刷新率只有56-60,显卡是自动检测的,手动选定时候却没有PHLIP 107T的型号,可以用107S和109S的设置,但刷新率最高也只有75,实际情况却跟60的刷新率没多大差别,还不如不要驱动呢,毕竟3D效果对于大多人来说只是个花瓶而已。
如此google了不知多少次,也请教了不少人,可就是解决不了这个问题,无奈之下只有用显示器OSD来调节,这样Ubuntu虽然可以了Windows系统下当然就向右钻了进去,也许是咱的显卡和显示器太烂吧,呵呵,想必同病相怜者也不会少 ^_^


既然Ubuntu下不行,也只有退而来鼓捣Windows了,还好老天不负有心人,终于给我找到一款调节屏幕的软件→→→PowerStrip,其最新版本是PowerStrip v3.78 Build 616

软件虽小功能却很强,可以用来显卡软超频,调节屏幕偏移只是其一个附带功能而已,如此却有牛刀杀鸡之嫌,不过只要解决问题就行了,其多国语言版的装好也不过2M左右,其实此软件只需PStrip.exe和PSdesk.dll就能运行,不过最好是用安装版,毕竟要读驱动的东西,也别太追求绿色喽


安装运行后点右键→显示器设定→设定→进阶时序选项→位置和尺寸→效果看附件,哈哈,不用教了吧
按自己需求调节好以后点右键→选项→偏好设定
在选项里边把Windows启动时自动运行和启动时恢复预定值打上勾
在模块里边把出显示器控制除外的取消勾选可以稍微提高一点启动速度
如此以后只要启动Windows软件就会自动运行并恢复你设定的值,运行软件调节显示器偏移以后也可以点退出,当然设置仍然保存的,还有个小问题就是这个软件启动速度较慢,因为其功能强大要读好多东西,不过这已经很不错了。




呵呵,如此解决屏幕偏移问题虽然不算完美的方法,但最起码简便易行,为Ubuntu屏幕偏移问题花费了好多时间累的不行可还是竹篮打水一场空,还好Windows下有这好的软件,这样也不失为一个可行的方法。

Ubuntu8.04初体验

由于学习QT的需要,最近忙着装LINUX,刚开始从硬盘装了Red hat enterprise server5,恩,发觉这个系统不行,缺点是由于是服务器版本的,在硬件的需求上会比较高,所以会比其他的个人用户桌面或者工作站版本的要卡一点。最重要的是不能更新。还有上面自带的QT和KDEVELOP版本比较低,QT是3.3的,也就是说我还要去给它安装新的软件,很费力费时。并且,默认的内核不支持NTFS文件系统的访问,要访问NTFS还要麻烦一些时间,所以我最后放弃了。


然后装了Fedora9,这款今年5月出来的个人用户操作系统是比较不错的,速度很快,界面也很友好,自带的QT和KDEVELOP版本都是很新的,我不用自己去安装新的,而且官方支持软件更新,并且可以很容易地访问NTFS文件系统(已安装了NTFS-3G)。唯一的问题是:1.对中文的支持不太好,即使安装了中文的编码和输入法,在显示器上也会比较难看,哎,很麻烦,我最讨厌麻烦!2.会出现字体模糊的情况。不知道是系统的问题还是字体的问题还是系统对硬件兼容的问题,打开KDEVELOP和QT都会出现字体模糊的显示,比较严重,花了两天的时候海搜解决办法无果,只得放弃。


然后装了Ubuntu的desk-top版本,看起来真的不错,暂时没发现什么大的、严重的缺点。


恩,然后花了点时间去刻了张盘,3.7G的DVD Ubuntu8.04的。


它自持免费更新,而且很重要的电子科技大学有免费的更新远源,西华这边下载是不算校园网上网流量的


界面也比较不错,我刚安装好后就更新了一大堆软件,而且管它三七二十一把内核全部都更新了,我晕…最后只用了最新的21。


电子科大UBUNTU更新源: http://ubuntu.uestc.edu.cn/

Ubuntu 8.04 Hardy Heron

deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy-backports main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ hardy-updates main restricted universe multiverse


ubuntu更新源地址在系统上的存储文件位置是: /etc/apt/sources.list

可以使用以下命令来完成:


打开终端,
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup         “备份原文件”
sudo gedit /etc/apt/sources.list
打开gedit后,将源地址粘贴过去,保存.
然后打开新立得,点更新(reload),就ok了



另外在我把KDE环境的更新内容全部更新之后(总共有700多MB,下了几分钟),进入KDE环境后再转入GNOME就会发现屏幕的分辨率变成600X420(好象是这个数字,没太注意)不能调了。我极puzzlled,在绝望准备把KDE环境软件全部删除之际,在网上找到了解决办法。或许这是ubuntu的一个小BUG。


1. /etc/usplash.conf
设置成你想要的就是了,也可以卸掉它,有时给它当住了,都不知道系统在做什么。

2. /etc/X11/xorg.conf
修改上面的配置文件里面屏幕的分辨率,我是重新启动系统之后就OK了。




另外一个重要的问题忘了说了,就是在刚开始用的时候总是出现了死机情况(屏幕定形,键盘鼠标不能用,只能直接按reset),后来升级了一下内核,问题没有再出现了,也不知道是什么原因,可能是显卡的驱动不兼容,我的是ATI X550,官方有相应的在LINUX下的驱动程序,并且在硬件驱动里面应该启用ATI图形加速选项。
驱动的安装方法是:
sudo ./ati-driver-installer-8-4-x86.x86_64.run

sudo命令详解

Ubuntu默认不能直接用root帐户登录,必须从第一个创建的用户(既安装时创建的那个用户)通过su或sudo来获得root权限。在Ubuntu中对系统进行操作很多时候都要使用这个命令,由此可见对于新来说很有必要来认识这个命令。这或许不太方便,但这样增加了安全性,避免用户由于误操作而损坏系统。


sudo


格式:sudo [其它命令]

 

sudo既为Super user do的意思。sudo在这个过程中只起一个调用root用户的作用,本次操作完成后,其作用就消失,如果要使用调用root权限操作的命令就必须再次使用sudo。些过程中系统会要求用户输入密码,此密码就是安装系统时你输入你那个密码,注意:这个密码在输入你时候不会像在Windows里输密码那样输入一位密码就有一个*号,这样的目的就是为了使密码更安全,因为不知道你密码有几位这样无疑给密码破译者增加了难度。

 


例:

 

我们要更改当前目录下upload.tar.gz的权限就要用到sudo。如果还要对当前目录下的另外一个文件eva.tar.gz更改权限就要再次用到sudo。

 

ownlinux@server:/var/www$ sudo chmod 777 upload.tar.gz
[sudo] password for ownlinux: (此时输入你的密码)
ownlinux@server:/var/www$ sudo chmod 777 eva.tar.gz
[sudo] password for ownlinux:

Fedora9中文输入法安装

[root@localhost ~]# uname -r
2.6.25-14.fc9.i686
[root@localhost ~]# yum install scim-lang-chinese
Loaded plugins: refresh-packagekit
YumRepo Warning: not using ftp, http[s], or file for repos, skipping – <html>
YumRepo Warning: not using ftp, http[s], or file for repos, skipping – <head>
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 241, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 116, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 307, in doCommands
    self._getTs()
  File "/usr/lib/python2.5/site-packages/yum/depsolve.py", line 98, in _getTs
    self._getTsInfo()
  File "/usr/lib/python2.5/site-packages/yum/depsolve.py", line 104, in _getTsInfo
    self._tsInfo.setDatabases(self.rpmdb, self.pkgSack)
  File "/usr/lib/python2.5/site-packages/yum/__init__.py", line 576, in <lambda>
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.5/site-packages/yum/__init__.py", line 419, in _getSacks
    self.repos.populateSack(which=repos)
  File "/usr/lib/python2.5/site-packages/yum/repos.py", line 245, in populateSack
    sack.populate(repo, mdtype, callback, cacheonly)
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 149, in populate
    if self._check_db_version(repo, mydbtype):
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 203, in _check_db_version
    return repo._check_db_version(mdtype)
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 928, in _check_db_version
    repoXML = self.repoXML
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 1086, in <lambda>
    repoXML = property(fget=lambda self: self._getRepoXML(),
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 1078, in _getRepoXML
    self._loadRepoXML(text=self)
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 1068, in _loadRepoXML
    return self._groupLoadRepoXML(text, ["primary"])
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 1052, in _groupLoadRepoXML
    if self._commonLoadRepoXML(text):
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 904, in _commonLoadRepoXML
    result = self._getFileRepoXML(local, text)
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 772, in _getFileRepoXML
    cache=self.http_caching == ‘all’)
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 643, in _getFile
    result = self.grab.urlgrab(relative, local,
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 463, in <lambda>
    grab = property(lambda self: self._getgrab())
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 458, in _getgrab
    self._setupGrab()
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 447, in _setupGrab
    self._grab = mgclass(self._grabfunc, self.urls,
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 548, in <lambda>
    urls = property(fget=lambda self: self._geturls(),
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 545, in _geturls
    self._baseurlSetup()
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 514, in _baseurlSetup
    self.mirrorurls = self._replace_and_check_url(mirrorurls)
  File "/usr/lib/python2.5/site-packages/yum/yumRepo.py", line 536, in _replace_and_check_url
    print ‘YumRepo Warning: not using ftp, http[s], or file for repos, skipping – %s’ % (url)
  File "/usr/lib/python2.5/codecs.py", line 303, in write
    data, consumed = self.encode(object, self.errors)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xd0 in position 78: ordinal not in range(128)
[root@localhost ~]# yum clean all
Loaded plugins: refresh-packagekit
Cleaning up Everything
[root@localhost ~]# yum install scim-lang-chinese
Loaded plugins: refresh-packagekit
fedora                                                   | 2.4 kB     00:00   
primary.sqlite.bz2                                       | 6.1 MB     02:38    
updates                                                  | 2.3 kB     00:00    
primary.sqlite.bz2                                       | 2.3 MB     04:54    
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
–> Running transaction check
—> Package scim-lang-chinese.i386 0:1.4.7-23.fc9 set to be updated
–> Processing Dependency: scim-chewing for package: scim-lang-chinese
–> Processing Dependency: scim-bridge-gtk for package: scim-lang-chinese
–> Processing Dependency: scim-tables-chinese for package: scim-lang-chinese
–> Processing Dependency: scim-python-pinyin for package: scim-lang-chinese
–> Running transaction check
—> Package scim-chewing.i386 0:0.3.1-13.fc9 set to be updated
–> Processing Dependency: libscim-1.0.so.8 for package: scim-chewing
–> Processing Dependency: libchewing.so.3 for package: scim-chewing
–> Processing Dependency: libscim-1.0.so.8(LIBSCIM_1.0) for package: scim-chewing
–> Processing Dependency: libscim-gtkutils-1.0.so.8 for package: scim-chewing
–> Processing Dependency: scim for package: scim-chewing
—> Package scim-tables-chinese.i386 0:0.5.8-3.fc9 set to be updated
–> Processing Dependency: scim-tables = 0.5.8 for package: scim-tables-chinese
—> Package scim-bridge-gtk.i386 0:0.4.15-5.fc9 set to be updated
–> Processing Dependency: scim-bridge = 0.4.15-5.fc9 for package: scim-bridge-gtk
—> Package scim-python-pinyin.i386 0:0.1.13rc1-1.fc9 set to be updated
–> Processing Dependency: scim-python = 0.1.13rc1-1.fc9 for package: scim-python-pinyin
–> Running transaction check
—> Package scim.i386 0:1.4.7-23.fc9 set to be updated
–> Processing Dependency: im-chooser for package: scim
—> Package scim-bridge.i386 0:0.4.15-5.fc9 set to be updated
—> Package scim-tables.i386 0:0.5.8-3.fc9 set to be updated
—> Package libchewing.i386 0:0.3.0-10.fc9 set to be updated
—> Package scim-libs.i386 0:1.4.7-23.fc9 set to be updated
—> Package scim-python.i386 0:0.1.13rc1-1.fc9 set to be updated
–> Running transaction check
—> Package im-chooser.i386 0:1.2.0-1.fc9 set to be updated
–> Processing Dependency: libimsettings.so.2 for package: im-chooser
–> Processing Dependency: imsettings >= 0.101.0 for package: im-chooser
–> Running transaction check
—> Package imsettings.i386 0:0.101.3-2.fc9 set to be updated
—> Package imsettings-libs.i386 0:0.101.3-2.fc9 set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 scim-lang-chinese       i386       1.4.7-23.fc9     fedora             25 k
Installing for dependencies:
 im-chooser              i386       1.2.0-1.fc9      updates            72 k
 imsettings              i386       0.101.3-2.fc9    updates           140 k
 imsettings-libs         i386       0.101.3-2.fc9    updates            52 k
 libchewing              i386       0.3.0-10.fc9     fedora            2.7 M
 scim                    i386       1.4.7-23.fc9     fedora            563 k
 scim-bridge             i386       0.4.15-5.fc9     fedora            100 k
 scim-bridge-gtk         i386       0.4.15-5.fc9     fedora             40 k
 scim-chewing            i386       0.3.1-13.fc9     fedora             63 k
 scim-libs               i386       1.4.7-23.fc9     fedora            411 k
 scim-python             i386       0.1.13rc1-1.fc9  updates           178 k
 scim-python-pinyin      i386       0.1.13rc1-1.fc9  updates            14 M
 scim-tables             i386       0.5.8-3.fc9      updates           326 k
 scim-tables-chinese     i386       0.5.8-3.fc9      updates           5.9 M
Transaction Summary
=============================================================================
Install     14 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        
Total download size: 25 M
Is this ok [y/N]: y
Downloading Packages:
(1/14): scim-tables-0.5.8-3.fc9.i386.rpm                 | 326 kB     01:03    
(2/14): scim-python-0.1.13rc1-1.fc9.i386.rpm             | 178 kB     00:19    
(3/14): im-chooser-1.2.0-1.fc9.i386.rpm                  |  72 kB     00:11    
(4/14): scim-libs-1.4.7-23.fc9.i386.rpm                  | 411 kB     00:07    
(5/14): imsettings-libs-0.101.3-2.fc9.i386.rpm           |  52 kB     00:05    
(6/14): imsettings-0.101.3-2.fc9.i386.rpm                |    0 B     01:15   
http://ftp.riken.jp/Linux/fedora/updates/9/i386/imsettings-0.101.3-2.fc9.i386.rpm: [Errno 4] Socket Error: timed out
Trying other mirror.
(6/14): imsettings-0.101.3-2.fc9.i386.rpm                |  24 kB     01:37    
http://mirror.yandex.ru/fedora/linux/updates/9/i386/imsettings-0.101.3-2.fc9.i386.rpm: [Errno 4] Socket Error: timed out
Trying other mirror.
(6/14): imsettings-0.101.3-2.fc9.i386.rpm                | 140 kB     00:13    
(7/14): scim-chewing-0.3.1-13.fc9.i386.rpm               |  63 kB     00:03    
(8/14): scim-bridge-0.4.15-5.fc9.i386.rpm                | 100 kB     00:05    
(9/14): scim-lang-chinese-1.4.7-23.fc9.i386.rpm          |  25 kB     00:01    
(10/14): scim-python-pinyin-0.1.13rc1-1.fc9.i386.rpm     | 6.7 MB     08:41    
ftp://seeder.yandex.net/fedora/linux/updates/9/i386/scim-python-pinyin-0.1.13rc1-1.fc9.i386.rpm: [Errno 4] Socket Error: timed out
Trying other mirror.
(10/14): scim-python-pinyin-0.1.13rc1-1.fc9.i386.rpm     | 9.5 MB     05:56    
ftp://dispenser.yandex.net/fedora/linux/updates/9/i386/scim-python-pinyin-0.1.13rc1-1.fc9.i386.rpm: [Errno 4] Socket Error: timed out
Trying other mirror.
(10/14): scim-python-pinyin-0.1.13rc1-1.fc9.i386.rpm     | 9.9 MB     01:12    
http://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/9/i386/scim-python-pinyin-0.1.13rc1-1.fc9.i386.rpm: [Errno 4] Socket Error: timed out
Trying other mirror.
(10/14): scim-python-pinyin-0.1.13rc1-1.fc9.i386.rpm     |  14 MB     06:17    
(11/14): libchewing-0.3.0-10.fc9.i386.rpm                | 2.7 MB     02:12    
(12/14): scim-1.4.7-23.fc9.i386.rpm                      | 563 kB     00:14    
(13/14): scim-bridge-gtk-0.4.15-5.fc9.i386.rpm           |  40 kB     00:01    
(14/14): scim-tables-chinese-0.5.8-3.fc9.i386.rpm        | 5.9 MB     07:40    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: scim-libs                    ####################### [ 1/14]
  Installing: imsettings-libs              ####################### [ 2/14]
  Installing: imsettings                   ####################### [ 3/14]
  Installing: im-chooser                   ####################### [ 4/14]
  Installing: scim                         ####################### [ 5/14]
  Installing: scim-bridge                  ####################### [ 6/14]
  Installing: scim-bridge-gtk              ####################### [ 7/14]
  Installing: scim-python                  ####################### [ 8/14]
  Installing: scim-tables                  ####################### [ 9/14]
  Installing: libchewing                   ####################### [10/14]
  Installing: scim-tables-chinese          ####################### [11/14]
  Installing: scim-python-pinyin           ####################### [12/14]
  Installing: scim-chewing                 ####################### [13/14]
  Installing: scim-lang-chinese            ####################### [14/14]
Installed: scim-lang-chinese.i386 0:1.4.7-23.fc9
Dependency Installed: im-chooser.i386 0:1.2.0-1.fc9 imsettings.i386 0:0.101.3-2.fc9 imsettings-libs.i386 0:0.101.3-2.fc9 libchewing.i386 0:0.3.0-10.fc9 scim.i386 0:1.4.7-23.fc9 scim-bridge.i386 0:0.4.15-5.fc9 scim-bridge-gtk.i386 0:0.4.15-5.fc9 scim-chewing.i386 0:0.3.1-13.fc9 scim-libs.i386 0:1.4.7-23.fc9 scim-python.i386 0:0.1.13rc1-1.fc9 scim-python-pinyin.i386 0:0.1.13rc1-1.fc9 scim-tables.i386 0:0.5.8-3.fc9 scim-tables-chinese.i386 0:0.5.8-3.fc9
Complete!
[root@localhost ~]# reboot

Linux Yum命令

一. yum是什么
yum = Yellow dog Updater, Modified
主要功能是更方便的添加/删除/更新RPM包.
它能自动解决包的倚赖性问题.
它能便于管理大量系统的更新问题
注:为什么要使用yum而不用apt,最简单的原因,Fedora自带

二. yum特点
*可以同时配置多个资源库(Repository)
*简洁的配置文件(/etc/yum.conf)
*自动解决增加或删除rpm包时遇到的倚赖性问题
*使用方便
*保持与RPM数据库的一致性

三. yum安装
Fedora自带
#rpm -ivh yum-2.0.4-2.noarch.rpm

四. yum配置
注:修改和增加配置文件中的资源库,加快下载速度和拥有更多可更新的rpm包
将/etc/yum.conf的内容全部替换为
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=fedora-release
tolerant=1
exactarch=1

[fedora-us-1]
name=Fedora Core 1 — Fedora US mirror
baseurl=ftp://mirrors.kernel.org/fedora.us/fedora/fedora/1/i386/yum/os

[fedora-us-1-updates]
name=Fedora Core 1 updates — Fedora US mirror
baseurl=ftp://mirrors.kernel.org/fedora.us/fedora/fedora/1/i386/yum/updates

[fedora-us-1-stable]
name=Fedora Linux (stable) for Fedora Core 1 — Fedora US mirror
baseurl=ftp://mirrors.kernel.org/fedora.us/fedora/fedora/1/i386/yum/stable

[freshrpms]
name=Fedora Linux $releasever – $basearch – freshrpms
baseurl=http://ayo.freshrpms.net/fedora/linux/$releasever/$basearch/freshrpms

五. yum应用
注:当第一次使用yum或yum资源库有更新时,yum会自动下载所有所需的headers放置于/var/cache/yum目录下,所需时间可能较长.

检查有哪些可更新的rpm包
#yum check-update

安装rpm包,使xmms可以播放mp3
#yum install xmms-mp3

安装mplayer,同时自动安装相关的软件
#yum install mplayer

删除licq包,同时删除与该包有倚赖性的包
#yum remove licq
注:同时会提示删除licq-gnome,licq-qt,licq-text,非常方便

系统更新(更新所有可以升级的rpm包,包括kernel)
#yum -y update

每天定期执行系统更新
#chkconfig yum on
#service yum start

六. yum指令详解
*rpm包的更新

检查可更新的rpm包
#yum check-update

更新所有的rpm包
#yum update

更新指定的rpm包,如更新kernel和kernel source
#yum update kernel kernel-source

大规模的版本升级,与yum update不同的是,连旧的淘汰的包也升级
#yum upgrade

*rpm包的安装和删除

安装rpm包,如xmms-mp3
#yum install xmms-mp3

删除rpm包,包括与该包有倚赖性的包
#yum remove licq
注:同时会提示删除licq-gnome,licq-qt,licq-text

*yum暂存(/var/cache/yum/)的相关参数
清除暂存中rpm包文件
#yum clean packages

清除暂存中rpm头文件
#yum clean headers

清除暂存中旧的rpm头文件
#yum clean oldheaders

清除暂存中旧的rpm头文件和包文件
#yum clean 或#yum clean all
注:相当于yum clean packages + yum clean oldheaders

*rpm包列表

列出资源库中所有可以安装或更新的rpm包
#yum list

列出资源库中特定的可以安装或更新以及已经安装的rpm包
#yum list mozilla
#yum list mozilla*
注:可以在rpm包名中使用匹配符,如列出所有以mozilla开头的rpm包

列出资源库中所有可以更新的rpm包
#yum list updates

列出已经安装的所有的rpm包
#yum list installed

列出已经安装的但是不包含在资源库中的rpm包
#yum list extras
注:通过其它网站下载安装的rpm包

*rpm包信息显示(info参数同list)

列出资源库中所有可以安装或更新的rpm包的信息
#yum info

列出资源库中特定的可以安装或更新以及已经安装的rpm包的信息
#yum info mozilla
#yum info mozilla*
注:可以在rpm包名中使用匹配符,如列出所有以mozilla开头的rpm包的信息

列出资源库中所有可以更新的rpm包的信息
#yum info updates

列出已经安装的所有的rpm包的信息
#yum info installed

列出已经安装的但是不包含在资源库中的rpm包的信息
#yum info extras
注:通过其它网站下载安装的rpm包的信息

*搜索rpm包
搜索匹配特定字符的rpm包
#yum search mozilla
注:在rpm包名,包描述等中搜索

搜索有包含特定文件名的rpm包
#yum provides realplay

七. 安全的更新freshrpms.net的rpm包
安装freshrpms.net的GPG key
#rpm –import http://freshrpms.net/packages/RPM-GPG-KEY.txt

编辑/etc/yum.conf,增加以下信息到尾部
[freshrpms]
name=Fedora Linux $releasever – $basearch – freshrpms
baseurl=http://ayo.freshrpms.net/fedora/linux/$releasever/$basearch/freshrpms
gpgcheck=1

注:
检查GPG Key
# rpm -qa gpg-pubkey*

显示Key信息
#rpm -qi gpg-pubkey-e42d547b-3960bdf1

删除Key
#rpm -e gpg-pubkey-e42d547b-3960bdf1