|
![]() | 作者: fireblue [fireblue]
![]() |
登录 |
我上次让夜色有空帮我把这个发上来,没想到这家伙比我还懒。 我今天在精华区里看见里面竟然只有一篇老大的建议...而且还有人问我怎么安装LINUX。所以我就把这个放上来了,希望对初学者有点帮助 一、LINUX 安装 安装方式: 光盘自启动 软盘启动: 硬盘、光盘、网络 制作安装启动盘: rawwrite boot.img 或 bootnet.img a: 安装步骤: 启动盘启动 选择安装方式 硬盘分区:fdisk 至少需要:linux native、Linux swap 选择安装点: / /dev/hda3 (linux native) /dos /dev/hda1 (dos) 选择软件包 配置系统:lilo、xwindow、mouse、时区、系统口令 使用X-Window 二、使用LINUX 基本命令 登录 login: root Password: <回车> 远程登录: telnet [机器名或IP地址] 注销 logout exit ^D 更改口令:passwd who [zrm@linux zrm]$ who root tty1 May 4 09:50 zrm tty2 May 4 10:09 whoami hostname uname [-a -s -r -v] date cal [2] 2001 echo " 提示 " clear mail [用户名] [zrm@linux zrm]$ mail zrm Subject: test test . Cc: [zrm@linux zrm]$ mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/zrm": 2 messages 2 new >N 1 zrm@linux.cau.edu.cn Fri May 4 10:14 13/336 "test" N 2 zrm@linux.cau.edu.cn Fri May 4 10:14 14/336 "tt" & 1 Message 1: From zrm Fri May 4 10:14:08 2001 Date: Fri, 4 May 2001 10:14:08 +0800 From: zrm@linux.cau.edu.cn To: zrm@linux.cau.edu.cn Subject: test test & 2 Message 2: From zrm Fri May 4 10:14:41 2001 Date: Fri, 4 May 2001 10:14:41 +0800 From: zrm@linux.cau.edu.cn To: zrm@linux.cau.edu.cn Subject: tt tt fas & mail -f mbox [zrm@linux zrm]$ mail -f mbox Mail version 8.1 6/6/93. Type ? for help. "mbox": 2 messages > 1 zrm@linux.cau.edu.cn Fri May 4 10:14 14/347 "test" 2 zrm@linux.cau.edu.cn Fri May 4 10:14 15/347 "tt" & talk 用户名 Message from Talk_Daemon@linux at 10:16 ... talk: connection requested by zrm@linux.cau.edu.cn. talk: respond with: talk zrm@linux.cau.edu.cn 系统重启:ctrl+alt+del (超级用户指令) reboot 停机: halt (超级用户指令) shutdown -f -h +2 "msg..." -f 强制执行 -h 停机(若无,则进入单用户方式) shutdown -r +10 (-r 重启) 命令行编辑:^C -- 强行中断 ^D -- 结束 ^S -- 挂起 ^Q -- 再运行 ^U -- 清命令行 history 光标上键 光标下键 虚终端切换: alt+F1 alt+F2 alt+F3 alt+F4 alt+F5 alt+F6 命令学习方法: man info 命令语法 命令 [选项] [参数] mail zrm mail -f mbox 三、文件操作 ls touch cat more tail mkdir cd rmdir 目录新建、进出、删除 cp rm mv 文件复制、删除、移动 ln 文件链接 vi -- 全屏字处理 find 按文件名查找 grep 按文件内容查找 wc ls [-l -a -d -F] [zrm@linux zrm]$ ls Desktop mbox sendmail-8.11.3 sendmail.8.11.3.tar.gz [zrm@linux zrm]$ ls -l %ld 总用量 1336 drwxr-xr-x 5 zrm zrm 4096 04 12 00:02 Desktop -rw------- 1 zrm root 694 05 4 10:15 mbox drwxr-xr-x 20 zrm root 4096 05 1 22:44 sendmail-8.11.3 -rwxr-xr-x 1 root root 1347756 05 1 22:40 sendmail.8.11.3.tar.gz [zrm@linux zrm]$ ls -a . .bash_logout .gnome .qti18nrc mbox .. .bash_profile .gnome-desktop .screenrc sendmail-8.11.3 .Xdefaults .bashrc .kde .vimrc sendmail.8.11.3.tar.gz .bash_history .emacs .kderc Desktop [zrm@linux zrm]$ ls -F Desktop/ mbox sendmail-8.11.3/ sendmail.8.11.3.tar.gz* cat mbox -- 显示文件内容 cat >abc.txt more mbox -- 分屏显示文件内容 vi -- 全屏字处理 文本编辑器 编辑状态:命令态[一般命令,行命令]、输入态 状态转换:命令态---->输入态--(ESC)-->命令态 一般命令: 插入 i I a A o O 移动光标 0 $ h j k l 光标左 光标下 光标上 光标右 ( ) { } H M L -- 至屏幕顶部 中部 底部 ctrl+f ctrl+b ctrl+d ctrl+u G nG 删除 J x dd 2dd dw cw cc u U - 取消上次修改 本行修改 块操作 yy 2yy y0 y$ p 查找 / 行命令: 从命令态进入 键: 0 1 2 w w! q q! w 文件名 wq x e aa.txt set autoident 或 set ai set number set nonumber 用VI字处理程序编写文件test.txt vi test.txt === 键 I 插入文字 Hi, my name is abc. how are you? bye! === ESC 键 :wq 存盘退出 查看内容: more test.txt 继续修改 文件test.txt find find . -name "a*" -print find / -name ping -print grep grep aa abc.txt wc [-l | -a |-c] 文件名 wc abc.txt wc -l abc.txt wc -w abc.txt wc -c abc.txt 四、shell(外壳) 用户登录环境,命令解释环境 [zrm@linux /etc]$ more /etc/shells /bin/bash /bin/sh /bin/ash /bin/bsh /bin/tcsh /bin/csh set -- 查看当前用户的环境变量 AA=aaaa echo $AA export AA [zrm@linux zrm]$ AA=abc [zrm@linux zrm]$ echo $AA abc [zrm@linux zrm]$ sh bash$ echo $AA bash$ exit [zrm@linux zrm]$ AA=abc;export AA [zrm@linux zrm]$ sh bash$ echo $AA abc .bash_profile (用户根目录下) bash用户执行命令的记录文件 注意:与history比较 PATH=$PATH:/bin:/usr/bin:/usr/sbin:. TERM=ansi export PATH TERM /etc/profile (定义所有用户的环境变量) PATH umask 022 重定向 标准输入(0) 标准输出(1) 标准错误输出(2) 标准输入重定向 < mail zrm < abc.txt 标准输入重定向 > >> cat >abc.txt ls >> abc.txt (覆盖) more abc.txt 标准错误重定向 2> cmd 2> err.txt cat er.txt find / -name a* -print > out.txt 2>&1 more out.txt 管道 | ls -l |more ls -l | wc -l 通配符 * -- 0至多个字符 ? -- 1个字符 [a,b,c,1-5,e-f] -- 任配一个字符 {01,02,03} 文件或目录名扩展 如: ls a* ls abc?.txt ls abc[1-5].txt mkdir abc{01,02,03} mkdir ab/{aa,aa/bb{01,02,03}} [zrm@linux zrm]$ ls a* abc.txt abc1.txt abc3.txt [zrm@linux zrm]$ ls abc?.txt abc1.txt abc3.txt [zrm@linux zrm]$ ls abc[1-5].txt abc1.txt abc3.txt umask -- 决定生成新文件的权限 umask 022 (缺省权限设置) touch aaa1 mkdir dir1 ls -l umask 002 touch aaa2 mkdir dir2 ls -l alias 命令别名 alias l="ls -la" l 作业控制 后台作业 & shell编程 例举:/etc/rc.d/rc3.d/S80sendmail === S80sendmail shell程序 #!/bin/sh 调用shell # #--说明语句 # sendmail This shell script takes care of starting and stopping # sendmail. # # chkconfig: 2345 80 30 # description: Sendmail is a Mail Transport Agent, which is the program \ # that moves mail from one machine to another. # processname: sendmail # config: /etc/sendmail.cf # pidfile: /var/run/sendmail.pid # Source function library. . /etc/rc.d/init.d/functions *** 执行另一shell程序 # Source networking configuration. . /etc/sysconfig/network # Source sendmail configureation. if [ -f /etc/sysconfig/sendmail ] ; then -- if 分枝语句 . /etc/sysconfig/sendmail else DAEMON=yes QUEUE=1h fi # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 -- 前一条件为真,执行后一命令 [ -f /usr/sbin/sendmail ] || exit 0 -- 前一条件为假,执行后一命令 RETVAL=0 # See how we were called. case "$1" in -- 开关分枝语句 start) # Start daemons. echo -n "Starting sendmail: " /usr/bin/newaliases > /dev/null 2>&1 for i in virtusertable access domaintable mailertable ; do if [ -f /etc/mail/$i ] ; then makemap hash /etc/mail/$i < /etc/mail/$i fi done daemon /usr/sbin/sendmail $([ "$DAEMON" = yes ] && echo -bd) \ $([ -n "$QUEUE" ] && echo -q$QUEUE) RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail ;; stop) # Stop daemons. echo -n "Shutting down sendmail: " killproc sendmail RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail ;; restart|reload) $0 stop $0 start RETVAL=$? ;; status) status sendmail RETVAL=$? ;; *) echo "Usage: sendmail {start|stop|restart|status}" exit 1 esac exit $RETVAL ==== end ==== 练习shell编程 vi mytest.sh === 进入VI 键I me=`whoami` if [ $me = root ] ; then echo "you are root user!" else echo "hi, $me, You aren't root user!" fi === ESC :wq 退出 执行shell: sh mytest.sh 换另一用户,再次执行 五、系统启动 lilo引导启动头 LINUX启动顺序:启动LINUX内核->安装文件系统->按启动方式启动服务进程 手工控制启动方式:init 数字 修改lilo引导启动头 lilo引导启动头 lilo:dos lilo:linux (或空回车) [root@linux /boot]# more /etc/lilo.conf boot=/dev/hda3 map=/boot/map install=/boot/boot.b message=/boot/cosixmsg prompt timeout=50 default=linux image=/boot/vmlinuz-2.2.16-3 label=linux vga=0x301 read-only root=/dev/hda3 other=/dev/hda1 label=dos LINUX启动顺序:启动LINUX内核->安装文件系统 ->执行init程序:按启动方式启动服务进程 /boot/vmlinuz 启动方式:单用户、多用户 more /etc/inittab.conf # 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 # Things to run in every runlevel. ud::once:/sbin/update # 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 # xdm is now a separate service x:5:respawn:/etc/X11/prefdm -nodaemon /etc/rc.d drwxr-xr-x 2 root root 4096 04 12 00:11 init.d -rwxr-xr-x 1 root root 2889 11 9 1999 rc -rwxr-xr-x 1 root root 1569 05 7 2000 rc.local -r-xr-x--- 1 news news 2964 07 25 2000 rc.news -rwxr-xr-x 1 root root 14394 08 2 2000 rc.sysinit drwxr-xr-x 2 root root 4096 04 12 00:11 rc0.d drwxr-xr-x 2 root root 4096 04 12 00:11 rc1.d drwxr-xr-x 2 root root 4096 04 12 00:11 rc2.d drwxr-xr-x 2 root root 4096 04 12 00:11 rc3.d drwxr-xr-x 2 root root 4096 04 12 00:11 rc4.d drwxr-xr-x 2 root root 4096 04 12 00:11 rc5.d drwxr-xr-x 2 root root 4096 04 12 00:11 rc6.d [root@linux /boot]# ls /etc/rc.d/init.d anacron functions inet killall network rstatd smb ypserv apmd gpm innd kudzu nfs rusersd snmpd arpwatch halt ipchains linuxconf nfslock rwalld syslog atd httpd irda lpd pcmcia rwhod xfs crond hzinput kdcrotate named portmap sendmail ypbind dhcpd identd keytable netfs random single yppasswdd 使用rc.local文件 最后运行的SHELL程序 查看: more /etc/rc.d/init.d/rc.local 手工控制启动方式:init 数字 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 6 - reboot (Do NOT set initdefault to this) 自定义服务启动方法 自编SHELL程序,放入相应引导目录, 或 放入rc.local程序中, 如: 加入 mail -s "Boot now" < /dev/null 修改lilo引导启动头 修改/etc/lilo.conf lilo - 重新安装引导头 六、用户管理 用户管理数据库 /etc/passwd /etc/group /etc/shadow 添加删除用户 adduser [-g group -p "password"] name userdel [-r] name 添加删除用户组 groupadd [-g gid [-o]] [-r] [-f] group groupdel group [root@linux /boot]# more /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin: adm:x:3:4:adm:/var/adm: gopher:x:13:30:gopher:/usr/lib/gopher-data: ftp:x:14:50:FTP User:/home/ftp: nobody:x:99:99:Nobody:/: zrm:x:500:0:Zou Renming:/home/zrm:/bin/bash 用户管理数据库格式为: 每行为一个用户的记录, 以":"来区分不同列 列1为: 用户名 列2为: 密码 列3为: 用户ID 列4为: 用户组ID 列5为: 用户信息 列6为: 用户根目录 列7为: 用户SHELL 若修改其中某一列值(如:用户SHELL),出现什么现象? zrm:x:500:0:Zou Renming:/home/zrm [root@linux /boot]# more /etc/group root:x:0:root bin:x:1:root,bin,daemon daemon:x:2:root,bin,daemon sys:x:3:root,bin,adm adm:x:4:root,adm,daemon 用户组管理数据库格式为: 每行为一个用户组的记录, 以":"来区分不同列 列1为: 用户组名 列2为: 密码 列3为: 用户组ID 列4为: 用户组成员列表 [root@linux /boot]# more /etc/shadow root:$1$K2pg8GSO$WNqt8YRFJOWwPFxum5SA//:11434:0:99999:7:-1:-1:134540356 bin:*:11423:0:99999:7::: ftp:*:11423:0:99999:7::: nobody:*:11423:0:99999:7::: zrm:$1$EBqAq.jp$uvxYBdXWyomQYSGR7kL4H.:11423:0:99999:7:-1:-1:134540356 比较文件/etc/passwd和/etc/shadow的存取权限。 添加删除用户 adduser user123 adduser -g nobody -p "" user124 tail /etc/passwd ls -l /home userdel user123 userdel -r user123 tail /etc/passwd ls -l /home 添加删除用户组 groupadd stu groupdel stu 从文件添加一组用户 建文件users,加用户记录,格式如/etc/passwd auser1:test::503::/home/auser1:/bin/bash auser2:test::503::/home/auser2:/bin/bash 执行:# newusers users 文件users 内容为: admin:password::0::/home/admin:/bin/bash usera_01:password::100::/home/usera_01:/bin/bash 七、文件系统管理 文件系统的自动安装 bash$ more /etc/fstab /dev/hda3 / ext2 defaults 1 1 /dev/hda1 /dos vfat defaults 0 0 /mnt/cdrom /mnt/cdrom supermount fs=iso9660,dev=/dev/cdrom 0 0 /mnt/floppy /mnt/floppy supermount fs=vfat,dev=/dev/fd0 0 0 none /proc proc defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 /dev/hda5 swap swap defaults 0 0 文件系统类型: ext2 ------ linux文件系统 ext3 ------ linux文件系统 swap ------ linux交换区文件系统 vfat ------ linux文件系统 iso9600 ------ 光盘文件系统 安装卸载文件系统 mount [-t 文件系统类型] 设备文件 安装点 umount 安装点 例:使用光盘: mount /dev/cdrom /mnt/cdrom 停止使用光盘: umount /mnt/cdrom 例:使用软盘: mount /dev/fd0 /mnt/floppy 停止使用软盘: umount /mnt/floppy 文件权限管理 缺省文件权限的设定: umask 022 666 - 022 = 644 (对应位相减) 读权限 = 4 写权限 = 2 执行权 = 1 644 - (读写执行 读执行 执行) umask 026 666 - 026 = 640 对目录的权限设定 777 - 026 = 751 (读写执行 读执行 执行) chown 用户[:用户组] 文件名 chmod 权限 文件 磁盘空间查看 df [-k] du [-sk] 检查文件系统 fsck [-f -y] [设备文件] 磁盘分区管理 fdisk /dev/hda 打包 tar cvf me.tar * tar tvf me.tar mdkir aaa cd aaa tar xvf ../me.tar tar cvf /dev/fd0 * tar tvf /dev/fd0 压缩 gzip me.tar ls 解压缩 gzip -d me.tar.gz gunzip me.tar.gz tar zxvf me.tar.gz compress me.tar uncompress me.tar.Z 八、进程管理 后台运行 & jobs ps kill [root@linux /root]# ls -Rl > out.txt & [1] 1397 [root@linux /root]# jobs [1]+ Done ls --color=tty --show-control-chars -Rl >out.txt find / -name "abc*" -print >tmp 2>&1 & jobs bg %1 fg %2 kill %1 jobs [root@linux /root]# ps -ef|grep ls root 1399 1280 0 14:41 tty2 00:00:00 grep ls [root@linux /boot]# ps PID TTY TIME CMD 1278 tty2 00:00:00 login 1280 tty2 00:00:00 bash 1345 tty2 00:00:00 ps [root@linux /boot]# ps -ef|grep sendmail UID PID PPID C STIME TTY TIME CMD root 811 1 0 09:48 ? 00:00:00 sendmail: accepting connections root 1342 1280 0 14:26 tty2 00:00:00 grep sendmail [root@linux /boot]# ps aux|grep sendmail USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 811 0.0 0.8 2128 1124 ? S 09:48 0:00 sendmail: acceptiroot 1344 0.0 0.4 2232 516 tty2 S 14:26 0:00 grep sendmail kill -HUP 811 kill -9 811 vmstat 查看虚拟内存 九、作业管理 at at 时间 atq atrm 工作号 cron [root@linux /root]# at now at> ls at> <EOT> warning: commands will be executed using /bin/sh job 3 at 2001-05-04 15:03 [root@linux /root]# atq [root@linux /root]# at 17:00 at> ls at> <EOT> warning: commands will be executed using /bin/sh job 4 at 2001-05-04 17:00 [root@linux /root]# atq 4 2001-05-04 17:00 a [root@linux /root]# atrm 4 [root@linux /root]# atq crontab [-u 用户名] -e 分 小时 天 月 星期几 <命令> 0,30 * * * * ls /root/out.a 30 1 * * * tar cvf /dev/fd0 /root/* crontab [-u 用户名] -l crontab [-u 用户名] -r /var/spool/cron 十、日志管理 /var/log [root@linux log]# ls -l /var/log %ld 总用量 632 -rw-r--r-- 1 root root 73863 05 4 09:48 boot.log -rw------- 1 root root 5125 05 4 15:20 cron -rw-r--r-- 1 root root 3951 05 4 09:48 dmesg -rw-r--r-- 1 root root 0 04 12 00:00 htmlaccess.log drwxr-xr-x 2 root root 4096 04 22 18:06 httpd -rw-r--r-- 1 root root 148044 05 4 14:53 lastlog -rw------- 1 root root 5545 05 4 15:03 maillog -rw------- 1 root root 297779 05 4 15:20 messages -rw-r--r-- 1 root root 6358 04 26 13:42 netconf.log drwxrwxr-x 3 news news 4096 04 11 23:58 news drwx------ 2 root root 4096 07 25 2000 samba -rw------- 1 root root 2098 05 4 14:53 secure -rw-r--r-- 1 root root 616 05 4 15:03 sendmail.st -rw------- 1 root root 0 04 11 23:56 spooler drwxr-xr-x 2 uucp uucp 4096 04 12 00:01 uucp -rw-rw-r-- 1 root utmp 177792 05 4 14:53 wtmp -rw------- 1 root root 0 04 12 00:01 xferlog /etc/syslog.conf ================= [root@linux log]# more /etc/syslog.conf # Log all kernel messages to the console. # Logging much else clutters up the screen. #kern.* /dev/console # Log anything (except mail) of level info or higher. # Don't log private authentication messages! *.info;mail.none;news.none;authpriv.none /var/log/messages # The authpriv file has restricted access. authpriv.* /var/log/secure # Log all the mail messages in one place. mail.* /var/log/maillog # Everybody gets emergency messages, plus log them on another # machine. *.emerg * # Save mail and news errors of level err and higher in a # special file. uucp,news.crit /var/log/spooler # Save boot messages also to boot.log local7.* /var/log/boot.log ...... ==================== rm /var/log/messages cp /dev/null /var/log/messages kill -HUP `cat /var/run/syslog.pid` 0 1 * * sun /usr/local/bin/newlogs 十一、软件包管理 rpm -qa |more rpm -ivv 包名 rpm -evv 包名 [root@linux conf]# rpm -qa |more Chinput-2.1-1 setup-2.1.8-1 filesystem-1.3.5-1 ...... [root@linux conf]# rpm -qa |wc -l 375 十二、超级服务器 inetd /etc/services =================== [root@linux log]# more /etc/inetd.conf # # inetd.conf This file describes the services that will be available # through the INETD TCP/IP super server. To re-configure # the running INETD process, edit this file, then send the # INETD process a SIGHUP signal. # # Version: @(#)/etc/inetd.conf 3.10 05/27/93 # # Authors: Original taken from BSD UNIX 4.3/TAHOE. # Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> # # Modified for Debian Linux by Ian A. Murdock <imurdock@shell.portal.com> # # Modified for RHS Linux by Marc Ewing <marc@redhat.com> # # <service_name> <sock_type> <proto> <flags> <user> <server_path> <args> # # Echo, discard, daytime, and chargen are used primarily for testing. # # To re-read this file after changes, just do a 'killall -HUP inetd' # #echo stream tcp nowait root internal #echo dgram udp wait root internal #discard stream tcp nowait root internal #discard dgram udp wait root internal # These are standard services. # ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd # # Shell, login, exec, comsat and talk are BSD protocols. # shell stream tcp nowait root /usr/sbin/tcpd in.rshd login stream tcp nowait root /usr/sbin/tcpd in.rlogind #exec stream tcp nowait root /usr/sbin/tcpd in.rexecd #comsat dgram udp wait root /usr/sbin/tcpd in.comsat talk dgram udp wait nobody.tty /usr/sbin/tcpd in.talkd ntalk dgram udp wait nobody.tty /usr/sbin/tcpd in.ntalkd #dtalk stream tcp wait nobody.tty /usr/sbin/tcpd in.dtalkd # # Pop and imap mail services et al # #pop-2 stream tcp nowait root /usr/sbin/tcpd ipop2d #pop-3 stream tcp nowait root /usr/sbin/tcpd ipop3d #imap stream tcp nowait root /usr/sbin/tcpd imapd # # =================== [root@linux log]# ps -ef|grep inetd root 735 1 0 09:48 ? 00:00:00 inetd [root@linux log]# kill -HUP 735 十三、网络配置 配置文件: /etc/resolv.conf /etc/nsswitch.conf 配置工具: netconfig netconf linuxconf [root@linux log]# more /etc/resolv.conf search cau.edu.cn nameserver 202.112.162.1 [root@linux log]# more /etc/nsswitch.conf # # /etc/nsswitch.conf # # An example Name Service Switch config file. This file should be # sorted with the most-used services at the beginning. passwd: files nisplus nis shadow: files nisplus nis group: files nisplus nis #hosts: db files nisplus nis dns hosts: files nisplus nis dns 十四、网络管理 ifconfig -a ping netstat -rn netstat -l netstat -a ================= [root@linux /root]# ifconfig -a eth0 Link encap:Ethernet HWaddr 00:00:B4:C5:EA:90 inet addr:202.112.162.5 Bcast:202.112.162.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:3105 dropped:0 overruns:0 carrier:6210 collisions:52785 txqueuelen:100 Interrupt:11 Base address:0xa000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:3924 Metric:1 RX packets:2087 errors:0 dropped:0 overruns:0 frame:0 TX packets:2087 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 ================= [root@linux /root]# ifconfig eth0 down [root@linux /root]# ifconfig eth0 202.112.162.20 up [root@linux /root]# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:00:B4:C5:EA:90 inet addr:202.112.162.20 Bcast:202.112.162.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:3141 dropped:0 overruns:0 carrier:6282 collisions:53397 txqueuelen:100 Interrupt:11 Base address:0xa000 ================= ================= [root@linux /root]# ping 202.112.162.5 PING 202.112.162.5 (202.112.162.5) from 202.112.162.5 : 56(84) bytes of data. 64 bytes from linux.cau.edu.cn (202.112.162.5): icmp_seq=0 ttl=255 time=0.1 ms 64 bytes from linux.cau.edu.cn (202.112.162.5): icmp_seq=1 ttl=255 time=0.0 ms 64 bytes from linux.cau.edu.cn (202.112.162.5): icmp_seq=2 ttl=255 time=0.0 ms 64 bytes from linux.cau.edu.cn (202.112.162.5): icmp_seq=3 ttl=255 time=0.0 ms --- 202.112.162.5 ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 0.0/0.0/0.1 ms ================= ================= [root@linux /root]# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 202.112.162.5 0.0.0.0 255.255.255.255 UH 0 0 0 eth0 202.112.162.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 202.112.162.99 0.0.0.0 UG 0 0 0 eth0 0.0.0.0 202.112.162.254 0.0.0.0 UG 0 0 0 eth0 ================= ================= [root@linux /root]# netstat -l 活动Internet连接 (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:www *:* LISTEN tcp 0 0 *:smtp *:* LISTEN tcp 0 0 *:printer *:* LISTEN tcp 0 0 *:linuxconf *:* LISTEN tcp 0 0 *:finger *:* LISTEN tcp 0 0 *:login *:* LISTEN tcp 0 0 *:shell *:* LISTEN tcp 0 0 *:telnet *:* LISTEN tcp 0 0 *:ftp *:* LISTEN tcp 0 0 *:auth *:* LISTEN tcp 0 0 *:716 *:* LISTEN tcp 0 0 *:sunrpc *:* LISTEN udp 27936 0 *:ntalk *:* udp 0 0 *:talk *:* udp 0 0 *:714 *:* udp 0 0 *:1024 *:* udp 0 0 *:sunrpc *:* raw 0 0 *:icmp *:* 7 raw 0 0 *:tcp *:* 7 Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node Path unix 0 [ ACC ] STREAM LISTENING 743 /dev/printer unix 0 [ ACC ] STREAM LISTENING 865 /tmp/.font-unix/fs-1 unix 0 [ ACC ] STREAM LISTENING 811 /dev/gpmctl ================= 十五、应用服务器的管理 apache - WWW服务器 /etc/httpd /home/httpd [root@linux conf]# ls -l /etc/rc.d/rc3.d/S85* lrwxrwxrwx 1 root root 23:56 /etc/rc.d/rc3.d/S85httpd -> ../init.d/httpd [root@linux conf]# more /etc/httpd/conf/httpd.conf ======================== ## ## httpd.conf -- Apache HTTP server configuration file ## # # ServerType is either inetd, or standalone. Inetd mode is only supported on # Unix platforms. # ServerType standalone # # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # NOTE! If you intend to place this on an NFS (or otherwise network) # mounted filesystem then please read the LockFile documentation # (available at <URL:http://www.apache.org/docs/mod/core.html#lockfile>); # you will save yourself a lot of trouble. # # Do NOT add a slash at the end of the directory path. # ServerRoot "/etc/httpd" Port 80 User nobody Group nobody #ServerName localhost DocumentRoot "/home/httpd/html" <Directory /> Options FollowSymLinks AllowOverride None </Directory> # # Note that from this point forward you must specifically allow # particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it # below. # # # This should be changed to whatever you set DocumentRoot to. # <Directory "/home/httpd/html"> # # This may also be "None", "All", or any combination of "Indexes", # "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews". # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # Options Indexes Includes FollowSymLinks # # This controls which options the .htaccess files in directories can # override. Can also be "All", or any combination of "Options", "FileInfo", # "AuthConfig", and "Limit" # # AllowOverride None AllowOverride All # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory> # # UserDir: The name of the directory which is appended onto a user's home # directory if a ~user request is received. # UserDir public_html DirectoryIndex index.html index.htm index.shtml index.cgi Alias /icons/ "/home/httpd/icons/" <Directory "/home/httpd/icons"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/" <Directory "/home/httpd/cgi-bin"> AllowOverride None Options ExecCGI Order allow,deny Allow from all </Directory> .......... ======================== [root@linux conf]# /etc/rc.d/rc3.d/S85httpd restart Shutting down http: [ 成功 ] Starting httpd: [ 成功 ] ps -ef|grep http [root@linux conf]# ps -ef|grep http root 1792 1 0 16:00 ? 00:00:00 httpd nobody 1798 1792 0 16:00 ? 00:00:00 httpd nobody 1799 1792 0 16:00 ? 00:00:00 httpd nobody 1800 1792 0 16:00 ? 00:00:00 httpd nobody 1801 1792 0 16:00 ? 00:00:00 httpd nobody 1802 1792 0 16:00 ? 00:00:00 httpd nobody 1803 1792 0 16:00 ? 00:00:00 httpd nobody 1804 1792 0 16:00 ? 00:00:00 httpd nobody 1805 1792 0 16:00 ? 00:00:00 httpd lynx http://localhost 维护WWW日志 查看日志/etc/httpd/logs [root@linux conf]# more /etc/httpd/logs/access_log 202.112.162.99 - - [22/Apr/2001:18:23:03 +0800] "GET / HTTP/1.0" 200 2511 202.112.162.99 - - [22/Apr/2001:18:32:15 +0800] "GET /zrm HTTP/1.0" 301 305 202.112.162.99 - - [22/Apr/2001:18:32:16 +0800] "GET /zrm/ HTTP/1.0" 200 644 202.112.162.99 - - [22/Apr/2001:18:32:23 +0800] "GET /zrm/aa.txt HTTP/1.0" 200 1 202.112.162.99 - - [22/Apr/2001:18:38:54 +0800] "GET /zrm HTTP/1.0" 301 305 202.112.162.99 - - [22/Apr/2001:18:38:55 +0800] "GET /zrm/ HTTP/1.0" 200 644 202.112.162.99 - - [22/Apr/2001:18:39:06 +0800] "GET /zrm/aa.txt HTTP/1.0" 200 1 清除日志 cp /dev/null /etc/httpd/logs/access_log [此贴被 fireblue(fireblue) 在 10月20日21时59分 编辑过] |
地主 发表时间: 10/20 21:38 |
![]() | 回复: magic [buaaytt] ![]() |
登录 |
very good! |
B1层 发表时间: 10/21 09:21 |
![]() | 回复: xmgu [xmgu] ![]() |
登录 |
有些帮助 |
B2层 发表时间: 10/23 21:20 |
![]() | 回复: nothing [eson] ![]() |
登录 |
good. i like it. |
B3层 发表时间: 11/10 22:36 |
![]() | 回复: tenhan [angy] ![]() |
登录 |
Very well, i'd like ,but isn't very uesed. |
B4层 发表时间: 11/11 15:42 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号