In which subdirectory of /proc is information about PC Cards, which are connected and recognised by a 2.6 kernel,stored?
—————————————————–
[root@cos3 /]# ll /proc/bus
total 0
dr-xr-xr-x 2 root root 0 Oct 20 05:26 input
dr-xr-xr-x 2 root root 0 Oct 20 05:26 pccard
dr-xr-xr-x 3 root root 0 Oct 20 05:26 pci
drwxr-xr-x 3 root root 0 Oct 19 19:33 usb
[root@cos3 /]# tree /proc/bus
/proc/bus
|– input
| |– devices
| `– handlers
|– pccard
| `– drivers
|– pci
| |– 00
| | |– 00.0
| | |– 01.0
| | |– 07.0
| | |– 07.1
| | |– 07.2
| | |– 07.3
| | |– 0f.0
| | |– 10.0
| | |– 11.0
| | |– 12.0
| | `– 13.0
| `– devices
`– usb
|– 001
| `– 001
`– devices
6 directories, 17 files
—-
为了实现设备的检测,系统会用到/proc目录,由于和尚的没有安装PCMCIA设备,所以上面的pccard/devices 是空文件。
给大家一个usb的例子。
[root@cos3 pccard]# cat /proc/bus/usb/devices
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2
B: Alloc= 0/900 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0000 ProdID=0000 Rev= 2.06
S: Manufacturer=Linux 2.6.18-8.el5 uhci_hcd
S: Product=UHCI Host Controller
S: SerialNumber=0000:00:07.2
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms
你看到什么了?
和尚看到遥远的星空了。
没关系,在IBM的网站《如何在LINUX下实现硬件的自动检测》有详细解释。
我们再仔细看(中括号里是文件大小)
[root@cos3 bus]# tree -as
.
|– [ 0] input
| |– [ 0] devices
| `– [ 0] handlers
|– [ 0] pccard
| `– [ 0] drivers
|– [ 0] pci
| |– [ 0] 00
| | |– [ 256] 00.0
| | |– [ 256] 01.0
| | |– [ 256] 07.0
| | |– [ 256] 07.1
| | |– [ 256] 07.2
| | |– [ 256] 07.3
| | |– [ 256] 0f.0
| | |– [ 256] 10.0
| | |– [ 256] 11.0
| | |– [ 256] 12.0
| | `– [ 256] 13.0
| `– [ 0] devices
`– [ 0] usb
|– [ 0] 001
| `– [ 43] 001
`– [ 0] devices
6 directories, 17 files
file size 是零哦,联想到 “Linux 虚拟文件系统” 了吗?
公布答案【/proc/bus/pccard】
Which Two statements about crontab are true?
A. Every user may have their own crontab.
B Changing a crontab requires a reload/restart of the cron deamon.
C. The cron daemon reloads crontab files automatically when necessarly.
D. hourly is the same as “0 * * * *”.
E. A cron daemon must run for each existing crontab.
———————————————————————
先看帮助
usage: crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e (edit user’s crontab)
-l (list user’s crontab)
-r (delete user’s crontab)
-i (prompt before deleting user’s crontab)
-s (selinux context)
可以用crontab -u username -e 编辑个人的计划文件,文件自动保存为/var/spool/cron/username。
所以every user may have their own crontab 是正确的。
———————————————————————
B为啥不对?因为更改之后,不需要重新启动cron 。
我们在设定crontab 时发现没有,计划的最小单位是分,不是秒或者其他的单位。
所以,cron工作时也是每一分钟扫描一次文件,看看有没有什么要做的工作。
———————————————————————
C正确,确实是自动工作的。
———————————————————————
D. hourly is the same as “0 * * * *”.
ERROR!虽然是5位,但顺序是从小单位到大单位的哦!(最后一位,星期除外)
分钟 (0-59)
小時 (0-23)
日期 (1-31)
月份 (1-12)
星期 (0-6)//0代表星期天
———————————————————————
公布正确答案·【AC】
What does the follwing script do ?
#!/bin/bash
find / -perm +4000 | mail -s “Daily find output” root
A. Emails a report of all guid files to root
B. Emails a report of all important files to root
C. Emails a report of all writeable files to root
D. Emails a report of all suid files to root
E. Corrects permissions on files and emails the results to root
先了解find 的 perm 参数
perm 参数用于文件权限模式匹配查找,
perm 又有三种匹配模式,
-perm mode 完全匹配
-perm -mode 最少匹配
-perm +mode 最大匹配
和尚准备了512个文件名(8*8*8=512)与其属性值一致的文件。
如属性值为777的文件,则文件名为777
下面看例子
-perm mode 完全匹配的例子。显示属性值为754的文件。
# find . -perm 754
./754
再看 -perm -mode 最少匹配的例子。
查找除自己以外的人,可以读写的文件。
# find . -perm -066
./177
./376
./677
./366
./166
./377
./666
./776
./767
./676
./577
./576
./266
./567
./066
./467
./777
./077
./076
./477
./276
./067
./167
./277
./176
./466
./476
./267
./367
./766
./667
./566
例子中使用了权限代码066,其含义是
不管自己的权限,所以第一位匹配数为0,意思是0,1,2,3,4,5,6,7的任意组合,从上面的例子也可以看出,第一位包含0~7,共8种组合。
同一group的成员,至少拥有读写权限rw ,不管是否可以执行,所以4+2+(0 or 1)转换为8进制数最少为6(4+2+0),或者为7(4+2+1),共2种组合。
其他group的成员也至少拥有读写权限rw ,所以属性值也为6 or 7. 同样也有共2种组合。
下面再看一个特殊的例子
#find . -perm -773
./777
./773
结果只有两个文件符合
提问!请回答,774,775,776 这三个属性为什么不符合呢?
(+mode 和尚还没有明白,另外不知何时find 命令多了一个 “-perm /mode” 参数)
注意问题中的权限代码是4位,原因是使用了suid/sgid,问题中的权限第一位是4,说明使用的是suid权限。
(提示,2则是sgid权限,6则是4+2,同时拥有suid sgid 权限) Google linux suid
mail command 的格式为
mail -s mail标题 收件人
公布答案【D】
For interpreting system rc scripts, a shell is most commonly used.
Please enter the first line found in such scripts. Answer:
_________________
首先明白什么是rc script ,系统启动脚本,记得/etc/rc.*吗?
# ls rc
rc rc1.d/ rc3.d/ rc5.d/ rc.d/ rc.sysinit
rc0.d/ rc2.d/ rc4.d/ rc6.d/ rc.local
这些脚本里面用的什么shell呢?
# cat K01smartd
#! /bin/sh
也有一些使用的 #!/bin/bash
#cat rc.sysinit
公布答案【#!/bin/sh】
Which of the following commands should be used in a bash script that needs a variable containing the IP address fo the eth0 interface?
The output for the command ifconfig eth0 is shown below:
eth0 Link encap:Ethernet HWaddr 00:0C:29:B0:6C:E1
inet addr:10.32.176.236 Bcast:10.32.176.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb0:6ce1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4583 errors:0 dropped:0 overruns:0 frame:0
TX packets:1140 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:595654 (581.6 KiB) TX bytes:174578 (170.4 KiB)
A. IP=LANG= ifconfig eth0 | awk ‘{print $2}’ | cut -f2
B. IP=$(LANG= ifconfig eth0 | grep inet | cut -d: -f2)
C. IP=`LANG= ifconfig eth0 | awk ‘{print $3}’`
D. IP=`LANG= ifconfig eth0 | grep inet | cut -d: -f2 | awk {print $1}`
E. IP=$(ifconfig eth0 | grep inet | awk ‘{print $2}’ | cut -d: -f2)
目的是取得 第2行中的IP 10.32.176.236
因为ifconfig eth0 的结果中有1行以上的描述,所以为了只取得第二行的IP,行列都需要限制。
A. IP=LANG= ifconfig eth0 | awk ‘{print $2}’ | cut -f2
IP=LANG= xxxx ,这种写法并不会把运算结果传给IP,或者 IP=LANG
shell变量的基本赋值方式是 <变量>=<文字列>
显示一下
[root@vanilla ~]# set | grep ^IP
[root@vanilla ~]#
B. IP=$(LANG= ifconfig eth0 | grep inet | cut -d: -f2)
IP=$xxx 的含义是, 但是如果xxx不是名字,而是表达式的话,根据表达式运算结果的不同,IP的值有两种情况。
假如表达式的运算结果不是一个字符串,而是包含空格,tab等,则IP的值为 $’表达式值,换行符等会成为转义字符’
假如表达式的运算结果是一个字符串,就是说不包含空格,tab等,则IP的值为 表达式值
我们再分析 LANG= ifconfig eth0 | grep inet | cut -d: -f2 的运算过程
先使用grep 对行限定,结果为第二行。
在使用cut 对列限定,分隔符为冒号,取第二个字段。也就是第一个分号到第二个分号的内容。结果中部单纯是IP地址,还包含 Bcast。
所以B也不正确。
C. IP=`LANG= ifconfig eth0 | awk ‘{print $3}’`
` 号 在这里与$的用法相同,
假如表达式的运算结果不是一个字符串,而是包含空格,tab等,则IP的值为 $’表达式值,换行符等会成为转义字符’
假如表达式的运算结果是一个字符串,就是说不包含空格,tab等,则IP的值为 表达式值
很明显没有对 行限制,只是用awk 对列进行了限制。
D. IP=`LANG= ifconfig eth0 | grep inet | cut -d: -f2 | awk {print $1}`
awk语法错误。
awk: cmd. line:1: {print
awk: cmd. line:1: ^ unexpected newline or end of string
awk运算时,没有加引号的 {print $1} 表达式被当作参数了。
和尚用的linux 版本(CentOS 2.6.18-8.el5xen )中,awk的表达式单双引号都可以使用。
Examples:
gawk ‘{ sum += $1 }; END { print sum }’ file
gawk -F: ‘{ print $1 }’ /etc/passwd
E. IP=$(ifconfig eth0 | grep inet | awk ‘{print $2}’ | cut -d: -f2)
因为ifconfig eth0 的结果中有1行以上的描述,所以为了只取得第二行的IP,行列都需要限制。
例子中先使用了grep 进行行限定,只取得包含 inet 的行,
结果为
inet addr:10.32.176.236 Bcast:10.32.176.255 Mask:255.255.255.0
又使用awk的列限制,取得第二列。注意如果不指定awk 的分割参数,默认是以空格分隔字段的。连续的空格被认为是一个空格。
结果为
addr:10.32.176.236
最后 cut -d: -f2 是在awk运算结果的基础上再次取得第二个字段。注意不指定分隔符的话,默认是tab。
结果为IP地址。
公布答案【1+1=2,嘿嘿】
A database application requires a maximum shared memory segment(shmmax) of 2GB (2147483648 Bytes) .Which configuration file should be modified,to set this kernel parameter permanently?名词 shared memory segment 中文叫共享内存段,也就是Oracle中的SGA.
shmmax 是 内核参数之一,用于定义单个共享内存段的最大值。
#cat /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# 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
# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1
# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536
# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456
注意内存的算法 2G = 2*1024*1024*1024 = 2147483648 Bytes
Which of the following configuration lines will export /usr/local/share/ to nfsclient with read-write access, ensuring that all changes are written straight to the disk?
A. /usr/local/share nfsclient(rw)
B. nfsclient:/usr/local/share/:rw,sync
C. /usr/local/share nfsclient:rw:sync
D. /usr/local/share nfsclient(rw,sync)
E. nfsclient(rw,sync) /usr/local/share
看一个nfs 配置文件的例子。
#cat /etc/exports
/usr/local 192.168.0.0/255.255.255.0(ro)
/home 192.168.0.0/255.255.255.0(rw,no_root_squash)
共享目录 客户机名或IP(参数,参数,….)
EXAMPLE
# sample /etc/exports file
/ master(rw) trusty(rw,no_root_squash)
/projects proj*.local.domain(rw)
/usr *.local.domain(ro) @trusted(rw)
/home/joe pc001(rw,all_squash,anonuid=150,anongid=100)
/pub (ro,insecure,all_squash)
Which TWO of the following options are valid, in the /etc/exports file?
A. rw
B. ro
C. rootsquash
D. norootsquash
E. uid
记得/etc/exports 吗?是nfs server 的共享目录及权限配置文件。
man exports 5 中 对于参数的描述分为两部分,
1. General Options 主要参数如下
rw
async
sync
nohide
2. User ID Mapping 主要参数如下
root_squash
no_root_squash
all_squash
anonuid
anongid
链接: 非常全面的NFS文档(For Linux)
On an NFS server, the portmap, nfsd and _____ daemons must be running. Please enter the missing deamon below.
NFS server 是由
rpc.nfsd(/usr/sbin/rpc.nfsd),
rpc.mountd(/usr/sbin/rpc.mountd),
portmap(/sbin/portmap),
在新版中,查看服务列表是会发现nfslock,但是很多地方没有提到nfslock。但nfslock并不是必须启动的服务,所以标准答案是 rpc.mountd
各守护的作用如下。
(1) The rpc.nfsd program implements the user level part of the NFS service. The main functionality is handled
by the nfsd.o kernel module; the user space program merely starts the specified number of kernel threads.
(2) The rpc.mountd server provides an ancillary service needed to satisfy mount requests by NFS clients.
The rpc.mountd program implements the NFS mount protocol. When receiving a MOUNT request from an NFS client, it checks the request against the list of currently exported file systems. If the client is permitted to mount the file system, rpc.mountd obtains a file handle for requested directory and returns it to the client.
(3) Portmap is a server that converts RPC program numbers into DARPA protocol port numbers. It must be running in order to make RPC calls.
When an RPC server is started, it will tell portmap what port number it is listening to, and what RPC pro-gram numbers it is prepared to serve. When a client wishes to make an RPC call to a given program number, it will first contact portmap on the server machine to determine the port number where RPC packets should be sent.
从 LPI/LPIC 201 问题学习Linux(025) 用户帐号限制的文件
Which site-specific configuration file for the shadow login suite must be modified to log logion failures? Please enter the complete path to that file. Answer:
Correct Text: 【/etc/login.defs】
#man login.defs
NAME
login.defs – shadow password suite configuration
DESCRIPTION
The /etc/login.defs file defines the site-specific configuration for the shadow password suite. This file is required. Absence of this file will not prevent system operation, but will probably result in undesirable operation.
———–sample———-
MAIL_DIR /var/spool/mail
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
UID_MIN 500
UID_MAX 60000
GID_MIN 500
GID_MAX 60000
CREATE_HOME yes
UMASK 077
What is the correct parameter to pass to the kernel at boot time to force it to user only one of the available processors?
系统启动时使用 maxcpus=0 参数,使系统不使用SMP(Symmetrical Multi-Processing
)系统,也就是使用题目中所说的单CUP了。
maxcpus 的设定方法。
1)lilo时
lilo: linux maxcpus=2
2)grub时
在含有kernel 信息的行的最后加上 maxcpus=2
启动之后,查看CPU信息,下面是和尚使用的VMware 模拟的两颗CPU
# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Mobile Intel(R) Pentium(R) 4 CPU 3.06GHz
stepping : 8
cpu MHz : 3053.345
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 3
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss constant_tsc pni ds_cpl
bogomips : 6100.01
processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Mobile Intel(R) Pentium(R) 4 CPU 3.06GHz
stepping : 8
cpu MHz : 3053.345
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 3
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss constant_tsc pni ds_cpl
bogomips : 6080.00
链接 Linux内核引导参数精选
Configuration of X is complete and now the default runlevel can be changed from runlevel 3 to runlevel 5 . In which of the following configuration files should this be done? Answer.
level 1 的问题,更改id:3:initdefault: to id:5:initdefault:
再看 /etc/inittab。
# cat /etc/inittab
# Default runlevel. The runlevels used by RHS are:
# 0 – halt (Do NOT set initdefault to this)
# 1 – Single user mode
# 2 – Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 – Full multiuser mode
# 4 – unused
# 5 – X11
# 6 – reboot (Do NOT set initdefault to this)
#
id:3:initdefault:
# 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
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
# When our UPS tells us power has failed, assume we have a few minutes
# of power left. Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 “Power Failure; System Shutting Down”
# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c “Power Restored; Shutdown Cancelled”
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon
You have written a little startup script(/usr/local/bin/startup.sh) that should automatically execute when entering runlevel 3. According to the standards,how can this best be achieved?
A. chmod 700 /usr/local/bin/startup.sh; cd /etc/initd./rc3.d; ln -s /usr/local/bin/startup.sh
B. chmod 700 /usr/local/bin/startup.sh; cd /etc/initd./rc3.d; ln -s /usr/local/bin/startup.sh S99Startup.sh
C. chmod 700 /usr/local/bin/startup.sh; cd /etc/initd./rc3.d; ln /usr/local/bin/startup.sh
D. chmod 700 /usr/local/bin/startup.sh; cd /etc/initd./rc3.d; ln -s S99Startup.sh /usr/local/bin/startup.sh
E. chmod 700 /usr/local/bin/startup.sh; cp /usr/local/bin/startup.sh /etc/initd./rc3.d/S99Startup.sh
ln 的用法:
ln -s TARGET LINK_NAME
A,C,D 会出现语法错误。
B,D,两种方法都可以实现自动启动的目的,但我们在看/etc/rc3.d 时会发现所有的脚本都是/etc/init.d/下的 symbolic 文件。
看来B才是best .
The Linux kernel is loaded successfully by the boot loader.However,straight after the kernel mounts the root filesystem, the boot process stops and an error message regarding init is shown. Which of the following actions is the best one to be used in order to identify and fix the problem? A. The administrator reboots the system with a recovery disk and checks the root filesystem for errors with fsck.B. The administrator reboots the system with a recovery disk and restores from a backup.C. The administrator reboots the system and tells the kernel, through the boot loader prompt, to use /bin/bash as the initial process.D. The administrator reboots the system with a recovery disk and installs a new kernel.E. The administrator reboots the system and tells init, through the boot loader prompt ,to use a different runlevel.
所谓init ,它是由内核启动的用户级进程,PID为1。内核完成系统的硬件设备的初始等工作之后,就会启动/sbin/init,init 按照自己的配置文件/etc/inittab完成系统的引导。所谓的init进程,它是一个由内核启动的用户级进程
A错. 既然已经启动起来了,在初始化时出问题,那么就不是硬盘的问题,所以fsck 工具是解决不了问题的。B错. 出问题就recovery 的话,就有点….,这应该是最后的方案吧。C对. 有些文章说init 启动失败后,会运行 /bin/sh。我们假设寻找/bin/sh 也失败了的话,就要手动指定shell程序了,比如用/bin/bash 代替 init 程序的话,可在 参数后面添加 init=/bin/bash。
进入shell 后就可以进行修复工作了。
例子
/boot/vmlinuz-2.6.17-11-generic root=UUID=5cc79966-969d-4cd0-abb2-74a132efbd7c ro vga=794 quiet splash init=/bin/bash
(不过,实际上 /bin/sh 就是 /bin/bash的链接文件)
D错. 还不至于安装新核心。E错. 在内核命令行的最后加上“init X”参数,可以改变运行级别。但是读 init 时出了问题的话,更改级别应该无济于事。
Which keyword is used in the /etc/inittab file to define the default system runlevel ?
__________
再次复习 inittab
# cat /etc/inittab
# Level to run in
id:3:initdefault:
———————————————
需要理解inittab 的书写格式。
看看man 是怎么说的。
The inittab file describes which processes are started at bootup and
during normal operation (e.g. /etc/init.d/boot, /etc/init.d/rc, get-
tys…). Init(8) distinguishes multiple runlevels, each of which can
have its own set of processes that are started. Valid runlevels are
0-6 plus A, B, and C for ondemand entries. An entry in the inittab
file has the following format:
id:runlevels:action:process
action (initdefault)就是keyword 了。
Consider the folwing /etc/fstab file:
/dev/hda1 swap swap defaults 0 0
/dev/hda2 / ext2 defaults 1 1
/dev/hda3 /home ext2 defaults 1 2
none /proc proc defaults 0 0
/dev/fd0 /media/floppy vfat user,noauto 0 0
What command can an ordinary(non-root) user use to mount a floppy disk in this system?( Please enter the command with all parameters and/or options) .
_________________
floppy 的定义是最后一行,这个就不解释了。
以 定义floppy参数行为例,看6个字段的作用。
(第1字段)/dev/fd0 —设备,或远程文件系统。
(第2字段)/media/floppy–上述设备加载的目录点.加载目录名中的空格用40来表示。
(第3字段)vfat—指定/dev/fd0的文件系统。
(第4字段)user,noauto—加载文件系统时需要使用的参数用逗号分隔。
常见参数有
default,ro,sync,user,quota,noauto.
题目中user,noauto的含义是,启动时不自动mount,普通用户(non-root)有权利mount。
(第5字段)0—0的含义是不需要转储
(第6字段)0—0的含义是启动时无需扫描
详细可参考 Linux fstab参数详解
既然为floppy 定义了加载目录,文件系统格式,那么在mount时,只需要 mount /dev/fd0 就可加载floppy 到/media/floppy目录下了。
虽然mount 的完整模式是
mount -t type device dir
看一下man mount 就了然了。
# man mount
.
.
.
The standard form of the mount command, is
mount -t type device dir
This tells the kernel to attach the file system found on device (which is of type type) at the directory
dir. The previous contents (if any) and owner and mode of dir become invisible, and as long as this file
system remains mounted, the pathname dir refers to the root of the file system on device.
.
.
.
-t vfstype
公布答案【mount /dev/fd0 】
从 LPI/LPIC 201 问题学习Linux(016) 为内核添加驱动模块并指定参数
Your routing configuration relies on eth0 begin a 3com card that requires the 3c59x module. What line must be added to modules configuration file,to ensure that eth0 always uses this module?
A. eth0=3c59x
A. alias eth0=3c59x
A. alias eth0 3c59x
A. set eth0 3c59x
A. set eth0=3c59x
看一下,系统如何为Linux kernel 添加驱动模块并指定参数。
# cat /etc/modprobe.conf
alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptspi
alias snd-card-0 snd-ens1371
options snd-card-0 index=0
options snd-ens1371 index=0
remove snd-ens1371 { /usr/sbin/alsactl store 0 >/dev/null 2>&1 || : ; }; /sbin/modprobe -r –ignore-remove snd-ens1371
alias eth0 pcnet32
alias eth1 pcnet32
看最后两行,和尚的两张网卡都使用的pcnet32 驱动。
同样格式,题目中只有C正确了。
———-
以下是题外话。
在man 5 modprobe.conf 看此文件的描述。
modprobe.conf, modprobe.d – Configuration file/directory for modprobe
原来在这里配置之后,是为了 modprobe
再看
#man modprobe
modprobe – program to add and remove modules from the Linux Kernel
原来modprobe 可以为系统内核添加删除驱动模块。
linux的驱动模块是以文件形式存储的,
查看 pcnet32模块的具体信息可以用 modinfo命令
#modinfo pcnet32
filename: /lib/modules/2.6.18-8.el5/kernel/drivers/net/pcnet32.ko
license: GPL
description: Driver for PCnet32 and PCnetPCI based ethercards
author: Thomas Bogendoerfer
srcversion: F81443556AAE169CBF80F55
alias: pci:v00001023d00002000sv*sd*bc02sc00i*
alias: pci:v00001022d00002000sv*sd*bc*sc*i*
alias: pci:v00001022d00002001sv*sd*bc*sc*i*
depends: mii
vermagic: 2.6.18-8.el5 SMP mod_unload 686 REGPARM 4KSTACKS gcc-4.1
parm: debug:pcnet32 debug level (int)
parm: max_interrupt_work:pcnet32 maximum events handled per interrupt (int)
parm: rx_copybreak:pcnet32 copy breakpoint for copy-only-tiny-frames (int)
parm: tx_start_pt:pcnet32 transmit start point (0-3) (int)
parm: pcnet32vlb:pcnet32 Vesa local bus (VLB) support (0/1) (int)
parm: options:pcnet32 initial option setting(s) (0-15) (array of int)
parm: full_duplex:pcnet32 full duplex setting(s) (1) (array of int)
parm: homepna:pcnet32 mode for 79C978 cards (1 for HomePNA, 0 for Ethernet, default Ethernet (array of int)
[root@usb3 proc]#
推荐文章 编译内核操作流程 其中介绍了为内核添加模块的内容。
从 LPI/LPIC 201 问题学习Linux(017) 日志的配置文件 /etc/syslog.conf
Please enter the complete path to the main configuration file for syslogd, which logs system messages on Linux systems?
___________直接公布答案【/etc/syslog.conf】
看一下#man syslog.conf
The syslog.conf file is the main configuration file for the syslogd(8) which logs system messages on *nix
systems. This file specifies rules for logging. For special features see the sysklogd(8) manpage.
从 LPI/LPIC 201 问题学习Linux(024) 日志的主配置文件
Please enter the complete path to the main configuration file for syslogd, which logs system messages on Linux systems? Answer
__________
Correct Text:【 /etc/syslog.conf】
从 LPI/LPIC 201 问题学习Linux(018) 为内核打补丁
To restore the kernel source to the previous, unpatched,version,which of the following commands could be used?
A. patch -restore
B. patch -remove
C. patch -U
D. patch -undo
E. patch -R
考点是补丁的恢复参数。顺便复习一下做补丁、打补丁。
如果打的补丁有什么问题的话,我们就会做补丁的恢复工作。这时可以用-R 参数,取消打的补丁,恢复以前的状态。
公布答案【 E 】
———————————————————
题外话:(1)制作补丁
先看一下源文件
# cat source.txt
再看我们修改过的文件,
在第一行前插入标题
删除第三行的“制作过程:”
删除最后一行的
# cat target.txt
比较文件可以用diff ,格式如下
diff [options] from-file to-file
[root@usb3 tmp]# diff source.txt target.txt
0a1 <—-源文件头前面插入(append) 一行 ,也就是插入目标文件的第一行
> 拔丝地瓜 <—- 操作内容
3d3 <—-删除源文件(delete)第三行,用目标文件的第三行补充 。
< 制作过程:<—- 操作内容
7d6 <—-删除原文件(delete)第七行,用目标文件的第六行代替。
<—- 操作内容
厉害吧!看看diff 如何做补丁文件[root@usb3 tmp]# diff -Naur target.txt source.txt > test.patch
[root@usb3 tmp]# cat test.patch
— target.txt 2007-11-28 22:59:36.000000000 -0500
+++ source.txt 2007-11-28 22:57:26.000000000 -0500
@@ -1,6 +1,7 @@
[root@usb3 tmp]# patch -p0 < test.patch
patching file source.txt这里的-p参数是目录层数,因为不牵扯目录使用0.看看成果:
[root@usb3 tmp]# cat source.txt
再如何利用补丁,恢复源文件。[root@usb3 tmp]# patch -R < test.patch
patching file source.txt
[root@usb3 tmp]# cat source.txt
从 LPI/LPIC 201 问题学习Linux(019) 网络管理部分
Running tcpdump -nli eth1 ‘icmp’ shows the follwing output:11:56:35.599063 IP 192.168.123.5 > 194.25.2.129: icmp 64: echo request seq 111:56:35.670910 IP 194.25.2.129 > 192.168.123.5: icmp 64: echo reply seq 1What command, without options, parameters or arguments, was used on the host 192.168.123.5, to generate this output? Answer________________________________哪一个命令可以不用参数就可以列出 icmp协议的利用情况 ?只有ping 了,ping的过程就是利用 icmp 协议工作的过程了。根据版本不同ping 的位置可能是/sbin/ping 或者 /bin/ping 。本题是属于202网络管理部分,不知道为什么在201中出现了。相关的命令还有几个:/sbin/route
/sbin/ifconfig
/sbin/arp
/usr/sbin/arpwatch
/etc/
题外话:tcpdump 是可以在网络界面上 按指定的规则 获取数据包的工具。规则支持针对网络层、协议、主机、网络或端口的过滤,并提供and、or、not等逻辑语句来帮你去掉无用的信息。看一个例子查询数据链路层头信息[root@cos3 c]# tcpdump -e host 10.12.254.8
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
07:34:49.523163 00:1a:6b:52:31:cf (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 60: arp who-has tkh1uni003.paci.co.jp tell 10.12.104.113
07:34:51.308540 00:0c:f1:d7:ab:3a (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 60: arp who-has tkh1uni003.paci.co.jp tell 10.12.102.35
07:34:53.511545 00:e0:18:e6:8e:32 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 60: arp who-has tkh1uni003.paci.co.jp tell 10.12.104.219
07:34:53.732263 00:e0:00:c4:8c:25 (oui Unknown) > 00:13:72:cd:da:91 (oui Unknown), ethertype IPv4 (0x0800), length 831: tkh1uni003.paci.co.jp.webcache > 10.12.103.91.airs: P 2936829140:2936829905(765) ack 1105359815 win 24616 <nop,nop,timestamp 1972406392 51347>
07:34:53.807607 00:13:72:cd:da:91 (oui Unknown) > 00:e0:00:c4:8c:25 (oui Unknown), ethertype IPv4 (0x0800), length 1514: 10.12.103.91.1472 > tkh1uni003.paci.co.jp.webcache: . 1284332590:1284334038(1448) ack 3868921452 win 7761 <nop,nop,timestamp 51613 1972403740>
07:34:53.810126 00:13:72:cd:da:91 (oui Unknown) > 00:e0:00:c4:8c:25 (oui Unknown), ethertype IPv4 (0x0800), length 590: 10.12.103.91.1472 > tkh1uni003.paci.co.jp.webcache: P 1448:1972(524) ack 1 win 7761 <nop,nop,timestamp 51613 1972403740>
07:34:53.855128 00:13:72:cd:da:91 (oui Unknown) > 00:e0:00:c4:8c:25 (oui Unknown), ethertype IPv4 (0x0800), length 66: 10.12.103.91.airs > tkh1uni003.paci.co.jp.webcache: . ack 765 win 8760 <nop,nop,timestamp 51614 1972406392>
07:34:53.870818 00:e0:00:c4:8c:25 (oui Unknown) > 00:13:72:cd:da:91 (oui Unknown), ethertype IPv4 (0x0800), length 66: tkh1uni003.paci.co.jp.webcache > 10.12.103.91.1472: . ack 1972 win 24616 <nop,nop,timestamp 1972406415 51613>
07:34:53.910730 00:07:e9:51:5a:81 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 60: arp who-has tkh1uni003.paci.co.jp tell 10.12.102.46
07:34:53.955855 00:c0:a8:7e:16:34 (oui Unknown) > Broadcast, ethertype ARP (0x0806), length 60: arp who-has tkh1uni003.paci.co.jp tell 10.12.103.228 MAN的说明DESCRIPTION
Tcpdump prints out the headers of packets on a network interface that match the boolean expression. It can also be run
with the -w flag, which causes it to save the packet data to a file for later analysis, and/or with the -r flag, which
causes it to read from a saved packet file rather than to read packets from a network interface. In all cases, only pack-
ets that match expression will be processed by tcpdump. Tcpdump will, if not run with the -c flag, continue capturing packets until it is interrupted by a SIGINT signal (gener-
ated, for example, by typing your interrupt character, typically control-C) or a SIGTERM signal (typically generated with
the kill(1) command); if run with the -c flag, it will capture packets until it is interrupted by a SIGINT or SIGTERM sig-
nal or the specified number of packets have been processed.
公布答案【/sbin/ping or /bin/ping 】
从 LPI/LPIC 201 问题学习Linux(020) 一张物理网卡绑定多个IP
Which TWO of the following commands could be used to add a second IP address to eth0?A. ifconfig eth0 -add -ip 192.168.123.10B. ifconfig eth0:1 192.168.123.10C. ifconfig eth0-1 192.168.123.10D. ifconfig eth0 +192.168.123.10E. ifconfig eth0:sub1 192.168.123.10考点: 如何增加虚拟网卡及指定IP用ifconfig 可为物理网卡添加别名,实现一张物理网卡绑定多个IP的目的。为eth0 网卡增加IP192.168.123.10[root@pckk ~]# ifconfig eth0:1 192.168.1.100
[root@pckk ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:2B:62:AA
inet addr:10.12.103.55 Bcast:10.12.255.255 Mask:255.255.0.0
inet6 addr: fe80::20c:29ff:fe2b:62aa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2558 errors:0 dropped:0 overruns:0 frame:0
TX packets:132 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:210764 (205.8 KiB) TX bytes:19468 (19.0 KiB)
Interrupt:10 Base address:0x1400
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:2B:62:AA
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:10 Base address:0x1400
或者不用数字,使用别名,如mynic01,
数字可以从0开始哦. eth0:0 也是合法的。
[root@pckk proc]# ifconfig eth0:mynic01 192.168.1.101
[root@pckk proc]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:2B:62:AA
inet addr:10.12.103.55 Bcast:10.12.255.255 Mask:255.255.0.0
inet6 addr: fe80::20c:29ff:fe2b:62aa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12122 errors:0 dropped:0 overruns:0 frame:0
TX packets:1114 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1005342 (981.7 KiB) TX bytes:128634 (125.6 KiB)
Interrupt:10 Base address:0x1400
eth0:mynic01 Link encap:Ethernet HWaddr 00:0C:29:2B:62:AA
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:10 Base address:0x1400
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:2B:62:AA
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:10 Base address:0x1400
可以新增IP的物理地址与实际使用的 eth0 的物理地址相同。上面的方法可临时为Server添加IP,重启之后就不存在了。想保存设置的话,可以在/etc/sysconfig/network-config/下,按照eth0的配置,添加eth0:1 或者 eth0:mynic01 的配置文件。[root@cos3 network-scripts]# cp ifcfg-eth0 ifcfg-eth0:mynic01
[root@cos3 network-scripts]# cat ifcfg-eth0:mynic01
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=dhcp
#HWADDR=00:0c:29:0e:1e:7c
ONBOOT=yes
TYPE=Ethernetcopy之后要更改设备名,与文件名相同。
更改之后如下:[root@cos3 network-scripts]# cat ifcfg-eth0:mynic01
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0:mynic01
BOOTPROTO=dhcp
#HWADDR=00:0c:29:0e:1e:7c
ONBOOT=yes
TYPE=Ethernet注意,和尚使用的DHCP,要指定IP的话使用IPADDR=xxx.xxx.xxx.xxx,并添加网管之类的….
公布答案【BE】
从 LPI/LPIC 201 问题学习Linux(021) 用mkisofs 制作ISO镜像文件
What command is used to create a file-system to be burned to a CD ? (Please enter the command without the path or any options or parameters )
Answer:
______________mkisofs is effectively a pre-mastering program to generate an ISO9660/JOLIET/HFS hybrid filesystem.
mkisofs命令是预制 ISO9660/JOLIET/HFS混合文件系统原盘的有力工具。man 如是说。使用最广的光盘文件系统是ISO9660,我们可以在 /etc/fstab 中找到根据。特征是文件名多遵从8.3形式。JOLIET则是使用Unicode 多国编码,支持多国语言,是由微软制定的ISO9660的扩展规范。当前的很多操作系统都支持JOLIET,当然包括linux。至于HFS(Hierarchical File System),在日本称【MacOS标准格式 】。据wiki上说,是Mac OS 8.1以后使用的标准,,是由Apple开发的MFS进化来的。为方便学习,我们制作一个etc目录的iso 文件,在windows下查看。其中用到了-o (object) 参数.[root@cos3 /]# mkisofs -o /etc01.iso /etc
INFO: UTF-8 character encoding detected by locale settings.
Assuming UTF-8 encoded filenames on source filesystem,
use -input-charset to override.
mkisofs: Symlink /etc/rmt ignored – continuing.
mkisofs: Symlink /etc/httpd/run ignored – continuing.
mkisofs: Symlink /etc/httpd/logs ignored – continuing.
mkisofs: Symlink /etc/httpd/modules ignored – continuing….
79.91% done, estimate finish Sat Oct 20 10:25:46 2007
85.24% done, estimate finish Sat Oct 20 10:25:45 2007
90.55% done, estimate finish Sat Oct 20 10:25:46 2007
95.89% done, estimate finish Sat Oct 20 10:25:46 2007
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 645120
Path table size(bytes): 4400
Max brk space used 16a000
93871 extents written (183 MB)全是文本文件竟然有近200M…汗。又是一个汗,在windows 下文件名、目录名全是大写,并且因为unix与windows的换行符不同,在windows看来文件内容是一行一行………。并且长文件名都截成了8个字符,如果截断名字之后重名,则取前六个字符,加下划线,再加一个尾字母。既然是文件名的问题,再用支持长文件名的 Joliet文件格式试试。参数-J Generate Joliet directory records in addition to regular iso9660 file names. [root@cos3 /]# mkisofs -J -o /etc02.iso /etcWarning: creating filesystem with (nonstandard) Joliet extensions
but without (standard) Rock Ridge extensions.
It is highly recommended to add Rock Ridge
INFO: UTF-8 character encoding detected by locale settings.
Assuming UTF-8 encoded filenames on source filesystem,
use -input-charset to override.
….在windows 下用Daemon manager 查看没有问题了。再挂接到Linux看一下#mount /etc02.iso /mnt/tmpcd -o loop 文件名也没有问题了。注意加上 -o loop 参数的含义是用文件来模拟块设备。
参见 Linux下loop device的使用
mkisofs 还可以制作启动ISO镜像文件。
从 LPI/LPIC 201 问题学习Linux(022) 日志配置文件
Which of the following must be included in th syslogd configuration file, so that ONLY kernel related messages with the priority crit are reported?A. kern.crltB. kern.!critC. kern.=critD.kern.*=crit
E.kern.-crit
公布答案【C kern.=crit】问题是问日志系统的主要配置文件syslog.conf的配置格式。先看man 是如何介绍的。#man syslog.conf
DESCRIPTION
The syslog.conf file is the main configuration file for the syslogd(8)
which logs system messages on *nix systems. This file specifies rules
for logging. For special features see the sysklogd(8) manpage. Every rule consists of two fields, a selector field and an action
field. These two fields are separated by one or more spaces or tabs.
The selector field specifies a pattern of facilities and priorities
belonging to the specified action.
Lines starting with a hash mark (‘‘#’’) and empty lines are ignored.
syslog.conf 文件是很多*nix系统中都是syslogd日志守护进程的主要配置文件。为日志指定了运行的规则,具体的特性可以查看sysklogd(8).
每一个规则都包含了两部分,一个限定范围字段selector和动作字段action。字段之间被一个或多个空格、制表符所分割。selector字段指定了action 字段所适用的工具、应用程序和优先权属性。
以井号”#”标记开头的行将被忽略。
SELECTORS
The selector field itself again consists of two parts, a facility and a priority, separated by a period
(‘‘.’’). Both parts are case insensitive and can also be specified as decimal numbers, but don’t do that,
you have been warned. Both facilities and priorities are described in syslog(3). The names mentioned
below correspond to the similar LOG_-values in /usr/include/syslog.h.
selector 字段本身又包含了两部分,facility(工具、应用程序名) 和 优先权,中间用点“.”分割。 两部分都不分大小写,并且还可以用十进制数字指定优先权,但是不推荐用数字,使用时会被警告的。这两部分都在syslog(3)里有记录。下面提到的各种名字都与 /usr/include/syslog.h 中的 LOG_名字 相对应。
The facility is one of the following keywords: auth, authpriv, cron, daemon, kern, lpr, mail, mark, news,
security (same as auth), syslog, user, uucp and local0 through local7. The keyword security should not be
used anymore and mark is only for internal use and therefore should not be used in applications. Anyway,
you may want to specify and redirect these messages here. The facility specifies the subsystem that pro-
duced the message, i.e. all mail programs log with the mail facility (LOG_MAIL) if they log using syslog.
The priority is one of the following keywords, in ascending order: debug, info, notice, warning, warn
(same as warning), err, error (same as err), crit, alert, emerg, panic (same as emerg). The keywords
error, warn and panic are deprecated and should not be used anymore. The priority defines the severity of
the message
The behavior of the original BSD syslogd is that all messages of the specified priority and higher are
logged according to the given action. This syslogd(8) behaves the same, but has some extensions.
In addition to the above mentioned names the syslogd(8) understands the following extensions: An asterisk
(‘‘*’’) stands for all facilities or all priorities, depending on where it is used (before or after the
period). The keyword none stands for no priority of the given facility.
You can specify multiple facilities with the same priority pattern in one statement using the comma
(‘‘,’’) operator. You may specify as much facilities as you want. Remember that only the facility part
from such a statement is taken, a priority part would be skipped.
从 LPI/LPIC 201 问题学习Linux(023) 合理的备份计划
What backup arrangement should be used for an intranet web server the contents of which is updated fairly regularly by different staff?
A. Daily incremental backups with a weekly full backup tape sent off-site
B. Monthly full backups with the tape sent off-site
C. Daily full backups with all tapes sent off-site
D. Weekly full backups with all tapes sent off-site
E. Daily full backups with one tape sent off-site per week.
Correct: A