好程序员云计算学习路线分享文件打包及压缩,建议针对目录
Demo: 复制未打包的文件到远程主机
[[email protected] ~]# du -sh /etc
39M /etc
[[email protected] ~]# time scp -r /etc [email protected]:/tmp //将/etc目录...
===打包,压缩===
[[email protected] ~]# tar -czf etc1.tar.gz /etc //-z 调用gzip : tar removeing 非报错
[[email protected] ~]# tar -cjf etc2.tar.bz2 /etc //-j 调用bzip2
[[email protected] ~]# tar -cJf etc3.tar.xz /etc //-J 调用xz
[[email protected] ~]# ll -h etc*
-rw-r--r--. 1 root root 8.7M 3月 12 00:08 etc1.tar.gz
-rw-r--r--. 1 root root 7.5M 3月 12 00:08 etc2.tar.bz2
-rw-r--r--. 1 root root 4.8M 3月 12 00:09 etc3.tar.xz
===解压,解包===
[[email protected] ~]# tar -tf sys.tar.xz
[[email protected] ~]# tar -xzvf etc1.tar.gz
[[email protected] ~]# tar -xvf etc1.tar.gz //无需指定解压工具,tar会自动判断
[[email protected] ~]# tar -xvf etc2.tar.bz2 -C /tmp //-C重定向到//tmp目录
[[email protected] ~]# tar xf etc3.tar.xz !!!!!!!!!!!!!!!自动寻找 记住这个就好了
file 可查看
==解压zip
[[email protected] ~]# unzip xxx.zip
压缩打包
gzip bzip2
[[email protected] tmp]# dd if=/dev/zero of=/tmp/data bs=100M count=2
in file out file block size count
[[email protected] tmp]# du -sh data -s 总共 -h 最大单位
[[email protected] tmp]# gzip data
[[email protected] tmp]# gunzip data.gz
[[email protected] tmp]# bzip2 data
[[email protected] tmp]# bunzip2 data.bz2
tar
[[email protected] tmp]# tar -cvf boot.tar /boot/ -c 创建 -v 显示过程 -f 文件
[[email protected] tmp]# tar -tvf boot.tar -t 查看
[[email protected] tmp]# tar -rvf boot.tar /root/install.log -r 追加打包
[[email protected] tmp]# tar -xvf boot.tar
[[email protected] tmp]# tar -cvf /home/boot.tar /boot/ 指定包存放路径
[[email protected] tmp]# tar -xvf /tmp/boot.tar -C /home/ 指定解压目录
调用gzip压缩
[[email protected] tmp]# tar -zcvf boot.tar.gz /boot/
[[email protected] tmp]# tar -ztvf boot.tar.gz
[[email protected] tmp]# tar -zxvf boot.tar.gz
调用bzip2压缩
[[email protected] tmp]# tar -jcvf boot.tar.bz2 /boot/
[[email protected] tmp]# tar -jtvf boot.tar.bz2
[[email protected] tmp]# tar -jxvf boot.tar.bz2
[[email protected] Packages]# rpm -ivh tree-1.5.3-2.el6.x86_64.rpm
-i 安装 -v显示过程 -h显示百分比
[[email protected] Packages]# rpm -q tree -q 检索
[[email protected] Packages]# rpm -qa | grep httpd 检索所有软件
[[email protected] Packages]# rpm -ql httpd 列出httpd所有文件位置
[[email protected] Packages]# rpm -ql httpd | cut -d \/ -f 2 | uniq
[[email protected] Packages]# rpm -qi tree 列出软件包信息
[[email protected] Packages]# rpm -qd httpd 查看软件文档
[[email protected] Packages]# rpm -qc httpd 查看配置文件
[[email protected] Packages]# rpm -qf /etc/man.config 通过文件查询对应软件包
[[email protected] Packages]# rpm -qf which mount
查找命令对应软件
[[email protected] Packages]# rpm -e tree 卸载
[[email protected] Packages]# rpm -ivh httpd-2.2.15-26.el6.x86_64.rpm --force 强制安装
未按装
[[email protected] Packages]# rpm -qpi tree-1.5.3-2.el6.x86_64.rpm
[[email protected] Packages]# rpm -qpl tree-1.5.3-2.el6.x86_64.rpm
解决依赖关系
[[email protected] Packages]# rpm -ivh httpd-devel-2.2.15-26.el6.x86_64.rpm
warning: httpd-devel-2.2.15-26.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
apr-devel is needed by httpd-devel-2.2.15-26.el6.x86_64
apr-util-devel is needed by httpd-devel-2.2.15-26.el6.x86_64
[[email protected] Packages]# rpm -ivh apr-devel-1.3.9-5.el6_2.x86_64.rpm
warning: apr-devel-1.3.9-5.el6_2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:apr-devel ########################################### [100%]
[[email protected] Packages]# rpm -ivh apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm
warning: apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
expat-devel is needed by apr-util-devel-1.3.9-3.el6_0.1.x86_64
[[email protected] Packages]# rpm -ivh expat-devel-2.0.1-11.el6_2.x86_64.rpm
warning: expat-devel-2.0.1-11.el6_2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:expat-devel ########################################### [100%]
[[email protected] Packages]# rpm -ivh apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm
warning: apr-util-devel-1.3.9-3.el6_0.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:apr-util-devel ########################################### [100%]
[[email protected] Packages]# rpm -ivh httpd-devel-2.2.15-26.el6.x86_64.rpm
warning: httpd-devel-2.2.15-26.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:httpd-devel ########################################### [100%]
[[email protected] Packages]# rpm -e apr-devel --nodeps 不检测依赖关系卸载
yum库的使用
1.[[email protected] mnt]# mkdir /yum
[[email protected] mnt]# mount -t iso9660 -o loop /var/ftp/rhel-server-6.4-x86_64-dvd.iso /yum/
2.[[email protected] mnt]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# touch yum.repo
[[email protected] yum.repos.d]# vim yum.repo
[rhel6.4] ------------------------库名字
name=rhel6.4 server -------------描述
baseurl=file:///yum -------------路径
gpgcheck=0 ----------------------是否校验key
enabled=1 -----------------------开启或者关闭
测试
[[email protected] yum.repos.d]# yum clean all 清除yum缓存
[[email protected] yum.repos.d]# yum makecache 建立yum缓存
[[email protected] yum.repos.d]# yum install httpd-devel 安装
[[email protected] yum.repos.d]# yum install -y httpd-devel
[[email protected] yum.repos.d]# yum reinstall -y httpd-devel 重新安装
[[email protected] yum.repos.d]# yum remove apr-devel 移除软件包
onal Development" "Development tools"
[[email protected] software]# chmod +x RealPlayer\®\;\ 11\ for\ Linux\ RealPlayer11GOLD.bin
[[email protected] software]# ./RealPlayer\®\;\ 11\ for\ Linux\ RealPlayer11GOLD.bin
[[email protected] software]# realplay
源码包lftp-3.5.10.tar.bz2
[[email protected] lftp-3.5.10]# rpm -e lftp 卸载rpm包的lftp
[[email protected] software]# tar -jxvf lftp-3.5.10.tar.bz2 -C /usr/local/src/
编译前检测和配置
[[email protected] lftp-3.5.10]# ./configure --prefix=/usr/local/lftp
编译
[[email protected] lftp-3.5.10]# make
安装
[[email protected] lftp-3.5.10]# make install
测试
[[email protected] lftp-3.5.10]# /usr/local/lftp/bin/lftp 172.16.110.1
[[email protected] lftp-3.5.10]# vim /etc/bashrc
PATH=/usr/local/lftp/bin:$PATH
export PATH
[[email protected] lftp-3.5.10]# lftp 172.16.110.1
lftp 172.16.110.1:/> ls
lftp 172.16.110.1:/> get biji.txt
原文地址:https://blog.51cto.com/14479068/2440312