码迷,mamicode.com
首页 > 其他好文 > 详细

解决打包软链接打包失败问题

时间:2016-04-13 00:46:19      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:软连接

一般情况下打包文件时,如果直接打包软连接会导致打包失败,即没有将要打包的内容打包进去,这里提供tar打包参数-h

[root@localhost ~]# ll /etc/rc.local

lrwxrwxrwx. 1 root root 13 Nov 24 00:45 /etc/rc.local -> rc.d/rc.local

[root@localhost ~]# tar czf tar.gz /etc/rc.local

tar: Removing leading `/‘ from member names

[root@localhost ~]# ll

[root@localhost ~]# sz tar.gz

rz

Starting zmodem transfer.  Press Ctrl+C to cancel.

  100%     117 bytes  117 bytes/s 00:00:01       0 Errors


[root@localhost ~]# 

技术分享

发现打包结果并没有将/etc/rc.local下的内容打包进来

所以这里用-h参数

[root@localhost ~]# tar czfh rc.local.tar.gz /etc/rc.local

tar: Removing leading `/‘ from member names

[root@localhost ~]# ll

total 84

-rw-------. 1 root root  1508 Nov 24 00:48 anaconda-ks.cfg

drwxr-xr-x. 5 root root  4096 Jun 10  2015 fabric-scripts

-rw-r--r--. 1 root root 17062 Dec 28 10:03 fabric-scripts.tar.gz

-rw-r--r--. 1 root root 33502 Nov 24 00:48 install.log

drwxr-xr-x. 2 root root  4096 Apr  7 15:08 logs

drwxr-xr-x. 3 root root  4096 Mar 23 10:35 mysql-sql

-rw-r--r--. 1 root root   415 Apr 12 16:42 rc.local.tar.gz

-rw-r--r--. 1 root root   117 Apr 12 16:31 tar.gz

[root@localhost ~]# sz rc.local.tar.gz 

rz

Starting zmodem transfer.  Press Ctrl+C to cancel.

  100%     415 bytes  415 bytes/s 00:00:01       0 Errors


[root@localhost ~]# 

技术分享



[root@localhost ~]# tar xf rc.local.tar.gz 

[root@localhost ~]# ll

-rw-r--r--. 1 root root   415 Apr 12 16:42 rc.local.tar.gz

-rw-r--r--. 1 root root   117 Apr 12 16:31 tar.gz

[root@localhost ~]# cd etc/

[root@localhost etc]# ll

total 4

-rwxr-xr-x. 1 root root 420 Mar  8 14:36 rc.local

[root@localhost etc]# cat rc.local 

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don‘t

# want to do the full Sys V style init stuff.


touch /var/lock/subsys/local

#startup Openvpn on boot

/usr/local/sbin/openvpn --config /etc/openvpn/product.server.conf &

#add a iptables ruler

/sbin/iptables -t nat -I POSTROUTING -s 10.8.0.0/255.255.255.0 -o eth0 -j MASQUERADE

[root@localhost etc]# 

至此,用tar打包软连接实际目录下内容操作成功

本文出自 “平平淡淡才是真” 博客,请务必保留此出处http://ucode.blog.51cto.com/10837891/1763056

解决打包软链接打包失败问题

标签:软连接

原文地址:http://ucode.blog.51cto.com/10837891/1763056

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!