用编辑工具(如vi)编写一个Shell程序,用于对系统进行设置。#!/bin/shcase $# in0) ftphome="`grep '^ftp:' /etc/passwd | cut -d: -f6`";;1) if [ "$1" = "start" ]; thenftphome="`grep '^ftp:' /etc/passwd | cut -d: -f6`"elseftphome=$1fi;;*) echo "Usage: $0 [anon-ftp-root]"exit 1;;esacif [ -z "${ftphome}" ]; thenecho "$0: ftphome must be non-null"exit 2fiif [ "${ftphome}" = "/" -o "${ftphome}" = "/usr" ]; thenecho "$0: ftphome must not be / or /usr"exit 2fiif [ ! -d ${ftphome} ]; thenmkdir ${ftphome}fiif [ ! -d ${ftphome}/usr/bin ]; thenmkdir -p ${ftphome}/usr/binficp /usr/bin/ls ${ftphome}/usr/binchmod 111 ${ftphome}/usr/bin/lschown root ${ftphome}/usr/binchmod 555 ${ftphome}/usr/binif [ -r ${ftphome}/bin ]; thenmv -f ${ftphome}/bin ${ftphome}/Obinfiln -s usr/bin ${ftphome} if [ ! -d ${ftphome}/usr/lib ]; thenmkdir -p ${ftphome}/usr/libfiif [ ! -d ${ftphome}/etc ]; thenmkdir -p ${ftphome}/etcficp /usr/lib/ld.so /usr/lib/ld.so.1 ${ftphome}/usr/libfor lib in libc libdl libintl libw libnsl libsocket nss_nis nss_nisplus nss_dns nss_filesdocp /usr/lib/${lib}.so.1 ${ftphome}/usr/librm -f ${ftphome}/usr/lib/${lib}.soln -s ./${lib}.so.1 ${ftphome}/usr/lib/${lib}.sodonecp /usr/lib/straddr.so.2 ${ftphome}/usr/lib rm -f ${ftphome}/usr/lib/straddr.soln -s ./straddr.so.2 ${ftphome}/usr/lib/straddr.socp /etc/passwd /etc/group /etc/netconfig ${ftphome}/etcchmod 555 ${ftphome}/usr/lib/*chmod 444 ${ftphome}/etc/*chown root ${ftphome}/usr/lib ${ftphome}/etcchmod 555 ${ftphome}/usr/lib ${ftphome}/etcif [ ! -d ${ftphome}/dev ]; thenmkdir -p ${ftphome}/devfiprefix=/devices/pseudo/mm@0:for device in zeroline=`ls -l ${prefix}${device} | sed -e 's/,//'`major=`echo $line | awk '{print $5}'`minor=`echo $line | awk '{print $6}'`rm -f ${ftphome}/dev/${device}mknod ${ftphome}/dev/${device} c ${major} ${minor}doneprefix=/devices/pseudo/clone@0:for device in tcp udp ticotsorddoline=`ls -l ${prefix}${device} | sed -e 's/,//'`major=`echo $line | awk '{print $5}'`minor=`echo $line | awk '{print $6}'`rm -f ${ftphome}/dev/${device}mknod ${ftphome}/dev/${device} c ${major} ${minor}donechmod 666 ${ftphome}/dev/*chown root ${ftphome}/devchmod 555 ${ftphome}/dev#建立一个匿名FTP服务目录,并设立可读可写属性if [ ! -d ${ftphome}/pub ]; thenmkdir -p ${ftphome}/pubfichown ftp ${ftphome}/pubchmod 777 ${ftphome}/pub3. 编辑/etc/passwd和/etc/shadow文件
新闻热点
疑难解答