Linux 基础知识(六.二)

1、复制/etc/rc.d/rc.sysinit至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#
[root@server01 tmp]# cp /etc/rc.d/rc.sysinit /tmp/
[root@server01 tmp]# sed -n "s@^[[:space:]]\+@#&@gp" rc.sysinit
  • #    . /etc/sysconfig/network
  • #    HOSTNAME=localhost
  • # mount -n -t proc /proc /proc
  • # mount -n -t sysfs /sys /sys >/dev/null 2>&1
  • # modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb
  • # mount -n -t usbfs /proc/bus/usb /proc/bus/usb
  • # if [ -r "/selinux/enforce" ] ; then
  • # SELINUX_STATE=$(cat "/selinux/enforce")
  • # else
  • # # assume enforcing if you can't read it
  • # SELINUX_STATE=1
  • # fi
  • ……
  • #  chmod 0664 /var/run/utmpx /var/log/wtmpx
  • #       /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-*  \
  • #       /tmp/scrollkeeper-*  /tmp/ssh-* \
  • #       /dev/.in_sysinit
  • # curswap=$(awk '/^\/dev/ { print $1 }' /proc/swaps | while read x; do get_numeric_dev dec $x ; echo -n " "; done)
  • # swappartitions=$(blkid -t TYPE=swap -o device)
  • # if [ x"$swappartitions" != x ]; then
  • # for partition in $swappartitions ; do
  • # [ ! -e $partition ] && continue
  • # majmin=$(get_numeric_dev dec $partition)
  • # echo $curswap | grep -qw "$majmin" || action $"Enabling local swap partitions: " swapon $partition
  • # done
  • # fi
  • #  if strstr "$cmdline" netprofile= ; then
  • #    for arg in $cmdline ; do
  • #        if [ "${arg##netprofile=}" != "${arg}" ]; then
  • #    /usr/sbin/system-config-network-cmd –profile ${arg##netprofile=}
  • #        fi
  • #    done
  • #  fi
  • # touch /var/run/confirm
  • #    /bin/plymouth –sysinit

2、复制/boot/grub/grub.conf至/tmp目录,删除/tmp/grub.conf文件中的行首的空白字符
[root@server01 tmp]# cp /boot/grub/grub.conf /tmp/
[root@server01 tmp]# sed -n "s@^[[:space:]]\+@@p" grub.conf
  • root (hd0,0)
  • kernel /vmlinuz-2.6.32-573.el6.x86_64 ro root=/dev/mapper/vg_server01-lv_root rd_NO_LUKS rd_LVM_LV=vg_server01/lv_root.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_DM  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_server01/lv_swap rhgb quiet
  • initrd /initramfs-2.6.32-573.el6.x86_64.img

3、删除/tmp/rc.sysinit文件中以#开头,且后面跟了至少一个空白字符的行的#和空白字符
[root@server01 tmp]# sed -rn "s@^#[[:space:]]+@@p" rc.sysinit 
  • /etc/rc.d/rc.sysinit – run once at boot time
  • Taken in part from Miquel van Smoorenburg's bcheckrc.
  • Check SELinux status
  • Print a text banner.
  • Only read this once.
  • Initialize hardware
  • Set default affinity
  • Load other user-defined modules
  • Load modules (for backward compatibility with VARs)
  • Configure kernel parameters
  • Set the hostname.
  • Sync waiting for storage.
  • Device mapper & related initialization
  • Start any MD RAID arrays that haven't been started yet
  • Remount the root filesystem read-write.
  • Clean up SELinux labels
  • If relabeling, relabel mount points.
  • Mount all other filesystems (except for NFS and /proc, which is already
  • mounted). Contrary to standard usage,
  • filesystems are NOT unmounted in single user mode.
  • The 'no' applies to all listed filesystem types. See mount(8).
  • Update quotas if necessary
  • Check to see if a full relabel is needed
  • Initialize pseudo-random number generator
  • Configure machine if necessary.
  • Clean out /.
  • Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might…
  • Clean up /var.
  • Clean up utmp/wtmp
  • Clean up various /tmp bits
  • Make ICE directory
  • Start up swapping.
  • Set up binfmt_misc
  • Boot time profiles. Yes, this should be somewhere else.
  • Now that we have all of our basic modules loaded and the kernel going,
  • let's dump the syslog ring somewhere so we can find it later
  • create the crash indicator flag to warn on crashes, offer fsck with timeout
  • Let rhgb know that we're leaving rc.sysinit

4、为/tmp/grub.conf文件中的前三行的行首加#号
[root@server01 tmp]# sed -n "1,3s@^@#@p" grub.conf
  • ## grub.conf generated by anaconda
  • ##
  • ## Note that you do not have to rerun grub after making changes to this file

5、将/etc/yum.repos.d/CentOS-Media.repo文件中所有的enabled=0或gpgcheck=0修改最后的0为1
[root@server01 tmp]# sed -rn "s@(enabled|gpgcheck)=0@\1=1@p" /etc/yum.repos.d/CentOS-Media.repo 
  • enabled=1

6、每4小时执行一次对/etc目录的备份,备份至/backuup目录中,保存的目录名称为形如etc-201504020202
[root@server01 tmp]# crontab -e
* */4 * * * /bin/tar cvf /backup/etc-$(date +%Y%m%d%H%M%S) /etc/*

7、每周2,4,6备份/var/log/messages文件至/backup/message_logs目录中,保存的文件名形如messages-20160402
[root@server01 tmp]# crontab -e
* * * * 2,4,6 /bin/cp /var/log/messages /backup/message_logs/messages-$(date +%Y%m%d)

8、每天每两小时取当前系统/proc/meminfo文件中的所有以S开头的信息至/stats/memory.txt文件中
[root@server01 message_logs]# mkdir /stats
[root@server01 ~]# crontab -e
* */2 * * * /bin/cat /proc/meminfo | /bin/grep -E "^[S]" &> /stats/memory.txt

9、工作日的工作时间内,每两小时执行一次echo "howdy"
[root@server01 ~]# crontab -e
* 9-18/2 * * 1,2,3,4,5 /bin/echo "howdy"


原创文章,作者:Tornado,如若转载,请注明出处:http://www.178linux.com/55335

(0)
TornadoTornado
上一篇 2016-11-14 08:29
下一篇 2016-11-14 08:30

相关推荐

  • CentOS6 编译安装httpd-2.4

       CentOS7的镜像中已经提供了httpd-2.4的rpm包,httpd-2.4相对于httpd2.2有较大的改进,在CentOS6下只能通过Apache官方网站提供的源码包编译安装。    有时候,我们需要应用http-2.4的某些特性,但是因为当前的发行版没有支持,所以我们需要自己编译安装。 httpd-2.…

    Linux干货 2016-07-27
  • 权限管理

           学习文件和目录的权限管理,不仅在学习上对我们的帮助很大,而且在工作上帮助也很大,因为你对文件或目录设置了权限,其他用户只能根据你设置的权限对文件或目录进行浏览,修改,删除或执行,也正是如此,权限的管理很重要。下面我就对Linux的权限管理进行简单的介绍。 Linux下的文件类型 -:普…

    Linux干货 2016-08-08
  • shell脚本的各种循环

    For循环 For循环格式      For   变量名  in    列表    ;   do         &nb…

    Linux干货 2016-08-21
  • Nginx代理MogileFS并实现负载均衡和高可用

    Nginx代理MogileFS并实现负载均衡和高可用 MogileFS nginx 负载均衡 前言 实验拓扑 实验环境 实验步骤 配置MogileFS 配置Nginx 总结 前言 上篇文章我们了解分布式系统和MogileFS的基本使用, 但是那样的架构是有问题的, 本篇文章我们来了解一下如何使用nginx-mogilefs-module-…

    大数据运维 2016-05-05
  • 【26期】Linux第六周学习小总结

        时光匆匆,一周时光悠然而逝,带给我们的只有知识的充实,和每日强大的自信心,学习的日益深入,慢慢的然我们的思绪和状态带回高中时光,吃饭上课睡觉三点一线的生活,枯燥中透露出稍微的晨曦,让每个明天都充满着期待,那我们的本周的学习中磁盘管理算是占了很大的比重,毕竟关于磁盘的知识很是难理解,那我就把本周的知识回顾温习,同时分享给大家。 &n…

    2017-08-19
  • 编译安装MariaDB源码包

        因为MySQL的发展趋势不甚乐观,MariaDB已替代MySQL被CentOS 7做为默认组件,如果想在CentOS 6中使用最新的MariaDB,则需要我们手动安装,其安装方式有三种:     1、RPM包安装     2、二进制…

    Linux干货 2015-06-08