1、系统安装至少选择的五个包
@ system-tools
@ development-tools
@ text-internet
@ server-cfg
@ admin-tools
@ network-server
@ kernel-development
 

2、通过命令setup,设置系统运行必要服务
crond
network
xinetd
iptables
ssh
syslog
3、更改Shell提示符
vi /etc/profile
PS1='${USER}:${PWD}>'
4、将服务器的配置写入文件motd,登录服务器就可以看到。
vi /etc/motd
HOSTNAME:  vmware.host
IP   :  192.168.1.123
MEM  :  256M
CPU  :  Intel(R) Pentium(R) M processor 1600MHz
DISK :  250G
 

5、为了方便管理用户,加入用户时将其加入同一个组。
root:/usr/local>groupadd admins
root:/usr/local>useradd -G admins fei
root:/usr/local>id fei
uid=580(fei) gid=580(fei) groups=580(fei),505(admins)

6、安装sudo
tar zxvf bak/sudo-1.6.6.tar.gz
cd sudo-1.6.6/
./configure  --help
./configure
make
make install (root)
/usr/local/sbin/visudo

# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
User_Alias  USERADMIN=shell,test,aian,lei          添加一行修改成需要的用户
# Cmnd alias specification
Cmnd_Alias USERADMIN_COM=/usr/local/sbin/suroot          添加一行
# User privilege specification
root    ALL=(ALL) ALL
USERADMIN       ALL=USERADMIN_COM
注:在执行时使用sudo
 
5、防火墙
 
6、设置用户登录自动发邮件到指定的邮箱
      如果所有用户登录自动发自动到指定邮箱就编辑/etc/porfile文件,如果是某个用户登录自动发邮件到指定邮箱就编辑用户主目录下.bash_prefile文件。
bo:/home/bo>vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
#MAIL=/bin/mail
w > /tmp/wcheck
/bin/mail -s "$HOSTNAME  $USER Login `date +%m%d-%R`" [email]bo@163.com[/email] </tmp/wcheck -- -f $USER@$HOSTNAME
export PATH
unset USERNAME
 
 
针对所有用户登录自动发邮件到指定用户
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
        if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
           if [ "$2" = "after" ] ; then
              PATH=$PATH:$1
           else
              PATH=$1:$PATH
           fi
        fi
}
# Path manipulation
if [ `id -u` = 0 ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
fi
pathmunge /usr/X11R6/bin after

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
 
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
#setup JDK environment variable
JAVA_HOME=/home/jdk/jdk1.5.0_11
CLASSPATH=$JAVA_HOME/lib/tools.jar:JAVA_HOME/lib:JAVA_HOME/bin

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
fi
PS1='${USER}:${PWD}>'
w > /tmp/wcheck
/bin/mail -s "$HOSTNAME $USER Login `date +%m%d-%R`"
[email]bo@163.com[/email] </tmp/wcheck
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME CLASSPATH
for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done
 
unset i
unset pathmunge
 
 
 
注:1、 -- -f 是指定发件人的地址 (不知为什么不启作用)       2、如果要更改发件人地址与/etc/postfix/main.cf 文件中mydomain = testbo.com  参数有关。
 
7、troubleshooting 
该服务器是做DNS服务器的,工作需要要对服务器重新启动。执行reboot命令后,在公司就连接不上了。于是到机房服务器终端出现以下信息WARNING: couldn't open /etc/fstab: No such file or directory
fsck.ext2: Is a directory/:
………………
………………
………………
Give root password for maintenance
(or type Control-D to continue):
感觉事情不妙,既然是fstab文件没有了,就要从新创建这个文件,以前这个文件有备份,所以方便多了。
 
 
采取措施:
(Repair filesystem) 1 # mv /etc/fstab.old /etc/fstab
mv: cannot move '/etc/fstab.old' to '/etc/fstab': Read-only file system
(Repair filesystem) 2 # mount -o remount,rw /dev/sda1
Warning: can't open /etc/fstab: No such file or directory
(Repair filesystem) 3 #
(Repair filesystem) 4 # mv /etc/fstab.old /etc/fstab
(Repair filesystem) 5 #
 
借助Live CD(G4L):
# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
   -o options 主要用来描述设备或档案的挂接方式。常用的参数有:
  loop:用来把一个文件当成硬盘分区挂接上系统
  ro:采用只读方式挂接设备
  rw:采用读写方式挂接设备
  iocharset:指定访问文件系统所用字符集
# mount -t ext3 /dev/sda1 /mnt/sda1
# chroot /mnt/gentoo /bin/bash  (切入硬盘Linux 系统)
# env-update
>>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"
 
更改ssh 端口
[root@localhost ~]# vim /etc/ssh/sshd_config
 
# possible, but leave them commented.  Uncommented options change a
# default value.
Port 45678 加入
#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
[root@localhost ~]# /etc/init.d/sshd  restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
[root@localhost ~]#