学习啦 > 学习电脑 > 操作系统 > Linux教程 >

BSD单用户级与多用户级启动脚本/etc/rc.d/rc.1

时间: 若木635 分享

  BSD单用户级启动脚本/etc/rc.d/rc.1

  脚本执行后,除了内核后台程序和init外都将关闭。登陆程序将开启,su:S1:respawn:/sbin/sulogin指定的功能。只有root用户才能用系统。

  --------------------------------/etc/rc.d/rc.1-------------------------------

  #!/bin/sh

  # 卸载远程文件系统

  echo "Unmounting remote filesystems..."

  /bin/umount -a -tnfs

  #下面两个信号后,除了内核后台程序和init外都将关闭。

  echo "Sending all processes the TERM signal..."

  /sbin/killall5 -15

  sleep 1

  echo "Sending all processes the KILL signal..."

  /sbin/killall5 -9

  ----------------------------end of /etc/rc.d/rc.1----------------------------

  BSD多用户终端脚本/etc/rc.d/rc.2

  /etc/rc.d/rc.2

  #!/bin/sh

  # 这个例子里网卡ip设置为192.168.0.2 。子网掩码为255.255.255.0,网关为192.168.0.1

  ### You may wish to add some commands changing sysctl states here, for example:

  # echo 1 > /proc/sys/net/ipv4/ip_forward # enable IP forwarding

  # echo 1 > /proc/sys/net/ipv4/tcp_syncookies # defend against SYN flood

  #设置网卡

  echo "Setting up loopback networking..."

  /sbin/ifconfig lo 127.0.0.1

  /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo

  echo "Setting up eth0..."

  /sbin/ifconfig eth0 192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0

  /sbin/route add -net default gw 192.168.0.1 netmask 0.0.0.0

  # 挂载远程文件系统

  echo "Mounting remote filesystems..."

  /bin/mount -a -v -tnfs

  ### you can create additional scripts for specific (networking) tasks,

  ### for example NFS, which needs a lot of daemons to work (see 3.2)

  ### or your firewall script:

  # 有防火墙则去下面注释

  # if [ -x /etc/rc.d/rc.firewall ]; then

  # echo "Restoring firewall rules..."

  # /etc/rc.d/rc.firewall

  # fi

  # 网络的一些后台程序,如NFS

  # if [ -x /etc/rc.d/rc.netdaemons ]; then

  # echo "Starting network daemons..."

  # /etc/rc.d/rc.netdaemons

  # fi

  # 用户个人配制文件

  if [ -x /etc/rc.d/rc.local ]; then

  /etc/rc.d/rc.local

  fi

75551