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)
上一篇 2016-11-14 08:29
下一篇 2016-11-14 08:30

相关推荐

  • Nginx

        Nginx(发音同engine x)是一个 Web服务器,也可以用作反向代理,负载平衡器和 HTTP缓存。Nginx 可以部署在网络上使用 FastCGI,脚本,SCGI 处理程序,WSGI 应用服务器或 Phusion 乘客模块的动态 HTTP 内容,并可作为软件负载均衡器。Nginx 使…

    Linux干货 2017-08-29
  • 构建私有CA

    构建私有CA 我们采用openssl这个软件来实现 所有首先我们来看下该软件的配置文件 实现环境 centos 7.2 [root@redhat7 ~]# rpm -qc openssl  //可以看到该命令没有任何输出,我们可以思考该软件包还存在其他的支包 [root@redhat7 ~…

    Linux干货 2016-09-28
  • N29 第一周作业

    1、描述计算机的组成及其功能。
    2、按系列罗列Linux的发行版,并描述不同发行版之间的联系与区别。
    3、描述Linux的哲学思想,并按照自己的理解对其进行解释性描述。
    4、说明Linux系统上命令的使用格式;详细介绍ifconfig、echo、tty、startx、export、pwd、history、shutdown、poweroff、reboot、hwclock、date命令的使用,并配合相应的示例来阐述。
    5、如何在Linux系统上获取命令的帮助信息,请详细列出,并描述man文档的章节是如何划分的。
    6、请罗列Linux发行版的基础目录名称命名法则及功用规定

    Linux干货 2018-03-05
  • Nginx反向代理、负载均衡的实现

    概述:     上篇介绍了Nginx作为web服务器的一些常用配置的说明,但是在实际生产环境中,Nginx更多是作为前端的负载均衡器,反代前端用户请求到后端真实的web服务器上,完成LNAMP的组合的方式存在。本篇就介绍一些Nginx作为http的反向代理和前端负载均衡调度器的一些常用配置,具体包括:  &n…

    Linux干货 2016-11-01
  • Linux基础知识(三)-用户管理组管理,正则grep,文本处理

    1、列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,只显示一次即可。 2、取出最后登录到当前系统的用户的相关信息。 3、取出当前系统上被用户当作其默认shell的最多的那个shell。 4、将/etc/passwd中的第三个字段数值最大的后10个用户的信息全部改为大写后保存至/tmp/maxusers.txt文件中 5、取出当前主机的IP…

    Linux干货 2016-10-09
  • nginx配置(一)

    Nginx:http协议:web服务器(类似于httpd)、http reverse proxy(类似于httpd)、imap/pop3 reverse proxy NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/…

    Linux干货 2017-05-05