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.www58058.com/55335

(0)
TornadoTornado
上一篇 2016-11-14
下一篇 2016-11-14

相關推薦

  • Linux系統vim文本編輯器

                                                      &nbsp…

    Linux干貨 2016-08-15
  • 文本

    一,復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其他用戶均沒 有任何訪問權限; cp -r /etc/skel/ /home/tuser1 chmod -R go= /home/tuser1 二,編輯/etc/group文件,添加組hadoop; vim /etc/group hadoop:x:100…

    Linux干貨 2016-11-20
  • LINUX基礎知識

    計算機的組成及其功能。 現代計算機體系將計算機分為控制器、運算器、存儲器、輸入設備和輸出設備5個部分 *控制器:控制器是整個計算機的中樞神經,其功能是對程序規定的控制信息進行解釋,并根據具體要求進行控制、調度程序、數據、地址,協調計 算機各個部分工作,協調計算機各部分工作及內存、IO設備等的訪問 *運算器:運算器是對數據進行各種算數運算和邏輯運算也就是對數據…

    Linux干貨 2018-02-25
  • 數據結構- 串的模式匹配算法:BF和 KMP算法

    Brute-Force算法的思想 1.BF(Brute-Force)算法   Brute-Force算法的基本思想是: 1) 從目標串s 的第一個字符起和模式串t的第一個字符進行比較,若相等,則繼續逐個比較后續字符,否則從串s 的第二個字符起再重新和串t進行比較。 2) 依此類推,直至串t 中的每個字符依次和串s的一個連續的字符序列相等,則稱模式匹…

    Linux干貨 2015-04-07
  • Linux入門詳解(第一周)

    Linux入門 1. 描述計算機的組成及其功能 計算機硬件的五大組成部分為:運算器、控制器、存儲器、輸入設備和輸出設備; CPU:CPU是執行存儲在主存中指令的引擎;內部又分為算數邏輯單元和控制單元,其中算數邏輯單元主要負責程序的運算與邏輯判斷,控制單元則主要是協調各周邊組件與各單元間的工作;此外CPU內還包含寄存器(如PC)和高速緩存等; 存儲器:這里指主…

    Linux干貨 2016-08-29
  • 文本處理工具

    分頁查看文件內容 less和more命令介紹 分頁查看文件內容:less和more less:一頁一頁地查看文件或STDIN輸出   # less FILE less的快捷鍵:     Ctrl+u:向上翻半屏     Ctrl+d:向下翻…

    Linux干貨 2016-08-07
欧美性久久久久