Linux Learning Commands Summary ⑩③

Source: Internet
Author: User

#链接文件

Hard link: ln SRC linkfile

① hard links cannot span partitions

[email protected]_168_102_centos tmp]# Mount/dev/xvda1 on////dev/pts type Devpts (rw,mode=0620,gid=5/proc/sys/fs/binfmt_misc type Binfmt_misc (rw)/dev/xvdb1 on/tmp/  XVDB1 type EXT4 (rw)/dev/xvdb2 on/tmp//tmp/xvdb1/test/tmp/xvdb2/newtestln:creating hard link ' /tmp/xvdb2/newtest ' = '/tmp/xvdb1/test ': Invalid cross-device link

② cannot create a hard link to a directory

[Email protected]_168_102_centos tmp]# ln/tmp/wanghan/tmp/new_wanghanln: '/tmp/wanghan ': Hard link not Allowed for Directory

③ hard Links will change the number of times a file is linked

[[Email Protected]_168_102_centos tmp]# ls-l t*-rw-r--r--1 root root 153] 11:48/tmp/test.sh/tmp/-l t*-rw-r--r--2 root root 153 11:48 test.sh

④ hard links to the same inode as the original file

[Email protected]_168_102_centos tmp]# ls-li458763-rw-r--r--2 root root        153 11:48 new_test.sh<
   
     /c7>458763-rw-r--r--2 root root        153 11:48
     test.sh
   

#软链接又称符号链接: Ln–s SCR linkfile

① Symbolic links can be cross-partitioned

[email protected]_168_102_centos tmp]# Mount/DEV/XVDA1 on/type ext3 (rw,noatime,acl,user_xattr) proc on/proc type proc (rw) Sysfs on/sys type SYSFS (rw) devpts on/dev/pts type devpts (rw,mode=0620,gid=5) None on/proc/sys/fs/Binfmt_misc type Binfmt_misc (rw)/DEV/XVDB1 on/tmp/xvdb1 type EXT4 (rw)/DEV/XVDB2 on/tmp/xvdb2 type EXT4 (rw) [[email protected]_168_102_centos tmp]# LN-s/tmp/xvdb1/test/tmp/xvdb2/new_test[[email protected]_168_102_centos tmp]# ls-l/tmp/Xvdb2total16drwx------2 root root 16384 16:37 lost+foundlrwxrwxrwx1 root root 16:55 new_test-/tmp/xvdb1/test

② Symbolic link file is not the same inode as the original file

[[Email Protected]_168_102_centos tmp]# ln-s/tmp/ceshi.sh/tmp/-li   458762-rw-r--r--1 root root        153 11:49 ceshi.sh458768 lrwxrwxrwx 1 root root from 16:57         new_ceshi.sh

③ can create symbolic links to directories

[Email protected]_168_102_centos tmp]# ln-s/tmp/wanghan/tmp/-l1 root root         22 17 : New_wanghan,/tmp/wanghandrwxr-xr-x 2 root root 4096, 20:57 Wanghan        

④ Symbolic link does not change the number of times the original file was linked

[[Email Protected]_168_102_centos tmp]# ls-li   458762-rw-r--r--1 root root        153-11:49 CE shi.sh458768 lrwxrwxrwx 1 root root from         16:57 new_ceshi.sh-/tmp/ceshi.sh

#解压缩命令

Gzip Unzip Tool

-L-rw-r--r--1 root root         11:49 ceshi.sh.gz

GZIP-C: The compression structure is sent to standard output, which can be saved by using redirection, thereby preserving the original file

[[Email Protected]_168_102_centos ~~]# gzip-c test.sh >~]# ls-8-rw-r--r--1 root root
   
    5 17:15
     test.sh-rw-r--r--1 root root-17:16 test.sh.gz
   

Gzip-d: Extracting Files

[Email protected]_168_102_centos ~]# ls-4-rw-r--r--1 root root, 17:15~]# gzip-~]# LS-4-rw-r--r--1 root root 5 17:15 test.sh

Zcat: Direct display of the contents of the compressed package

[Email protected]_168_102_centos ~]# zcat yum.conf.gz [main]cachedir=/var/cache/yum/$basearch/$ Releaseverkeepcache=0debuglevel=2logfile=/var/log/yum.logexactarch=1  Obsoletes=1gpgcheck=1plugins=1installonly_limit=5

BZIP2 Decompression Tool

[[Email Protected]_168_102_centos ~~]# ls-4-rw-r--r--1 root root 648] 17:21 yum.conf.bz2

BZIP2-C: The compression structure is sent to standard output, which can be saved by using redirection, thereby preserving the original file

[[Email Protected]_168_102_centos ~]# bzip2-c yum.conf >~]# ls-8-rw-r--r--1 root root 969 22 1 7:21 yum.conf-rw-r--r--1 root root 648 17:30 yum.conf.bz2

Bzip2-d: Extracting Files

[Email protected]_168_102_centos ~]# bzip2-~]#ls-4-rw-r--r--1 root root 969-17:21 yum.conf

Bzcat: Direct display of the contents of the compressed package

[Email protected]_168_102_centos ~~]# bzcat yum.conf.bz2 [main]cachedir=/var/cache/yum/$basearch /$releaseverkeepcache=0debuglevel=2logfile=/var/log/yum.logexactarch=1

XZ Decompression Tool

[Email protected]_168_102_centos ~~~]# ls-4-rw-r--r--1 root root 696 17:21 yum.conf.x Z

XZ-C: The compression structure is sent to standard output, which can be saved by using redirection, thereby preserving the original file

[[Email Protected]_168_102_centos ~]# xz-c yum.conf >~]# ls-8-rw-r--r--1 root root 969 22 17:2 1 yum.conf-rw-r--r--1 root root 696 17:35 yum.conf.xz

Xz-d: Extracting Files

[Email protected]_168_102_centos ~~]# XZ-~]# lsyum.conf

Xzcat: Direct display of compressed package contents

[Email protected]_168_102_centos ~]# xzcat yum.conf.xz [main]cachedir=/var/cache/yum/$basearch/$ Releaseverkeepcache=0debuglevel=2logfile=/var/log/yum.logexactarch=1  Obsoletes=1

#tar归档工具

tar [options]–f file.tar Flie ...

-C: Create an archive

[Email Protected]_168_102_centos ~]# Tar-~]# ls-16-rw-r--r--1 root root   969 17:21 Yum.conf-rw-r--r--1 root root 10240 17:45 Yum.conf.tar

-X: Expand Archive

[Email protected]_168_102_centos ~~]# Tar-~]# lsyum.conf  Yum.conf.tar

-T: Do not expand direct view of archived files

[Email Protected]_168_102_centos ~]# Tar-tf yum.conf.tar yum.conf

Compress files and archive them:

Call the Gzip tool

-z:gzip

Compressed archive

[[Email Protected]_168_102_centos ~]# Tar-~]# ls-8-rw-r--r--1 root root 969-17:21 yum.conf -rw-r--r--1 root root 708 17:53 Yum.conf.gz.tar

Unzip the archive

[[Email protected]_168_102_centos ~]# ls   ~]# Tar-~]# lsyum.conf  Yum.conf.gz.tar

Calling the Bzip2 tool

-j:bzip2

Compressed archive

[Email Protected]_168_102_centos ~]# Tar-~]# ls yum.conf  yum.conf.bz2.tar

Unzip the archive

[Email protected]_168_102_centos ~~]# Tar-~]# lsyum.conf  Yum.conf.bz2.tar

Call the XZ tool

-j:xz

Compressed archive

[Email Protected]_168_102_centos ~]# Tar-~]# ls yum.conf  yum.conf.xz.tar

Unzip the archive

[Email Protected]_168_102_centos ~]# Tar-~]# ls yum.conf  yum.conf.xz.tar

Three types of compressed archives

-rw-r--r--1 root root 969 17:21 yum.conf-rw-r--r--1 root root 744-18:02 yum.conf.bz2-rw-  r--r--1 root root 708 18:02 Yum.conf.gz.tar-rw-r--r--1 root root 792-18:01 Yum.conf.xz.tar

Linux Learning Commands Summary ⑩③

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.