标签:liunx开机服务
[root@oldboy rc3.d]# chkconfig --list|grep 3:on|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk ‘{print "chkconfig",$1,"off"}‘
chkconfig abrt-ccpp off
chkconfig abrtd off
chkconfig acpid off
chkconfig atd off
chkconfig auditd off
chkconfig blk-availability off
chkconfig cpuspeed off
chkconfig haldaemon off
chkconfig ip6tables off
chkconfig irqbalance off
chkconfig kdump off
chkconfig lvm2-monitor off
chkconfig mdmonitor off
chkconfig messagebus off
chkconfig netfs off
chkconfig postfix off
chkconfig udev-post off
[root@oldboy rc3.d]# chkconfig --list|grep 3:on|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk ‘{print "chkconfig",$1,"off"}‘|bash
[root@oldboy rc3.d]# chkconfig --list|grep 3:on
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sysstat 0:off 1:on 2:on 3:on 4:on 5:on 6:off
开机启动管理
setup第四项(不重要)可以设置
3、chkconfig 命令主要用来更新(启动或停止)和查询系统服务的运行级信息。
chkconfig[--add][--del][--list][系统服务] 或 chkconfig [--level <等级代号>][系统服务][on/off/reset]
--level《等级号》指定读系统服务要在哪一个执行等级中开启或关闭
--list sshd 产看指定服务是否开机自启动
主要管理/etc/init.d/sshdstart 下的文件
原理实现:
!!!脚本开头必须包含chkconfig管理的代码
chkconfig :12345 13 98
description: oldboy test
1、把脚本放到/etc/init.d下面,并且可执行,希望被chkcofig管理,就用添加进去chkconfig --add sshd
2、添加进去的默认在哪个级别上启动看开发脚本中chkconfig的配置,服务启动顺序和关闭顺序也是看脚本中的chkconfig的配置
3、chkconfig --level 3 sshd on实质
rm -f /etc/rc.d/rc3.d/Knnsshd ln -s/etc/init.d/sshd /etc/rc.d/rc3.d/Snnsshd
4、关闭chkconfig --level 3 sshd off
rm -f /etc/rc.d/rc3.d/Snnsshd ln -s/etc/init.d/sshd /etc/rc.d/rc3.d/Knnsshd
[root@zhang ~]# chkconfig --list crond
crond 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@zhang ~]# chkconfig --level 3crond on
[root@zhang ~]# chkconfig --list crond
crond 0:off 1:off 2:off 3:on 4:off 5:off 6:off
[root@zhang ~]# chkconfig --level 245crond off
[root@zhang init.d]# vi oldboy
# chkconfig: 2345 91 61
echo "Welcome to oldboytraining:"
[root@zhang init.d]# cat oldboy
# chkconfig: 2345 91 61
echo "Welcome to oldboytraining:"
[root@zhang init.d]# chmod +x oldboy
[root@zhang init.d]# /etc/init.d/oldboystrt
Welcome to oldboy training:
[root@zhang init.d]# /etc/init.d/oldboy start
Welcome to oldboy training:
[root@zhang init.d]# chkconfig --addoldboy
[root@zhang init.d]# chkconfig --listoldboy
oldboy 0:off 1:off 2:on 3:on 4:on 5:on 6:off
--exclude=data/2排除 过滤data下的文件2其余都打包
[root@Oldboy ~]# tar zcvf/tmp/zhang.tar.gz data --exclude=4.txt
data/
data/7.txt
data/8.txt
1、尽量切换到打包目录的上一级目录,然后用相对路径打包,除非是你想保留完整路径
[root@zhang /]# tar zcvf /tmp/root.tar.gz ./root
[root@zhang /]# ls /tmp
456.txt oldboy.tar.gz ssh-AKUVKh1729 zhang.txt
oldboy root.tar.gz test.txt
[root@zhang /]# tar tf /tmp/root.tar.gz
./root/
./root/install.log.syslog
./root/.tcshrc
./root/test.txt
./root/anaconda-ks.cf
[root@zhang ~]# tar zcvf data.tar.gz./data --exclude=data/2
./data/
./data/4
./data/5
./data/6
./data/3
./data/10
./data/1
./data/9
./data/7
./data/8
[root@oldboy opt]# mkdir test
[root@oldboy opt]# cd test/
[root@oldboy test]# touch stu{01..10}
[root@oldboy test]# ls
stu01 stu02 stu03 stu04 stu05 stu06 stu07 stu08 stu09 stu10
[root@oldboy opt]# mkdir test
[root@oldboy opt]# cd test/
[root@oldboy test]# touch stu{01..10}
[root@oldboy test]# ls
stu01 stu02 stu03 stu04 stu05 stu06 stu07 stu08 stu09 stu10
[root@oldboy test]# ls -l
total 0
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu01
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu02
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu03
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu04
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu05
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu06
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu07
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu08
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu09
-rw-r--r-- 1 root root 0 Mar 15 05:49 stu10
[root@oldboy test]# cd ../
[root@oldboy opt]# tar zcvf test.tar.gz ./test
./test/
./test/stu03
./test/stu01
./test/stu02
./test/stu09
./test/stu06
./test/stu08
./test/stu10
./test/stu07
./test/stu05
./test/stu04
[root@oldboy opt]# ls
etc rh test test.tar.gz
[root@oldboy opt]# tar jcvf test.tar.bz ./test
./test/
./test/stu03
./test/stu01
./test/stu02
./test/stu09
./test/stu06
./test/stu08
./test/stu10
./test/stu07
./test/stu05
./test/stu04
[root@oldboy opt]# ll
total 20
drwxr-xr-x 82 root root 4096 Mar 15 04:22 etc
drwxr-xr-x. 2 root root 4096 Mar 26 2015 rh
drwxr-xr-x 2 root root 4096 Mar 15 05:49 test
-rw-r--r-- 1 root root 211 Mar 15 05:51 test.tar.bz
-rw-r--r-- 1 root root 231 Mar 15 05:50 test.tar.gz
[root@oldboy opt]# tar zxf test.tar.gz
[root@oldboy opt]# tar zxf test.tar.bz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
[root@oldboy opt]# tar jxf test.tar.bz
[root@oldboy opt]# tar xf test.tar.bz
[root@oldboy opt]# cat paichu.log
stu05
stu06
stu07
tar zcvfX data/data.tar.gz root/paichu.txt ./root
[root@oldboy opt]# tar zcvfX paichuX.tar.gz paichu.log ./test
./test/
./test/stu03
./test/stu01
./test/stu02
./test/stu09
./test/stu08
./test/stu10
./test/stu04
[root@oldboy opt]# tar tf paichuX.tar.gz
./test/
./test/stu03
./test/stu01
./test/stu02
./test/stu09
./test/stu08
./test/stu10
./test/stu04
tar zcvf /tmp/etc4.tar.gz --exclude=services --exclude=111 etc
17:43:50
find /root/ -type d -name "oldboy"|xargs tar zcvf oldboy.tar.gz
1064 find root -type f ! -name "*.txt"|xargs tarzcvf root/hello.gar.gz
find /root/ -type d -name "oldboy" -exec tar zcvf oldboy.tar.gz {} \;(错误的方法)
tar zcvf oldboy.tar.gz `find /root/ -type d -name "oldboy"`
tarzxvf框 xf最简解包看不到过程
-x 从归档文件中解压文件
[root@zhang ~]# tar zxvf/tmp/root.tar.gz
./root/
./root/install.log.syslog
./root/.tcshrc
./root/test.txt
./root/anaconda-ks.cfg
./root/.bashrc
./root/123.txt
[root@zhang data]# touch `seq 10`
[root@zhang data]# ls
1 10 2 3 4 5 6 7 8 9
[root@zhang ~]# ls kk
data.tar.gz
[root@zhang ~]# tar tf kk/data.tar.gz
./data/
./data/4
./data/5
./data/6
./data/3
./data/10
./data/1
./data/2
./data/9
./data/7
./data/8
可以讲一段文本的某一段 切 出来,处理的信息是以行为单位
-f依据-d分隔符将一段信息切割成为数段,用-f取出第几段的意思
[root@zhang ~]# ifconfig eth0|sed -n ‘2p‘|cut -d ‘:‘ -f 2
10.0.0.128 Bcast
[root@zhang ~]# ifconfig eth0|sed -n ‘2p‘|cut -d ‘:‘ -f 2|cut -d ‘ ‘ -f 1
本文出自 “11255195” 博客,请务必保留此出处http://11265195.blog.51cto.com/11255195/1758734
标签:liunx开机服务
原文地址:http://11265195.blog.51cto.com/11255195/1758734