Вы находитесь на странице: 1из 49

IT认证部落 www.8cmd.

com
IT认证部落 www.8cmd.com

作者: 红盟过客 CCIE 理论 RHCE


QQ : 369136929
msn : ccieyc@live.cn
籍贯 :湖北宜昌。 有宜昌的朋友可以一起聊聊技术。
杭州 CCIE 联盟群 40576311
时间: 2008 年 10 月
地点: 浙江杭州
软件:RHEL5.1 Visio 2007 CorelDRAW 12 WPS 2005

RHCE 学习心得

人,一定要靠自己。不管如何艰难,我都不曾放弃!!
这个笔记是我在学习 RHCE 时写的实验笔记。
Linux 学习主要是两方面,一是命令。二是服务。学以致用是最主要的。对于命令,建
议大家只学最实用的参数,LINUX 下面的每个命令有成千上万个参数,没有必要去都学会,
只要学会最常用的命令与参数就够用了。
LINUX 对于大多数朋友来说,还不是很了解,大家所知道的关于 linux 运行最多的肯定
是在于防火墙,高端的路由与交换方面的配置。我在学习 linux 时开始学习是感觉到很艰难 ,
原因就在于要用另外一种方法与思维去学习一种操作系统。但是当你进入到这个学习空间
后,你就会认为你物有所值,我学习时间有一年多了,也不是每天都在用这个操作系统 ,
也就是一个星期用上几次,特别是服务配置,学习了很长时间,linux 是网络操作系统 ,那
么它的长处肯定会是在网络方面,而不是个人方面。现在只要安全理念强一点的公司肯定会
使用 linux.因为这一个合格的网络工程师必备的知识与技能。
我是参加培训的,之所以参加培训是因为我原来学习了很长一段时间都没有进入到
linux 门里去,都是在一些桌面上学习,而没有进到内核与服务方面。培训有一个最大的好
处,那就是有什么不懂的问题可以去问老师与同学,这也是我在学习中进步最快的地方。
写笔记与心得已成了我一个很好的习惯,原因很简单,能经常有目地的复习一下我所学
习的内容。心得能记当自己当时在学习时所遇到的一些问题与经验,每当自己回过头来看自
己的笔记,或是从朋友那里得知他们从笔记中学到知识时,也特别的高兴。所以我一直坚持 。
我一直不敢说自己是一个高手,我认为一个真正的高手就是不断的挑战自我。就像我
在一次做网络工程时,遇到一个集团公司的高级工程师一样 ,那位工程师早以白发,但是
仍然坚持看书,不断学习。
QQ 群里有大家聊的开兴的朋友与我的学生,有兴趣的朋友可以加进去学习一些思科
方面与 linux 方面的知识.
在我写完很多笔记后,也认识了很多学生和朋友。能给他们在学习时指点一二也是一
种很快乐的事情。因为我也曾经像他们一样,在学习时遇到很多困难但是找不到帮助的人,
我只不过做了一个曾经想做的事情。
其实,份笔记在 07 年 8 月份的时候就写好了,但是一直到 08 年 3 月我还在修改中,
原因很简单,我想写一分高水平,高质量的 hrce 笔记,所以一直在不断的修改与润色中。
金无足赤,人无完人,这份笔记中肯定有不足与错误之外,希望有心的朋友指出。在写这份
IT认证部落 www.8cmd.com

笔记的时候,得到了我的学生的大力帮助,在这里一并帮示感谢。在这里说明一下适合 0
基础但是喜欢 rhce 的朋友学习 linux 的方法,推荐先看十遍台湾台的 RHCE 教程有
7cd,verycd 上有的下,然后是十遍 chinaitlab 出的 rhce 课程,台湾讲命令讲的相当好,
并且一步一步讲的相当基础,而 itlab 讲的是实战,讲到在工作中如何使用 linux,需要有一
定的基础才能听懂,如果你每个课程都能听到十遍,那么你对 linu 应当有相当的精通。linux
如果按我说明的方法,先看视频,最后对着我的实验笔记去学习,自学过 rhce 没有什么问
题。
写在最后:这个笔记是我的学习 linux 的一些实验,肯定会有一些不完善与错误,希
望有心的朋友指出。

我与 linux 的故事

Great hopes make great man. 远大的希望造就伟大的人。


Success belongs to the persevering. 胜利属于坚忍不拔的人。

大约在 99/%的人在装好 RHEL 后第一件事情是打开 gnome 或是 kde 想上网隐聊天,


或是想看看电影,但是当你发现你在用 linu 的时候会出现下面的事实:分编率只有 800*600.
本来你在 xp 下面是 1024*768.或是你是宽屏的:是 1280*800 现在也只有 1024*768.发现
在 linux 下面的图标特别大,很模糊。
当你想听歌的时候,发现在 RHEL 下没有软件,在网上找了半天,终于找到一软件,
是源码的,上面写了很多命令,你根本看不懂。在 xp 下面 只要 setup 点一下,就可以听
歌看电影了,在 RHEL 下面你找到一个软件是这样了。当你想上 QQ 与朋友聊天的时候,你
发现没有这个软件。当然,8 月分小马同志终于有了 linux 下面的 QQ。当你想下载安装的
时候,发现又是 rpm 的,你不过是刚装好,你也不懂命令。想玩玩游戏吧,找不到软件。
最让你难受的是分辩率太低,眼睛太难受了。当你装好 RHEL 后发现在 xp 下面最基本
的东东,看电影,听歌,上 QQ,玩游戏,装视频驱动,你一样也不会,一个软件找了几天
也没有找到,找到也装不上去。这在 linux 下面是常见的事情了。这时候,大约有 99%人 ,
会在一天后装回 xp。或许还有一部分在文字界面下面学习命令,学习服务,但是只是认为
RHEL 就是用在服务器上面的,一点也不像 xp 那样:友好。你在想,如果在 RHEL 下面一边
听歌一边看电影,一边学习命令,是多么爽的事情了,歌也听了,命令也学会了。服务也搞
定了。不是有很多 RHEL 的视频吧,一边在 RHEL 上面看一边练习,多爽啊。
确实。linux 的软件安装对于新手来说是一件非常痛苦的事情了,难到装 RHEL 就只能
学习服务与命令吧吗,不能一边学习一边玩吗。答案是可以的了,并且,当你认真看完我写
的下面的软件安装与实验后,你会发现,RHEL 的效率非常的高,在 xp 下面要关机,有时
候会等上十几秒,在 linux 下面一个 init 0 命令,让你体会到什么叫做作操作系统的真正主
人。不会让你等 1 秒。
前一段时间,我在 RHEL 下面用 realplay 看电影,朋友过来看到了,很羡慕,说,RHEL
也能听歌看电影啊,不错,不过,我原来装了很长时间也一直没有搞好了,下载的是一个.bin
的软件,这个到底怎么安装啊。当我把这个软件演示给他看以后,他兴奋的不得了,说原来
这么简单了。我也换成 linux 的。
你会发现,你爱上了 linux.特别是当你一边听歌一边看视频然后一边学习 iptables 防火
墙的时候是多么惬意的事情。没有比边玩边学习更爽的事情了。
IT认证部落 www.8cmd.com

在这里想说明是对于学习 linux 的朋友,我想说,还是装 RHEL 吧,虽然有很多朋在用


fc,或是其它的。我主要想说的是,对于 rhce 来说,主要是服学如何配置服务,rhce 里考
到的有 7 种常用服务,而当你装 RHEL 的时候,可以边学习学玩,主要是对 inux 有 兴 趣 ,
当你能在 linux 下做 xp 任何想做的事情的时候,你就有学习的动力了,不然会一直停在怎
么样安装 linux 等或是一些命令的事情上的。
请记住下面的事实:linux 是用的非常多的一种操作系统。曾经我学生问过:为什么我
接触的客户都是用的 windowns。是不是 linux 太少了。我说:那是因为你接触的客户档次
比较低。虽然是一句笑话,但是却是事实。我是非常佩服李阳,李阳曾说过,你之所以不能
脱口而出英语,那是因为你说的不够多。有一次去帮朋友搞一个防火墙,是一家外企,里面
有 400 多台 pc,网管说,有 8 成全部都是 redhat 的 linux。所有的服务都是那个网管自己
配置的,当时我是相当佩服这位网管的,没有话说,有的网管 400 多台 xP 都把它搞的焦头
烂额,更不用说 linux。里面还有 hp 的 unix,SUN 的 UNIX 操作系统 solaris 10 。 等 等 。
所以我想说的是,linux 用的真的是多得不得了,我去过数不清的机房,里面没有看到一台
windown 的机器。当然了,这个网管的工资也是以万为单位的。兄弟,如果也想拿到这么
高的 memoy,除了把 linux 学好以外,还有什么选择了。当然了,这只是自己的一点想法 ,
当做参考。
RHEL5.2 下载地址
http://lib.verycd.com/2008/05/25/0000189555.html
我的是 5.1 下载地址
http://lib.verycd.com/2007/11/10/0000170314.html
安装方法就不说了,太简单了,全中文的没有什么难的,记得把 gnome 或是 kde 桌面
安装上去,因为我主要是写的在这两个上面安装软件。
在这里推荐两本书吧。一本是专门讲系统的《天下没有难学的 Linux》

一本是专门讲服务的《Linux 服务器配置与应用(第 2 版》

让我们来做吧。

已完工的作品
《2009 mpls vpn 自学命令配置排错》 第一版
《2009 3560 交换机自学命令与配置》 第一版
《2008 vpn 自学命令与配置》 第一版
《2008 ospf 命令与配置手册实验笔记》第二版
《2008 bgp 命令与配置手册实验笔记》第二版
《2009 ISIS 命令与配置手册实验笔记》 第一版
《2008 三层交换与路由综合配置案例》
《RHCE5.0 实验手册》
《华为 3600 交换机实验笔记》
《BGP 设计与实现笔记》
《JUNIPER NETSCREEN 防火墙基础实验》
《杭州某中学断网解决办法》

2008 年十月于杭州
IT认证部落 www.8cmd.com

第一章 基础命令

[root@CCIE /]# adduser

增加一个系统用户 useradd 与 adduser 是一样的命令,都是增加一个用户。

[root@CCIE /]# useradd ccna

[root@CCIE /]# adduser ccnp

当前用户,主机名,当前目录。超级用户为#,一般用户为$

[root@CCIE ~]#

当前账户路径。~表示用户 home 目录.root 的 home 为/root

增加一个用户 ccne 并将其增加到 root 组中。注意-g 是将一个用户放到什么组中。

[root@CCIE /]# useradd -g root ccne

[root@CCIE home]# ls -l

总计 16

drwx------ 3 ccie ccie 4096 08-20 00:01 ccie

drwx------ 3 ccna ccna 4096 08-20 16:22 ccna

drwx------ 3 ccne root 4096 08-20 16:23 ccne

drwx------ 3 ccnp ccnp 4096 08-20 16:22 ccnp

增加一个系统用户 ccie 注意-r

[root@CCIE /]# useradd -r ccie

增加一个系统用户 aa 并批定目录为/home/aa

[root@CCIE /]# useradd -d /home/aa aa

更改删除用户

[root@CCIE ~]# userdel 用户名

记录用户密码

[root@CCIE ~]# more /etc/passwd

默认密码存放在

[root@CCIE ~]# vi /etc/shadow

组管理

[root@CCIE ~]# vi /etc/group

arpm 电源管理

笔记本没有用电池

IT认证部落 www.8cmd.com

[root@CCIE /]# apm

No APM support in kernel

指定,选项和参用空格格开

[root@CCIE /]# ls -l |less

许多选项前加--

[root@CCIE /]# ls --help

Man 的数字 1 表示用户指令。5 表示文件帮助

[root@CCIE /]# man 1 passwd

[root@CCIE /]# man 5 passwd

显示剩余电量

[root@CCIE /]# apm -m

显示当前系统体系结构

[root@CCIE /]# arch

i686

将程序放在后台

[root@CCIE home]# bg

切换目录

[root@CCIE home]# cd

[root@CCIE ~]# cd ..

[root@CCIE /]# cd .

[root@CCIE /]# cd

[root@CCIE ~]#

设置自己的 finger 消息。

[root@CCIE ~]# chfn

[root@CCIE ~]# chfn

Changing finger information for root.

Name [chfn]:

Office []:

Office Phone []:

Home Phone []:

Finger information not changed.

查看可用的 shell

[root@CCIE ~]# chsh -l

/bin/sh

/bin/bash

IT认证部落 www.8cmd.com

/sbin/nologin

/bin/tcsh

/bin/csh

/bin/ksh

/bin/zsh

改变当前的 shell

[root@CCIE ~]# chsh

Changing shell for root.

New shell [/bin/bash]:

通过-s 也可以改变当前的 shell

[root@CCIE /]# chsh -s /bin/bash

Changing shell for root.

Shell changed.

[root@CCIE /]# chsh

Changing shell for root.

New shell [/bin/bash]:

创建一个文件 touch

[root@CCIE wa]# touch ccie

[root@CCIE wa]# ls

a b ccie

清除当前的屏幕

[root@CCIE ~]# clear

显示当前的时间

[root@CCIE /]# date

2008 年 08 月 20 日 星期三 17:05:07 CST

显示当前的文字

[root@CCIE /]# echo

[root@CCIE /]# echo hello

hello

删除一个文件 rm

[root@CCIE wa]# rm ccie

rm: remove regular empty file `ccie'? y

[root@CCIE wa]# ls

a b

移动并重命名 mv

[root@CCIE wa]# mv ccie ccnp

IT认证部落 www.8cmd.com

[root@CCIE wa]# ls
a b ccnp

考贝一个文件到另外一文件 cp
[root@CCIE ccie]# cp vi /home/ccnp
以/开头是绝对路径,没有/的是相对路径。由实际位置定。
Cd 回到 home 目录。Cd ..回到根目录。Cd 回到上一级目录。
[root@CCIE ~]# cd /
[root@CCIE /]# cd
[root@CCIE ~]#

执行命令后退出
[root@CCIE ~]# exec
[root@CCIE ~]# exec ls

删除一个新的空的目录 rmdir
[root@CCIE home]# rmdir ccnp

强制删除一个有文件的文件夹 rm -rf
[root@CCIE home]# rm -rf ccnp

退出命令
[root@CCIE ~]# exit

显示系统完整信息
[root@CCIE ~]# uname -a
Linux CCIE 2.6.9-5.EL #1 Wed Jan 5 19:22:18 EST 2005 i686 i686 i386 GNU/Linux

显示主机名
[root@CCIE ~]# hostname
CCIE

显示主机名地位置
[root@CCIE home]# more /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=CCIE

更改主机名
[root@CCIE ~]# vi /etc/sysconfig/network

列出执行过的指令
[root@CCIE ~]# fc -l

将后台的任务拉到前台
IT认证部落 www.8cmd.com

[root@CCIE /]# fg
-bash: fg: current: no such jo

查看虚拟终端的数目
[root@CCIE /]# fgconsole
1
[root@CCIE /]#

Linux 中所有的设备都文件
[root@CCIE dev]# ls -l |less
brw-rw---- 块文件 可以随时读写,硬盘光盘。B 表示

crw-rw---- 字符文件 比如串口 c 表示。

查看登录用户的消息
[root@CCIE /]# finger -l
Login: root Name: chfn
Directory: /root Shell: /bin/bash
On since Wed Aug 20 16:04 (CST) on tty1 1 hour 5 minutes idle
On since Wed Aug 20 17:08 (CST) on pts/0 from 192.168.1.101
No mail.
No Plan.

显示指定的用户信息
[root@CCIE /]# finger -m ccie
Login: ccie Name: (null)
Directory: /home/ccie Shell: /bin/bash
Never logged in.
No mail.
No Plan

显示内存的消息
[root@CCIE /]# free
total used free shared buffers cached
Mem: 255596 251476 4120 0 47612 153872
-/+ buffers/cache: 49992 205604
Swap: 522104 0 522104

以总和的消息显示内存消息
[root@CCIE /]# free -t
total used free shared buffers cached
Mem: 255596 250064 5532 0 35784 160576
-/+ buffers/cache: 53704 201892
Swap: 522104 0 522104
IT认证部落 www.8cmd.com

Total: 777700 250064 527636


每 4 秒显示一次
[root@CCIE /]# free -s 4
total used free shared buffers cached
Mem: 255596 252008 3588 0 18112 173896
-/+ buffers/cache: 60000 195596
Swap: 522104 0 522104

显示信号
[root@CCIE /]# fuser -l
HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM
STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH IO
PWR SYS
UNUSED

Vi 编辑器
Vi 是一个可视化编辑器,也就是说你所做的改动能直接的看到结果。Vi 有两种模式,命令
模式可以删除,查找等 编辑模式主要是用来编辑文件。用 esc 退回来命令模式
打开一个文件 vi 文件名

[root@CCIE ccie]# ls
a a.tar inittab
[root@CCIE ccie]# vi a
命令参数
保存文件 : w
没有改动退出 :q
有改动退出 : wq 保存改动退出 : q! 不保存改动退出。
:e 文件名, 打开别的文件工始编辑。

编辑 命令参数
i 在当前位子进入到编辑模式
I 光标到行首进到入编辑模式
a 光标退后一格进到编辑模式
A 光示退到行尾进到编辑模式
O《小> 在光标所在行新一行进到编辑模式
O<大> 在光标所在行新起上一行进到编辑模式
S 删除光标所在字进到编辑模式
S 删除光标所在行进到编辑模式

删除命令
X 删除一个字
Nx 删除 n 个字
Dd 删除当前行
Dw 删除到尾
IT认证部落 www.8cmd.com

剪贴
Yy 光标所在行复制
Yw 光标所在词复制
Nyw 光标所在位后 n 个词复制
P 贴在光标位之右 小 p
P 贴在光标位之左 大 p

取消上一个动用
U 取消上一个更新
U 取消所有的更动
Ctrl + r 重新更改
E:! 放弃更新重新更改

显示进程
[root@CCIE /]# fuser -a /root
/root: 4897c

查看 cpu 信息
[root@CCIE /]# cat /proc/cpuinfo

查看输入输出信
[root@CCIE /]# cat /proc/ioports

查看系统运行时间
[root@CCIE /]# cat /proc/uptime

查看系统信息
[root@CCIE /]# cat /proc/version

查看 scsi 信息
[root@CCIE /]# cat /proc/scsi

查看 ide 信息
[root@CCIE /]# cat /proc/ide

查看网络信息
[root@CCIE /]# cat /proc/net

查看核心系统参数
[root@CCIE /]# cat /proc/sys

系统日志存放在/var/log
查看核心启动日志
IT认证部落 www.8cmd.com

[root@CCIE log]# more /var/log/dmesg

查看系统报错日志
[root@CCIE log]# more /var/log/messages

查看邮件日志
[root@CCIE log]# more /var/log/maillog

直接用指令查看
[root@CCIE /]# dmesg

查看 ftp 日志 用于记录 ftp 服务信息


[root@CCIE /]# cat /var/log/xferlog

查看安全信息日志 记录与系统相关的信息
[root@CCIE /]# more /var/log/secure

查看登录日志
[root@CCIE /]# more /var/log/wtmp
杀死与 root 相关的进程
[root@CCIE /]# fuser -k /root
/root: 4897c

查看用户的密码文件
[root@CCIE /]# more /etc/passwd
[root@CCIE /]# more /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
IT认证部落 www.8cmd.com

nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
rpm:x:37:37::/var/lib/rpm:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
netdump:x:34:34:Network Crash Dump user:/var/crash:/bin/bash

解释
Login name 登录用户名
Passwd 密码
Uid 用户编号
Gid 所在组编号
Full name 用户全名
Home directory 用户主目录
Shell 用户默认的 shell

创建一个 ccie 新组
[root@CCIE /]# groupadd ccie

删除一个 ccie 组
[root@CCIE /]# groupdel ccie

重启 需要账户为 root
[root@CCIE ~]# reboot
[root@CCIE ~]# shutdown -r now
[root@CCIE ~]#init 6

关机 需要账户为 root
[root@CCIE ~]# halt
[root@CCIE ~]# shutdown -h now
[root@CCIE ~]# powerofff
[root@CCIE ~]# init 0

关闭系统关关闭电源
[root@CCIE ccie]# halt -p

显示历史命令
[root@CCIE ccie]# history 2
624 history
625 history 2

查看文件类型。
[root@CCIE ccie]# file inittab
inittab: ASCII English text

文件类型
IT认证部落 www.8cmd.com

- 一般文件
D 目录文件
B 块设备文件
C 字符文件
L 链接文件
P 人工管道

文件权限
[root@CCIE home]# ls -l
total 32
drwx------ 2 ccie ccie 4096 Sep 7 10:26 ccie
一个文件总共有 10 种权限属性,第一个表文件类型 2-4 表示用户权限 5-7 组权限 8-10 其
它权限。258 字符控制读权限 369 表示写 4710 表示执行权限
D 表示为目录文件
文件权限分为 r w x 读 写 执行权限。用户权限为 文件所有者 u 文件所属组 g 其它用
户 0

改变权限:只有用户本身与 root 才能修改.

将一个文件名改成只有用户才有读写执行
chmod u=rwx 文件名

将 ccie 文件改成只有读的权限
[root@CCIE home]# chmod u=r 文件名 ccie
[root@CCIE home]# ls -l
total 32
dr--rwxrwx 2 ccie ccie 4096 Sep 7 10:26 ccie
drwx------ 2 wa ccie 4096 Aug 31 15:57 dcj
drwx------ 5 ccie hhh 4096 Aug 19 13:26 redhat
drwx------ 2 500 500 4096 Sep 7 09:39 wa

Chmod <ugoa > =rwx 文件名


U 表示用户本身 g 表示组成员 o 表示其它 a 表示所有的。=表示改后的权限 文件名是要
改的文件的名子。

将文件 ccnp 改为用户与组有执行权限


[root@CCIE home]# chmod ug=x ccnp

数字表示权限
4 读 2 写 1 执行
7=4+2+1 表示读写执行
6 读写
5 读执行
3 写执行
IT认证部落 www.8cmd.com

将一个文件 ccnp 给用户组其它读写执行权限,


[root@CCIE home]# chmod 777 ccnp
[root@CCIE home]# ls -l
total 36
dr--rwxrwx 2 ccie ccie 4096 Sep 7 10:26 ccie
-rwxrwxrwx 1 root root 0 Sep 7 11:27 ccnp

各个位置上没有权限则为 0
[root@CCIE home]# chmod 707 ccnp
[root@CCIE home]# ls -l
total 36
dr--rwxrwx 2 ccie ccie 4096 Sep 7 10:26 ccie
-rwx---rwx 1 root root 0 Sep 7 11:27 ccnp

Chown 用来改变文件拥用者。
将 ccie 这个文件的用户变 ccie 变成 root
[root@CCIE home]# ls -l
total 36
dr--rwxrwx 2 ccie ccie 4096 Sep 7 10:26 ccie

[root@CCIE home]# chown root ccie


[root@CCIE home]# ls -l
total 36
dr--rwxrwx 2 root ccie 4096 Sep 7 10:26 ccie

Chgrp 用来改变所属组。
Chgrp 组名 文件名
文件所有者与 root 用户通过命令来改变所属组。
[root@CCIE ccie]# ls -l
total 8
-rw-r--r-- 1 root root 1666 Sep 7 09:57 inittab

[root@CCIE ccie]# chgrp ccie inittab

[root@CCIE ccie]# ls -l
total 8
-rw-r--r-- 1 root ccie 1666 Sep 7 09:57 inittab

文件名规则:一个文件名最多为 255 个字符。以点开头为隐藏文件。

目录在文件类型上用 d 表示
/表示根目录。对于每个用户都有一个当前目录。
。文件与。。文件。
。表示当前目录的一个硬连结。
IT认证部落 www.8cmd.com

。。表示上一级目录的硬连结。
目录权限:
与文件有相同的权限。读:只可以读取目录内内容
写:执行。有向目录中增加删除权限
执行:进入到目录,调用资料。

如果一个目录只有--x 权限,则无法列出目录内容,但是可以执行等程序。

强制位冒险位
强制位:给一般用户有文件所者相同的权限。
冒险位:一般文件中如果有 w x 则所有的用户都有建立与删除文件能力。但是设置冒险位
后只有文件所有,目录所有与管理员才可能删除文件。

U g 0 分别对应:强制位 Set uid 强制位 set gid 和 sticky 冒险位.设置好以后,强制位会


在 u g 位置上用用一个 s 冒险位会采用 t 表示。强制位在用户 u 中表示为 4 set uid.强制位
在组 g 中表示为 2 set gid 冒险位在其它 0 中表示为 1 sticky.

[root@CCIE ccie]# chmod 1777 inittab


[root@CCIE ccie]# ls -l
total 8
-rwxrwxrwt 1 root ccie 1666 Sep 7 09:57 inittab
[root@CCIE ccie]# chmod 6777 inittab
[root@CCIE ccie]# ls -l
total 8
-rwsrwsrwx 1 root ccie 1666 Sep 7 09:57 inittab
[root@CCIE ccie]# chmod 7777 inittab
[root@CCIE ccie]# ls -l
total 8
-rwsrwsrwt 1 root ccie 1666 Sep 7 09:57 inittab

清除历史命令
[root@CCIE ccie]# history -c
[root@CCIE ccie]# history
1 history

显示用户的 id 与所属组的 id
[root@CCIE ~]# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@CCIE ~]# id -g
0
[root@CCIE ~]# id -G
0 1 2 3 4 6 10
IT认证部落 www.8cmd.com

[root@CCIE ~]# id root

uid=0(root) gid=0(root)

groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)

查看文件 a 的信息

[root@CCIE ccie]# info a

根目录下文件类型

/bin 常用指令

/usr/bin 常用指令

/boot 核心启动文件

/dev 设备文件

/etc 服务与配置文件

/home 个人文件

/lib 库文件与驱动

/usr/lib 库文件驱动。

/lost+found 孤儿文件。

/mnt 常用挂载点

/opt 第三方工具使用目录

/proc 系统信息

/root root 目录

/sbin 系统管理指命令

/tmp 临时文件

/usr 与用户有关的目录

/var 可能会改变的数据。

显示进程间的通信状态

[root@CCIE ccie]# ipcs

------ Shared Memory Segments --------

key shmid owner perms bytes nattch status

------ Semaphore Arrays --------

key semid owner perms nsems

------ Message Queues --------

key msqid owner perms used-bytes messages

[root@CCIE ccie]# ipcs -m -t

------ Shared Memory Attach/Detach/Change Times --------

shmid owner attached detached changed

列出所有的后台进程

IT认证部落 www.8cmd.com

[root@CCIE ccie]# jobs


[root@CCIE ccie]# jobs -l
[root@CCIE ccie]# jobs -p

设备文件的使用
Echo hello > /dev/tty2 在第二个 tty 上显示 hello
Cp /dev/fd0 /dev/fd1 考第一个软驱到第二个软驱
Dd if=/dev/hda of=/root/mbr bs=512 count=1
备份第一个硬盘上的 mbr
Dd 一个强大的拷贝工具
If= 文件名
Of 目标文件名
Bs=xxx 指定块大小
Count=n 指定复制块的数量

输入重定向
用<表示输入源。如 [root@CCIE ccie]# vi < ccie 意思是 vi 这个命令是从 ccie 这个文件
得到的

输出重定向:将输出的结果放到别的文件中
[root@CCIE ccie]# ls -l >a
[root@CCIE ccie]# ls
a inittab.txt
[root@CCIE ccie]# more a
total 12
-rw-r--r-- 1 root root 0 Oct 24 21:53 a
---x--x--- 1 ccie ccie 1666 Oct 24 21:30 inittab

[root@CCIE /]# ls -l >/home/ccie/a 意思:将根目录下的显示输出到/home/ccie/a


这个文件中。

杀死进程
[root@CCIE ccie]# kill 12345

杀死所有的同名进程
[root@CCIE ccie]# killall 1234

查看最后登陆的用户
[root@CCIE ccie]# last

查看最后登陆的主机 ip 地址
[root@CCIE ccie]# last -n 5 -a -i
root pts/0 Wed Aug 20 17:08 still logged in 192.168.1.101
IT认证部落 www.8cmd.com

root pts/0 Wed Aug 20 17:07 - 17:08 (00:00) 192.168.1.101


root pts/0 Wed Aug 20 17:07 - 17:07 (00:00) 192.168.1.101
root pts/0 Wed Aug 20 17:06 - 17:07 (00:00) 192.168.1.101
root pts/0 Wed Aug 20 17:06 - 17:06 (00:00) 192.168.1.101

wtmp begins Tue Aug 19 23:53:01 2008

查看登陆失败的相关消息
[root@CCIE ccie]# lastb
ssh:notty 192.168.1.102 Wed Aug 20 00:00 - 00:00 (00:00)
(unknown :0 Tue Aug 19 23:59 - 23:59 (00:00)

btmp begins Tue Aug 19 23:59:09 2008

重新登陆

[root@CCIE ~]# login

显示登陆帐号消息

[root@CCIE ~]# logname

Root

查看所有的语言支持

[root@localhost ~]# locale -a

将字体变成中文

[root@localhost /]# LANG=zh_CN.gb2312

语言环境默认情况下

[root@localhost /]# ls /etc/sysconfig/i18n

[root@localhost /]# cat /etc/sysconfig/i18n

LANG="zh_CN.UTF-8"

SUPPORTED="zh_CN.UTF-8:zh_CN:zh"

SYSFONT="latarcyrheb-sun16"

修改地址:

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

配置网络另外一个命令

[root@localhost ~]# netconfig ||neat

显示 linux 的内核模块消息

[root@CCIE /]# lsmod

IT认证部落 www.8cmd.com

创建一个字体的文件目录

[root@CCIE ccie]# mkfontdir

[root@CCIE ccie]# ls

a fonts.dir

查看所有的持载

[root@CCIE ccie]# mount -l

/dev/hda1 on / type ext3 (rw) [/]

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

将 u 盘挂载到 mnt/u

[root@CCIE ccie]# mount /dev/sda1 /mnt/u

将已存在的设备重新挂载

[root@CCIE ccie]# mount --bind /mnt/usb /mnt/usb1

配置各种服务

[root@CCIE ccie]# ntsysv

因为第次启动都会查新硬件将会耗费一定时间,关闭硬件检测。

[root@CCIE ~]# chkconfig kudzu off

关闭 sendmail 服务

[root@CCIE ~]# chkconfig sendmail off

关闭防火墙防服

[root@CCIE ~]# chkconfig iptables off

杀死所有的 tty1 下的进程

[root@CCIE etc]# pkill -t tty1

杀死 http 服务

[root@CCIE ~]# killall httpd

显示特定进程的内存消息
[root@CCIE etc]# ps -a
PID TTY TIME CMD
27849 pts/0 00:00:00 bash
IT认证部落 www.8cmd.com

27862 pts/0 00:00:00 bash


27917 pts/0 00:00:00 ps
[root@CCIE etc]# pmap 27849
27849: bash
00227000 104K r-x-- /lib/ld-2.5.so
00241000 4K r-x-- /lib/ld-2.5.so
00242000 4K rwx-- /lib/ld-2.5.so

显示系统状态
[root@CCIE /]# ps
PID TTY TIME CMD
27395 pts/0 00:00:00 bash
27849 pts/0 00:00:00 bash
27862 pts/0 00:00:00 bash
27927 pts/0 00:00:00 ps

显示指定用户的系统进程
[root@CCIE /]# ps -u root

[root@CCIE /]# ps -t tty1


PID TTY TIME CMD
27913 tty1 00:00:00 mingetty

[root@CCIE /]# ps -efww

以树状图型显示
[root@CCIE /]# pstree

[root@CCIE /]# pstree -u

查密码文件
[root@CCIE /]# pwck /etc/passwd
用户 adm:目录 /var/adm 不存在
用户 uucp:目录 /var/spool/uucp 不存在
用户 gopher:目录 /var/gopher 不存在
用户 pcap:目录 /var/arpwatch 不存在
用户 sabayon:目录 /home/sabayon 不存在

查看工作目录
[root@CCIE /]# pwd
/
系统日志
核心起动日志:些日志写在系统每次启动时,包括核心装入时系统所有的输出数据
[root@CCIE ~]# cat /var/log/dmesg
IT认证部落 www.8cmd.com

系统报错日志
[root@CCIE ~]# more /var/log/messages
邮件系统日志
[root@CCIE ~]# more /var/log/maillog
ftp 服务日志
[root@CCIE ~]# more /var/log/xferlog
安全信息与网络信息日志
[root@CCIE ~]# more /var/log/secure

登录记录
[root@CCIE ~]# more /var/log/wtmp

将进程号为 10 的进程改为优先级为 2
[root@CCIE /]# renice 2 -p 10
10: old priority -5, new priority 2

查看模块
[root@CCIE /]# lsmod

删除一个模块
[root@CCIE /]# lsmod -v hid
Usage: lsmod
[root@CCIE /]#

光盘弹出
[root@localhost /]# eject

收回
[root@localhost /]# eject -t

挂载 ntfs 分区
[root@CCIE ~]# mount -t ntfs /dev/hda1 /mnt/u

结示当前 screen 作业
[root@CCIE /]# screen -ls
There is a screen on:
27989.pts-0.CCIE (Attached)
1 Socket in /var/run/screen/S-root.

系统马上关机
[root@CCIE /]# shutdown -h now

休眠
[root@CCIE /]# sleep 1m
IT认证部落 www.8cmd.com

暂停 shell
[root@CCIE /]# suspend

强制暂停 shell
[root@CCIE /]# suspend -f

显示系统进程
[root@CCIE /]# top
[root@CCIE /]# top -c

显示系统信息
[root@CCIE /]# uname
Linux

[root@CCIE /]# uname -a


Linux CCIE 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:12 EDT 2008 i686 i686 i386
GNU/Linux
[root@CCIE /]# uname -m
i686
[root@CCIE /]# uname -n
CCIE
[root@CCIE /]# uname -r
2.6.18-92.el5
[root@CCIE /]# uname -s
Linux
[root@CCIE /]# uname -v
#1 SMP Tue Apr 29 13:16:12 EDT 2008

显示用户
[root@CCIE /]# users
root

显示当前的用户
[root@CCIE /]# w
18:36:47 up 2:36, 2 users, load average: 0.22, 0.05, 0.02
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty2 - 18:36 4.00s 0.07s 0.07s -bash
root pts/1 192.168.1.101:S. 18:25 0.00s 0.35s 0.01s w

[root@CCIE /]# w -f
18:37:14 up 2:37, 2 users, load average: 0.14, 0.04, 0.01
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root tty2 18:36 31.00s 0.07s 0.07s -bash
IT认证部落 www.8cmd.com

root pts/1 18:25 0.00s 0.37s 0.02s w -f


[root@CCIE /]# w -s
18:37:16 up 2:37, 2 users, load average: 0.13, 0.04, 0.01
USER TTY FROM IDLE WHAT
root tty2 - 33.00s -bash
root pts/1 192.168.1.101:S. 0.00s w -s
[root@CCIE /]# w -h
root tty2 - 18:36 35.00s 0.07s 0.07s -bash
root pts/1 192.168.1.101:S. 18:25 0.00s 0.37s 0.01s w -h

将 ls -l 结果标准输出
[root@CCIE /]# watch -d ls -l

查看命令
[root@CCIE /]# which ls
alias ls='ls --color=tty'
/bin/ls

显示用户消息

[root@CCIE /]# who

root tty2 2008-08-20 18:36

root pts/1 2008-08-20 18:25 (192.168.1.101:S.0)

[root@CCIE /]# who -H

NAME LINE TIME COMMENT

root tty2 2008-08-20 18:36

root pts/1 2008-08-20 18:25 (192.168.1.101:S.0)

[root@CCIE /]# who -l -H

NAME LINE TIME IDLE PID COMMENT

LOGIN tty3 2008-08-20 16:01 4835 id=3

LOGIN tty4 2008-08-20 16:01 4836 id=4

LOGIN tty5 2008-08-20 16:01 4837 id=5

LOGIN tty6 2008-08-20 16:01 4838 id=6

LOGIN tty1 2008-08-20 18:37 28110 id=1

[root@CCIE /]# whoami

root

[root@CCIE /]# whois ccie

设置命令的别名

[root@CCIE /]# alias

alias cp='cp -i'

alias l.='ls -d .* --color=tty'

IT认证部落 www.8cmd.com

alias ll='ls -l --color=tty'

alias ls='ls --color=tty'

alias mv='mv -i'

alias rm='rm -i'

alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

[root@CCIE /]# l

bash: l: command not found

[root@CCIE /]# alias a=ls

配置系统的认证消息

[root@CCIE /]# authconfig

列出系统服务的指令

[root@CCIE /]# chkconfig --list

关闭 telnet 服务

[root@CCIE /]# chkconfig telnet off

查看当前时间

[root@CCIE home]# clock

2008 年 08 月 20 日 星期三 20 时 29 分 32 秒 -0.679937 seconds

显示开机消息

[root@CCIE home]# dmesg

显示所有的环境变量

[root@CCIE home]# export -p

显示当前的主机名

[root@CCIE home]# hostname

CCIE

显示时间

[root@CCIE /]# hwclock

2008 年 08 月 21 日 星期四 14 时 19 分 42 秒 -0.817177 seconds

显示光盘的大小

[root@CCIE /]# isosize /dev/cdrom

3076845568

修改系统等待时间

[root@CCIE /]# vi /etc/grub.conf

# grub.conf generated by anaconda

IT认证部落 www.8cmd.com

#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/hda1
# initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=2 注意这里的时间是等待时间。
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.18-92.el5.img

显示没有使用的设备
[root@CCIE etc]# losetup -f
/dev/loop0
[root@CCIE etc]#

组成 raid 阵列
[root@CCIE etc]# mkraid -f /dev/hda1 + /dev/fd0

删除一个账户的密码
[root@CCIE etc]# passwd -d ccie
Removing password for user ccie.
passwd: Success

设置用户的开机投影密码
[root@CCIE etc]# pwconv

关闭用户的投影密码
[root@CCIE etc]# pwunconv

设置终端的屏幕大小
[root@CCIE etc]# resize -s 60 120

显示软件的安装信息
[root@CCIE etc]# rpm -qi rpm
Name : rpm Relocations: (not relocatable)
Version : 4.4.2 Vendor: Red Hat, Inc.
Release : 48.el5 Build Date: 2008 年 01 月 15 日 星期二
IT认证部落 www.8cmd.com

22 时 25 分 00 秒
Install Date: 2008 年 08 月 19 日 星期二 23 时 24 分 36 秒 Build Host: hs20-bc1
5.build.redhat.com
Group : System Environment/Base Source RPM: rpm-4.4.2
48.el5.src.rpm
Size : 1633585 License: GPL
Signature : DSA/SHA1, 2008 年 02 月 09 日 星 期 六 05 时 55 分 52 秒 , Key ID
5326810137017186
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary : RPM 软件包管理系统。
Description :
RPM 软件包管理器 (RPM) 是一个功能强大的命令行
驱动的软件包管理系统。它能够安装、卸装、校验、
查询、及更新软件包。每个软件包都由一个文件归
档,以及关于该软件包的信息(如版本、描述等)
组成。

查一个软件包是否安装
[root@CCIE /]# rpm -q rpm
rpm-4.3.3-7_nonptl

查看一个软件包的安装情况
[root@CCIE /]# rpm -qi rpm

列出一个 rpm 包中所含有的文件


[root@CCIE /]# rpm -ql rpm
查看文件属于那一个 rpm 包

[root@CCIE /]# rpm -qf rpm

列出所有安装的 rpm 软件
[root@CCIE /]# rpm -qa 包

列出一个等待安装的 rpm 包

[root@CCIE /]# rpm -qp rpm

查 rpm 包安装信息
[root@CCIE /]# rpm -qpi
[root@CCIE /]# rpm -qpl rpm

查 rpm 包的安装情况
[root@CCIE cdrom]# rpm -V rpm
[root@CCIE cdrom]# rpm -Va rpm
IT认证部落 www.8cmd.com

显示当前系统等级
[root@CCIE etc]# runlevel
N 3

显示当前的环境变量
[root@CCIE etc]# set
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="25" [3]="1" [4]="release" [5]="i686-redhat-linux
gnu")
BASH_VERSION='3.2.25(1)-release'
COLORS=/etc/DIR_COLORS
COLUMNS=80
DIRSTACK=()
EUID=0
GROUPS=()
G_BROKEN_FILENAMES=1
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/root
HOSTNAME=CCIE
HOSTTYPE=i686
IFS=$' \t\n'
INPUTRC=/etc/inputrc
LANG=zh_CN.UTF-8
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=37
LOGNAME=root
LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;3
3;01:or=01;05;37;41:

mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=
01;32:*.sh=01;32:*.c

sh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=0
1;31:*.Z=01;

31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;3
5:*.gif=01;35:*
IT认证部落 www.8cmd.com

.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:'
MACHTYPE=i686-redhat-linux-gnu
MAIL=/var/spool/mail/root
MAILCHECK=60
OLDPWD=/
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:
/usr/sbin:/usr

/bin:/root/bin
PIPESTATUS=([0]="0")
PPID=4883
PS1='[\u@\h \W]\$ '
PS2='> '
PS4='+ '
PWD=/etc
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive
comments:monitor
SHLVL=1
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SSH_AUTH_SOCK=/tmp/ssh-aOFPTF4883/agent.4883
SSH_CLIENT='192.168.1.100 3123 22'
SSH_CONNECTION='192.168.1.100 3123 192.168.1.103 22'
SSH_TTY=/dev/pts/0
TERM=linux
UID=0
USER=root
_=clear
consoletype=pty

设置常用程序
[root@CCIE etc]# setup

建立链接
硬链接:原文件名与连接文件名都在同一物理位置
Ln
[root@CCIE ccie]# ls -il
total 16
147348 -rw-r--r-- 1 root root 1040 Oct 24 21:56 a
IT认证部落 www.8cmd.com

147347 ---x--x--- 1 ccie ccie 1666 Oct 24 21:30 inittab.txt


[root@CCIE ccie]# ln a a1
[root@CCIE ccie]# ls
a a1 inittab.Txt
软件连接相当于快捷方式

Grep 查找关健字一行
[root@CCIE ccie]# ls -l
total 16
-rw-r--r-- 1 root root 1040 Oct 24 21:56 a
---x--x--- 1 ccie ccie 1666 Oct 24 21:30 inittab.txt
[root@CCIE ccie]# ls
a inittab.Txt

[root@CCIE ccie]# grep rc inittab.txt


# Modified for RHS Linux by Marc Ewing and Donnie Barnes
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

关闭或开启交换分区
[root@CCIE etc]# fdisk -l

Disk /dev/hda: 5368 MB, 5368709120 bytes


255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/hda1 * 1 586 4707013+ 83 Linux
/dev/hda2 587 651 522112+ 82 Linux swap / Solaris
[root@CCIE etc]# swapoff /dev/hda2
[root@CCIE etc]# swapon /dev/hda2

将系统核心参数记录下来
[root@CCIE home]# sysctl -a >/home/b
[root@CCIE home]# ls
aa b ccie ccne
[root@CCIE home]# more b
IT认证部落 www.8cmd.com

设置时区
[root@CCIE /]# timeconfig

system-config-date - (C) 2003 Red Hat, Inc.

┌────────────┤ 时区选择 ├─────────


────┐

│ │
│ 为系统选择时区。 │
│ │
│ Asia/Qyzylorda ↑ │
│ Asia/Rangoon ? │
│ Asia/Riyadh ? │
│ Asia/Saigon ? │
│ Asia/Sakhalin ? │
│ Asia/Samarkand ? │
│ Asia/Seoul ? │
│ Asia/Shanghai ↓ │
│ │
│ [*] 系统时钟使用 UTC │
│ │
│ ┌──────┐ ┌──────┐ │
│ │ 确定 │ │ 取消 │ │
│ └──────┘ └──────┘ │
│ │
│ │
└────────────────────────────
─────────┘

设置别名 删除别名
[root@CCIE /]# alias aa=ls 将 aa 用来代替 ls 命令
[root@CCIE /]# aa
bin dev home lost+found misc net proc sbin srv tftpboot usr
boot etc lib media mnt opt root selinux sys tmp var
[root@CCIE /]# unalias aa 取消这个命令的代替
[root@CCIE /]# aa
-bash: aa: command not found

显示虚拟内存情况
[root@CCIE /]# vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa
st
IT认证部落 www.8cmd.com

0 0 0 160084 8856 52696 0 0 84 23 1010 63 1 9 88


2 0

显示磁盘信息
[root@CCIE /]# vmstat -d

持续输出字串 good
[root@CCIE /]# yes good

显示头部消息 head
[root@CCIE ccie ]# ls -l
总计 8
-rw-r--r-- 1 root ccie 1666 08-20 17:43 a
-rw-r--r-- 1 root root 2 08-20 18:03 fonts.dir
[root@CCIE ccie]# head a
#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:


# 0 - halt (Do NOT set initdefault to this)

显示前十行的头部消息
[root@CCIE ccie]# head -n 10 a
#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:


# 0 - halt (Do NOT set initdefault to this)
[root@CCIE ccie]#

将 a 文件一页页显示
[root@CCIE ccie]# less a

将 a 文件显示出来
IT认证部落 www.8cmd.com

[root@CCIE ccie]# more a

nano 文件编辑器
[root@CCIE ccie]# ls -l
总计 8
-rw-r--r-- 1 root ccie 1666 08-20 17:43 a
-rw-r--r-- 1 root root 2 08-20 18:03 fonts.dir
[root@CCIE ccie]# nano a

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

[ Read 53 lines ]
^G Get Help ^O WriteOut ^R Read File ^Y Prev
Page ^K Cut

Text ^C Cur Pos


^X Exit ^J Justify ^W Where Is ^V Next Page
^U UnCut

Text ^T To Spell

可以看到上面的帮助命令。
ctrl +x 关闭文件

在 ftp 中,退出 ftp 程试


[root@CCIE ccie]# bye

建立 ftp 连接
[root@CCIE ccie]# ftp 192.168.1.33
开启 vsftpd 服务先查看 vsftpd 安装情况

[root@CCIE ccie]# rpm -q vsftpd


vsftpd-2.0.5-12.el5
[root@CCIE ccie]# service vsftpd restart
IT认证部落 www.8cmd.com

关闭 vsftpd: [确定]

为 vsftpd 启动 vsftpd: [确定]

[root@CCIE ccie]# ftp 192.168.1.103

Connected to 192.168.1.103.

220 (vsFTPd 2.0.5)

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (192.168.1.103:root): ccie 注意这里用户名

331 Please specify the password.

Password: 密码

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> dir

227 Entering Passive Mode (192,168,1,103,191,93)

150 Here comes the directory listing.

-rw-r--r-- 1 0 500 1666 Aug 20 09:43 a

-rw-r--r-- 1 0 0 2 Aug 20 10:03 fonts.dir

226 Directory send OK.

可以看到没有限制的账号,可以到根目录下,

ftp> cd /

250 Directory successfully changed.

ftp> ls

227 Entering Passive Mode (192,168,1,103,231,84)

150 Here comes the directory listing.


drwxr-xr-x 2 0 0 4096 Aug 20 09:14 bin
drwxr-xr-x 3 0 0 4096 Aug 19 15:29 boot
drwxr-xr-x 11 0 0 3800 Aug 25 02:30 dev
drwxr-xr-x 100 0 0 12288 Aug 25 02:33 etc
drwxr-xr-x 5 0 0 4096 Aug 21 06:28 home
drwxr-xr-x 14 0 0 4096 Aug 20 09:14 lib
drwx------ 2 0 0 16384 Aug 19 15:18 lost+found
drwxr-xr-x 2 0 0 4096 Aug 25 02:30 media
drwxr-xr-x 2 0 0 0 Aug 25 02:30 misc
drwxr-xr-x 2 0 0 4096 Oct 10 2006 mnt
drwxr-xr-x 2 0 0 0 Aug 25 02:30 net
drwxr-xr-x 2 0 0 4096 Oct 10 2006 opt
dr-xr-xr-x 89 0 0 0 Aug 25 02:29 proc
drwxr-x--- 16 0 0 4096 Aug 20 08:56 root
drwxr-xr-x 2 0 0 12288 Aug 20 09:14 sbin
drwxr-xr-x 2 0 0 4096 Aug 19 15:20 selinux
IT认证部落 www.8cmd.com

drwxr-xr-x 2 0 0 4096 Oct 10 2006 srv

drwxr-xr-x 11 0 0 0 Aug 25 02:29 sys

drwxr-xr-x 3 0 0 4096 Aug 19 15:38 tftpboot

drwxrwxrwt 7 0 0 4096 Aug 25 02:33 tmp

drwxr-xr-x 14 0 0 4096 Aug 19 15:24 usr

drwxr-xr-x 25 0 0 4096 Aug 19 15:42 var

226 Directory send OK.

get 下载文件

ftp> get a

local: a remote: a

227 Entering Passive Mode (192,168,1,103,139,45)

150 Opening BINARY mode data connection for a (1666 bytes).

226 File send OK.

put 上传文件

断开连线

ftp> close

221 Goodbye.

重新开启连线

ftp> open

(to) 192.168.1.103

删除文件

ftp> delete a

250 Delete operation successful.

显示文件类行

[root@CCIE ccie]# file a

a: ASCII English text

查找 48 小时修改过的文件
[root@CCIE ccie]# find -atime -2
.
./a

显示文件属性
[root@CCIE ccie]# lsattr a
------------- a

以 8 进制显示文件内容
[root@CCIE ccie]# od a
IT认证部落 www.8cmd.com

显示文件信息
[root@CCIE ccie]# stat a
File: “a”
Size: 1666 Blocks: 8 IO Block: 4096 一般文件
Device: 301h/769d Inode: 719548 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2008-08-25 11:07:37.000000000 +0800
Modify: 2008-08-25 10:48:15.000000000 +0800
Change: 2008-08-25 10:48:15.000000000 +0800

显示默认的权限
[root@CCIE ccie]# umask
0022

设置文件权限
[root@CCIE ccie]# umask 111
[root@CCIE ccie]# umask
0111

显示当前分区大小
[root@CCIE ccie]# fdisk -l

Disk /dev/hda: 5368 MB, 5368709120 bytes


255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/hda1 * 1 586 4707013+ 83 Linux
/dev/hda2 587 651 522112+ 82 Linux swap / Solaris

用 fdisk 分区 hdb
[root@CCIE ccie]# fdisk /dev/hdb

a 标记分区
d 删除分区
l 列出分区类型
m 帮助信息
n 新建分区
p 列出分区消息
q 退出但不保存
t 设置分区编号
v 进行分区的检测
w 写回硬盘
IT认证部落 www.8cmd.com

查看文件系统并尝试修复
[root@CCIE ccie]# fsck
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
/dev/hda1 is mounted.

WARNING!!! Running e2fsck on a mounted filesystem may cause


SEVERE filesystem damage.

Do you really want to continue (y/n)?

gzexe 压缩可执行文件
[root@CCIE ccie]# gzexe a
a: 51.7%
[root@CCIE ccie]# ls
a a~ fonts.dir
[root@CCIE ccie]# ls -l
总计 12
-rw-r--r-- 1 root root 1201 08-25 11:24 a
-rw-r--r-- 1 root root 1666 08-25 10:48 a~
-rw-r--r-- 1 root root 2 08-20 18:03 fonts.dir

向指定机器发送 arp 请求。


[root@CCIE ccie]# arping 192.168.1.99

显示 arp
[root@CCIE ccie]# arp
Address HWtype HWaddress Flags Mask
Iface
192.168.1.101 ether 00:03:0D:69:DE:80 C
eth0
192.168.1.99 ether 00:1D:60:18:46:54 C
eth0
192.168.1.1 ether 00:18:39:A5:10:20 C eth0

dns 查讯
[root@CCIE /]# host www.163.com
查询具体的 dns
[root@CCIE /]# host -a www.g.cn
Trying "www.g.cn"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56330
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4

;; QUESTION SECTION:
IT认证部落 www.8cmd.com

;www.g.cn. IN ANY

;; ANSWER SECTION:

www.g.cn. 583 IN CNAME cn.l.google.com.

;; AUTHORITY SECTION:

g.cn. 280140 IN NS ns3.google.com.

g.cn. 280140 IN NS ns4.google.com.

g.cn. 280140 IN NS ns2.google.com.

g.cn. 280140 IN NS ns1.google.com.

;; ADDITIONAL SECTION:

ns1.google.com. 287943 IN A 216.239.32.10

ns2.google.com. 287943 IN A 216.239.34.10

ns3.google.com. 287943 IN A 216.239.36.10

ns4.google.com. 287943 IN A 216.239.38.10

Received 191 bytes from 221.12.33.228#53 in 31 ms

查看网络接口

[root@CCIE /]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:0C:29:53:1F:EA

inet addr:192.168.1.103 Bcast:192.168.1.255 Mask:255.255.255.0


inet6 addr: fe80::20c:29ff:fe53:1fea/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1492 Metric:1
RX packets:258 errors:0 dropped:0 overruns:0 frame:0
TX packets:279 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:24959 (24.3 KiB) TX bytes:35381 (34.5 KiB)
Interrupt:177 Base address:0x1080

lo Link encap:Local Loopback


inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)

ip 转发功能充许服务器将数据从一个子网转到另一个子网。
[root@CCIE /]# more /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
IT认证部落 www.8cmd.com

# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and

# sysctl.conf(5) for more details.

# Controls IP packet forwarding

net.ipv4.ip_forward = 0

# Controls source route verification

net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing

net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel

kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.

# Useful for debugging multi-threaded applications.

kernel.core_uses_pid = 1

通过将 net.ipv4.ip forward=1 来开启。

telnet 默认采用 23 号端口通信

[root@CCIE /]# telnet 192.168.168.125

ssh 采用 22 号端口通信,比 telnet 更安全。

[root@CCIE ~]# ssh 192.168.168.125

root@192.168.168.125's password:

关闭网卡

[root@CCIE /]# ifconfig eth0 down

开启网卡

[root@CCIE /]# ifconfig eth0 up

显示防火墙过滤表

[root@CCIE /]# iptables -t filter -L

Chain INPUT (policy ACCEPT)

target prot opt source destination

Chain FORWARD (policy ACCEPT)

target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

IT认证部落 www.8cmd.com

禁止 ping 自己的地址

[root@CCIE log]# iptables -A INPUT -p icmp -j DROP

显示高级路由表

[root@CCIE /]# iptables -t mangle -L

Chain PREROUTING (policy ACCEPT)

target prot opt source destination

Chain INPUT (policy ACCEPT)

target prot opt source destination

Chain FORWARD (policy ACCEPT)

target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

Chain POSTROUTING (policy ACCEPT)

target prot opt source destination

显示转发包过滤表

[root@CCIE /]# iptables -t nat -L

Chain PREROUTING (policy ACCEPT)

target prot opt source destination

Chain POSTROUTING (policy ACCEPT)

target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

关闭防火墙

[root@CCIE ~]# service iptables stop

开启防火墙

[root@CCIE ~]# service iptables restart

设置 input 的规则 与 input 不合的会部丢弃。

[root@CCIE ~]# iptables -P INPUT DROP

设置 output 规则。与 output 不合的会部丢弃

[root@CCIE ~]# iptables -P OUTPUT DROP

设置 forward 规则,与 forward 不合的全部丢弃。

IT认证部落 www.8cmd.com

[root@CCIE ~]# iptables -P FORWARD DROP

显示防火墙的设置
[root@CCIE ~]# iptables-save
# Generated by iptables-save v1.3.5 on Thu Aug 28 11:44:59 2008
*filter
:INPUT ACCEPT [143:10453]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [145:14684]
-A INPUT -s 192.168.1.100 -j ACCEPT
COMMIT
# Completed on Thu Aug 28 11:44:59 2008

查看防火墙帮助
[root@CCIE log]# iptables --help |more
清空防火墙
[root@CCIE log]# iptables -F
Iptables -a 加一个规则
-d 删除一个
-i 插入
-r 替换
-f 清空
查看编号

设置一条新规则,接受来自一个地址的一切包。
[root@CCIE ~]# iptables -A INPUT -s 192.168.1.100 -j ACCEPT

设置一条新规则,丢弃来自一个地址的一切包。
[root@CCIE /]# iptables -A INPUT -s 192.168.1.100 -j DROP

显示 mangle 表的设置
[root@CCIE /]# iptables -t filter
iptables v1.3.5: no command specified
Try `iptables -h' or 'iptables --help' for more information.
[root@CCIE /]# iptables-save -t mangle
# Generated by iptables-save v1.3.5 on Thu Aug 28 12:58:51 2008
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Thu Aug 28 12:58:51 2008
IT认证部落 www.8cmd.com

查看端口号
[root@CCIE /]# more /etc/services

显示 nat 表的设置
[root@CCIE /]# iptables-save -t nat
# Generated by iptables-save v1.3.5 on Thu Aug 28 12:59:13 2008
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
# Completed on Thu Aug 28 12:59:13 2008

配置无线网张设备
[root@CCIE /]# iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

sit0 no wireless extensions.

控制终端的写入
[root@CCIE /]# mesg
is y

网络诊断工具
[root@CCIE /]# mtr

查看到 www.163.com 的网络情况


[root@CCIE /]# mtr www.163.com
CCIE (0.0.0.0)

Thu Aug 28 13:02:16 2008


Keys: Help Display mode Restart statistics Order of fields quit

Packets Pings
Host

Loss% Last Avg Best Wrst StDev


1. 172.16.12.126

0.0% 1.8 1.9 1.3 3.1 0.3


192.168.1.1
IT认证部落 www.8cmd.com

2. 172.16.12.254

0.0% 4.0 3.2 2.4 4.9 0.7


3. 172.16.1.1

0.0% 3.5 2.8 1.7 4.7 0.7


4. 221.12.26.33

0.0% 5.7 5.6 2.8 16.6 2.3


5. 221.12.2.205

0.0% 8.9 12.9 4.8 45.0 8.8


6. 221.12.1.198

0.0% 3.3 3.5 2.1 7.2 0.9


7. 221.12.2.145

7.8% 4.7 6.6 2.8 48.3 6.4


221.12.1.125
221.12.1.121
221.12.2.249
221.12.1.201
221.12.2.253
8. 219.158.9.93

0.0% 4.7 5.4 3.7 8.8 0.9


219.158.9.13
219.158.12.77
9. 219.158.4.69

0.0% 14.6 14.5 3.4 26.8 5.5


219.158.5.166
10. 202.96.12.22

0.0% 56.9 33.9 13.0 56.9 12.2


219.158.4.69
11. 202.106.193.173

0.0% 33.7 32.7 27.0 52.0 4.9


202.96.12.22
12. 61.148.143.18

0.0% 34.6 34.0 27.1 58.8 6.5


202.106.193.173
IT认证部落 www.8cmd.com

13. 202.108.38.14

0.0% 49.1 37.7 27.2 54.2 8.6


61.148.143.18
14. zz-9-34-a8.bta.net.cn

0.0% 32.4 31.3 27.3 45.5 3.2


202.108.38.14

查看网络状态
[root@CCIE /]# netstat -a

显示网络统计信息
[root@CCIE /]# netstat -s

显示监听的接口
[root@CCIE /]# netstat l

dns 查找
[root@CCIE /]# nslookup www.g.cn
Server: 221.12.33.228
Address: 221.12.33.228#53

Non-authoritative answer:
www.g.cn canonical name = cn.l.google.com.
Name: cn.l.google.com
Address: 203.208.35.100
Name: cn.l.google.com
Address: 203.208.35.101

ping 主机
[root@CCIE /]# ping www.g.c

建立 ppp 连接
[root@CCIE /]# pppd

从远端主机获取时间
[root@CCIE /]# rdate 192.168.1.100

显示当前的路由表
[root@CCIE /]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use
Iface
IT认证部落 www.8cmd.com

192.168.1.0 * 255.255.255.0 U 0 0 0 eth0


169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0

删除一个网关
[root@CCIE /]# route del default gw 192.168.2.2

增加一条路由
[root@CCIE /]# route add -net 1.1.1.0 netmask 255.255.255.0 dev eth0

远程登陆一台主机
[root@CCIE /]# ssh 192.168.1.100

与另外一客户交淡
[root@CCIE /]# who
root pts/0 2008-08-28 12:51 (192.168.1.100)
root pts/1 2008-08-28 12:57 (192.168.1.100)
[root@CCIE /]# talk kk tty2

远程登录主机
[root@CCIE /]# telnet 192.168.1.103

测试 samba 配置
[root@CCIE /]# testparm
Load smb config files from /etc/samba/smb.conf
Processing section "[homes]"
Processing section "[printers]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
workgroup = MYGROUP
server string = Samba Server Version %v
passdb backend = tdbsam
cups options = raw

[homes]
comment = Home Directories
read only = No
browseable = No

[printers]
comment = All Printers
IT认证部落 www.8cmd.com

path = /var/spool/samba

printable = Yes

browseable = No

跟踪路由
[root@CCIE /]# tracepath ww.g.cn
1: 192.168.1.103 (192.168.1.103) 2.619ms pmtu 1492
1: 172.16.12.126 (172.16.12.126) 1.899ms
2: 172.16.12.254 (172.16.12.254) 1.995ms
3: 172.16.1.1 (172.16.1.1) asymm 4 1.991ms
4: 221.12.26.33 (221.12.26.33) 5.949ms
5: 221.12.2.205 (221.12.2.205) 9.361ms
6: 221.12.2.213 (221.12.2.213) asymm 7 5.049ms
7: 221.12.2.149 (221.12.2.149) asymm 8 4.734ms
8: 219.158.13.65 (219.158.13.65) asymm 9 24.994ms
9: 219.158.11.94 (219.158.11.94) asymm 11 23.024ms
10: 219.158.32.226 (219.158.32.226) asymm 12 28.567ms
11: 203.208.62.17 (203.208.62.17) asymm 14 25.885ms
12: 203.208.35.100 (203.208.35.100) asymm 14 18.932ms
reached
Resume: pmtu 1492 hops 12 back 14

[root@CCIE /]# traceroute www.g.cn


traceroute to www.g.cn (203.208.35.101), 30 hops max, 40 byte packets
1 172.16.12.126 (172.16.12.126) 2.088 ms 2.117 ms 3.910 ms
2 172.16.12.254 (172.16.12.254) 4.747 ms 3.249 ms 4.053 ms
3 172.16.1.1 (172.16.1.1) 2.978 ms 5.303 ms 4.158 ms
4 221.12.26.33 (221.12.26.33) 19.627 ms 17.143 ms 18.069 ms
5 221.12.2.209 (221.12.2.209) 23.741 ms 20.188 ms 23.686 ms
6 221.12.1.169 (221.12.1.169) 15.276 ms 16.759 ms 17.186 ms
7 221.12.1.201 (221.12.1.201) 18.830 ms 19.722 ms 21.721 ms
8 219.158.7.185 (219.158.7.185) 55.971 ms 56.697 ms 58.162 ms
9 219.158.22.154 (219.158.22.154) 58.840 ms 52.449 ms 52.919 ms
10 219.158.32.226 (219.158.32.226) 36.534 ms 40.734 ms 32.857 ms
11 203.208.62.15 (203.208.62.15) 25.774 ms 28.681 ms 29.240 ms
12 203.208.35.101 (203.208.35.101) 33.341 ms 35.694 ms 39.274 ms

显示当前终端
[root@CCIE /]# tty
/dev/pts/1

显示磁盘的使用情况
[root@CCIE /]# df
文件系统 1K-块 已用 可用 已用% 挂载点
IT认证部落 www.8cmd.com

/dev/hda1 4559492 2465836 1858308 58% /


tmpfs 127796 0 127796 0% /dev/shm
[root@CCIE /]# df i
文件系统 Inode (I)已用 (I)可用 (I)已用% 挂载点
/dev/hda1 1177344 107469 1069875 10% /
tmpfs 31949 1 31948 1% /dev/shm
[root@CCIE /]# df -t ext3
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/hda1 4559492 2465836 1858308 58% /

关闭硬盘的配额限制
[root@CCIE /]# quotaoff -a

开启硬盘的配额限制
[root@CCIE /]# quotaon -a

显示硬盘的空间限制
[root@CCIE /]# quotastats
Kernel quota version: 6.5.1
Number of dquot lookups: 0
Number of dquot drops: 0
Number of dquot reads: 0
Number of dquot writes: 0
Number of quotafile syncs: 22
Number of dquot cache hits: 0
Number of allocated dquots: 0
Number of free dquots: 0
Number of in use dquot entries (user/group): 0

关闭硬盘的软件 raid
[root@CCIE /]# rpiastop -a

显示硬盘的使用情况
[root@CCIE /]# repquota -a

显示分区消息
[root@CCIE /]# sfdisk -l

Disk /dev/hda: 10402 cylinders, 16 heads, 63 sectors/track


Warning: The partition table looks like it was made
for C/H/S=*/255/63 (instead of 10402/16/63).
For this listing I'll assume that geometry.
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
IT认证部落 www.8cmd.com

Device Boot Start End #cyls #blocks Id System


/dev/hda1 * 0+ 585 586- 4707013+ 83 Linux
/dev/hda2 586 650 65 522112+ 82 Linux swap / Solaris
/dev/hda3 0 - 0 0 0 Empty
/dev/hda4 0 - 0 0 0 Empty

将内存数据写处硬盘
[root@CCIE /]# sync

创建一张启用盘
[root@CCIE /]# mkbootdisk 2.6.18-92.el5
Insert a disk in /dev/fd0. Any information on the disk will be lost.

Press <Enter> to continue or ^C to abort:

mkisofs 创建一个 iso 文件


[root@CCIE ccie]# mkisofs -o aiso b
INFO: UTF-8 character encoding detected by locale settings.
Assuming UTF-8 encoded filenames on source filesystem,
use -input-charset to override.
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
175 extents written (0 MB)
[root@CCIE ccie]# ls
aiso b fonts.dir

指定一个分区为交换分区
[root@CCIE ccie]# mkswap -c -vl -L swapnew/dev/hda3

启动图型界面
[root@CCIE ccie]# startx

显示当前设置
[root@CCIE ccie]# xset

红盟过客修改于 2008 年 9 月第一版本。

2008 年 9 月 15 日

IT认证部落 www.8cmd.com

Вам также может понравиться