[root@li ~]# 加电--BIOS (basic input output system)--以什么设备来启动--/dev/sda -- mbr -- grub.conf --vmlinux and initramfs -- init -- /etc/inittab -- /etc/fstab -- /etc/rc.sysinit -- ls /etc/rcx.d -- /etc/rc.local --登录
[root@li ~]# rpm -qa |grep grub grub-0.97-13.5 [root@li ~]# rpm -qi grub-0.97-13.5
Summary : GRUB - the Grand Unified Boot Loader.
Description :
GRUB (Grand Unified Boot Loader) is an experimental boot loader
capable of booting into most free operating systems - Linux, FreeBSD,
NetBSD, GNU Mach, and others as well as most commercial operating
systems.
device.map iso9660_stage1_5 stage1
device.map.backup jfs_stage1_5 stage2
e2fs_stage1_5 menu.lst ufs2_stage1_5
fat_stage1_5 minix_stage1_5 vstafs_stage1_5
ffs_stage1_5 reiserfs_stage1_5 xfs_stage1_5
grub.conf splash.xpm.gz
lrwxrwxrwx 1 root root 22 Jun 3 2011 /etc/grub.conf -> ../boot/grub/grub.conf
[root@li vm]# diff /etc/grub.conf /boot/grub/grub.conf
[root@li vm]# md5sum /etc/grub.conf
37b9c539c0c4320fd297cd89ea6497ad /etc/grub.conf
[root@li vm]# md5sum /boot/grub/grub.conf
37b9c539c0c4320fd297cd89ea6497ad /boot/grub/grub.conf
default=0 --默认进入第一个系统
timeout=5 --5秒钟不选择,则进入默认default指定的系统;如果改为-1表示等待时间无限
splashimage=(hd0,0)/grub/splash.xpm.gz --指定grub背景图的路径;(hd0,0)表示的就是/dev/sda1,所以这个路径其实就是指/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-164.el5)
root (hd0,0) --表示/dev/sda1,也就是/boot
kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet --vmlinuz是/boot分区下的,名字不能错;root=LABEL=/是启动时要知道根分区是谁;这里写的是标签。但可以替换成/dev/sdax
initrd /initrd-2.6.18-164.el5.img --initrd的路径
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz --加/boot
title Red Hat Enterprise Linux Server (2.6.18-164.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet --加boot
initrd /boot/initrd-2.6.18-164.el5.img --加boot
LABEL=/ / ext4 defaults 1 1
LABEL=/boot /boot ext4 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
[root@localhost ~]# /dev/sda1 /boot
[root@localhost ~]# /dev/sda2 /
[root@localhost ~]# /dev/sda3 swap
[root@localhost ~]# /dev/sda4 扩展分区
grub>root (hd0,0) --进到/boot分区
grub>kernel /vmlinuz-xxxxxxx ro root=LABEL=/ --root分区不要写错,label形式或者/dev/sdax形式都可以
grub>initrd /initrd-xxxxxxxx
grub>boot --boot代表启动
Password:
Retype password:
$1$JWQIX/$tYXWeDn3HPj9LYZezTuTI/ --输两次密码就可以产生加密串
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz --在下面加上加密信息
password --md5 $1$JWQIX/$tYXWeDn3HPj9LYZezTuTI/
title Red Hat Enterprise Linux Server (2.6.18-164.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/1 rhgb quiet
initrd /initrd-2.6.18-164.el5.img
title Red Hat Enterprise Linux Server (2.6.18-164.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/1 rhgb quiet
password --md5 $1$JWQIX/$tYXWeDn3HPj9LYZezTuTI/
initrd /initrd-2.6.18-164.el5.img
/share/iso/rhel63-64.iso ----把iso放到/share/目录
/share/rhel63-64.iso
/share/vmlinuz
/share/initrd.img
/share/images/
/share/isolinux/
grub > root (hd0,4) --进入到/dev/sda5,也就是我的/share目录
grub > kernel /vmlinuz
grub > initrd /initrd.img
grub > boot --回车后,就进入到了安装界面
# 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)--多用户模式,但没有NFS,没有网络
# 3 - Full multiuser mode --带网络的文本多用户模式,如果3模式没有网络的话就和2模式一样
# 4 - unused --保留
# 5 - X11 --图形模式
# 6 - reboot (Do NOT set initdefault to this) --重启
#
id:5:initdefault: --设定开机后默认的启动级别,不要设成0或者6,如果设成0或者6致命开机不了,在grub的选择界面按E编辑这一次启动进入5模式(临时,只对这次进系统有效),进入后再修改/etc/initab(这是永久生效)
# 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 --/etc/rc.d/init.d目录下脚本的软链接
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 --定义ctrl+alt+del三键重启功能,只能在tty文本界面才能生效,服务器一般都建议把这一句给注释掉,防止误操作
# 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 --定义了六个文本终端
[root@li ~]# at now + 10 minutes
[root@li ~]# at now + 1 hours
[root@li ~]# at now + 1 days
[root@li ~]# at now + 1 weeks
[root@li ~]# at now + 1 months
[root@li ~]# at now + 1 years
[root@li ~]# atq
1 2017-11-03 09:46 a root
[root@li ~]# at -l
1 2017-11-03 09:46 a root
[root@li ~]# file /var/spool/at/a00001017fee0a
/var/spool/at/a00001017fee0a: Bourne shell script text executable
/etc/at.allow --在这里可以写上允许执行at的普通用户(格式方面也要注意,不要乱空格),一个用户一行;存在的话就不用去考虑at.deny
/etc/at.deny --在这里可以定上拒绝执行at的普通用户,一个用户一行;如果at.allow不存在,才生效
#!/bin/bash
pts=`who |grep -v "(:0" |awk '{print $2}'`
ip=`who |grep -v "(:0" |awk -F"(" '{print $2}'|awk -F")" '{print $1}'`
pid=`ps -ef |grep $pts |grep sshd |grep -v grep |awk '{print $2}'`
kill -9 $pid
iptables -A INPUT -p tcp --dport 22 -s $ip -j REJECT
at now + 30 minutes << EOF
iptables -D INPUT -p tcp --dport 22 -s $ip -j REJECT
EOF
sleep 2
#!/bin/bash
while true
do
line=`who |grep -v "(:" |wc -l`
for i in `seq $line`
do
pts=`who |grep -v "(:" |awk '{print $2}' |head -$i |tail -1`
ip=`who |grep -v "(:" |awk -F"(" '{print $2}'|awk -F")" '{print $1}' |head -$i |tail -1`
pid=`ps -ef |grep $pts |grep sshd |grep -v grep |awk '{print $2}'`
kill -9 $pid
iptables -A INPUT -p tcp --dport 22 -s $ip -j REJECT
at now + 30 minutes << EOF > /dev/null 2>&1
iptables -D INPUT -p tcp --dport 22 -s $ip -j REJECT
EOF
done
sleep 2
done
#!/bin/bash
echo "check ssh...."
while true
do
who | awk -F"(" '{print $2}' | sed 's/.$//' | while read ip
do
if [ `echo $ip | awk -F"." 'END{print NF}'` -eq 4 ]
then
echo "$ip ssh close"
iptables -A INPUT -p tcp --dport 22 -s $ip -j REJECT
ipssh=`who | awk '{print $2}' | head -$i | tail -1`
ipsshid=`ps -ef | grep "@$ipssh" | awk '{print $2}'`
kill -9 $ipsshid 2> /dev/null
echo iptables -D INPUT -p tcp --dport 22 -s $ip -j REJECT | at now + 30 minutes
fi
done
sleep 2
done
#!/bin/bash
goal=`date +%s -d 20350101`
while true
do
now=`date +%s`
day=$[($goal-$now)/86400]
hour=$[($goal-$now-$day*86400)/3600]
minute=$[($goal-$now-$day*86400-$hour*3600)/60]
second=$[$goal-$now-$day*86400-$hour*3600-$minute*60]
clear
echo "离2013年还有$day天:$hour时:$minute分:$second秒"
sleep 1
done
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
* 代表每分钟,每小时,每日,每星期,每月..........
, 代表分隔时间 1,5,6,7
- 代表一个时间范围 7-20
/n 代表每隔n个单位 */3 --不能写成/3,而要写成*/3
示例:
01 1,5,12,18,23 * * * --每天的1,5,12,18,23点的第一分钟
01 * 5-15 * * --每月的5号到15号的每小时的第一分钟
*/2 * * * * --每两分钟
*/3 1,3,8 1-5 3-6 7 --每年的3到6月的1到5号的1,3,8点的每三分钟 (只有星期天才行)
* * * * * root echo 'crontab'> /dev/pts/2 --每分钟都会去echo一个crontab到/dev/pts/2终端
* * * * * root run-parts /etc/cron.minutely --做一个每分钟都会执行的目录,把每分钟都要执行的脚本任务放到这个目录里,注意要有执行权限
crontab -e -u d --编辑d用户的时间任务 crontab -l -u d --列出d用户的时间任务 crontab -r -u d --删除d用户的时间任务 crontab的使用限制: 和atd服务是一样的 /etc/cron.allow --写上允许使用crontab的普通用户名,一行写一个;有些文件的话就不考虑/etc/cron.deny /etc/cron.deny --写上拒绝使用crontab的普通用户名,一行写一个;如果/cron.allow不存在,才生效
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
1 65 cron.daily run-parts /etc/cron.daily
7 70 cron.weekly run-parts /etc/cron.weekly
30 75 cron.monthly run-parts /etc/cron.monthly
1 65 cron.daily run-parts /etc/cron.daily
Jul 8 11:45:27 li anacron[3104]: Anacron 2.3 started on 2011-07-08
Jul 8 11:45:27 li anacron[3104]: Will run job `cron.daily' in 65 min.
Jul 8 11:45:27 li anacron[3104]: Will run job `cron.weekly' in 70 min.
Jul 8 11:45:27 li anacron[3104]: Jobs will be executed sequentially