Directory archive management under Linux (CentOS) and archive file System package compression

Source: Internet
Author: User
Tags file copy gz file parent directory

I. Management of Catalogue Archives 1. Common commands for operating directories:

(1), absolute path and relative path:

Absolute paths start with the root directory:/usr/local/java ("/" is the root directory, and the directory's entry)

Relative path is relative to the path of the current path, his writing is not from the root directory ("/") is written as: CD. /LOCAL/JDK This notation is relative to your current path you go up a level of directory, and then into the/LOCAL/JDK directory

(2), a symbol representing a different directory: .   Or./ represents the current directory, . . Or .. / represents the parent directory,-represents the previous working directory, ~ represents the home directory

(3), Common directory Operation command:

&, CD (change directory) modify directories, CD ~, CD/Modify Directory

&, PWD (print working directory) print working directory, PWD [-p] Display your current directory,-p is print real directory is not link directory

&, mkdir (make directory) to create a directory, mkdir [-PM] two parameters,-P can help you establish a multi-level directory, such as Mkdir-p/test1/test2/test3, and-M is in the establishment of the time to specify permissions, not Default permissions for pipe (umask)

&, RmDir (remove directory) remove directory, there are three cases, one, delete empty directory rmdir Second, delete this directory while you want to delete the parent directory of this directory, 三、一次 delete more than one directory is this directory and subdirectories: Rm-r This r is recursive delete, but also can add a parameter-F is to ignore the file under it, will be deleted at once!

(4), directory and file View Ls:ls can be followed by a lot of parameters, commonly used is ls-al (display long string characters, as well as the properties of the file directory), there are many like-I (Inode), and other use man ls check!

2. operation file Copy Delete move:

(1), copy: CP can copy the file directory, you can also establish a connection file, commonly used commands are as follows:

Cp-a Test.txt Test1.txt

cp-d Test.txt Test1.txt If the source file is a linked file attribute, copy the properties of the linked file without copying the file itself

Cp-f test.txt test1.txt-f (force) if the target file already exists, it will be tried once after removal

Cp-i Test.txt test1.txt If the destination file already exists, you will be asked to overwrite the target file before overwriting it! Common

Cp-l Test.txt Test1.txt A hard-connect connection file is established without copying the file itself

Cp-p Test.txt Test1.txt is copied in conjunction with the properties of the archive and is often used as a backup!

Cp-r recursive replication, the replication behavior in the directory! Common

(2), delete: RM [-fir] where F (force, mandatory strength) and I is the meaning of the inquiry and R is recursive delete!

(3), move rename: MV [-fiu] where F is also mandatory meaning-I if the target file already exists then ask whether to replace, and U for if the target file already exists, and the source is relatively new when it will be replaced

Mv-f Test.txt Test1.txt

Mv-i Test.txt Test1.txt

Mv-r Test.txt Test1.txt

3, the contents of the file View:

(1), command:  cat  start with the first line to display the contents of the archive
                      &N Bsp      tac  from the last line, you can see that the TAC is a cat backwards write!
                             nl   When displayed, output line number!
                             more one Page one page display file Content
                             Less Similar, but better than more is that he can page forward!
                             head just a few lines
                          Tail    just look at the end of a few lines
&NB Sp                         od   to read files in two import mode Case Content!

(2), cat [-bn] Common-B displays only the line number with the content, and-n displays all the line numbers!

(3), interception content: Head-n ++/-m intercept the first m line or after M line tail-n ++/-m intercept the last few lines

4, create an empty file, and can modify the time:

(1), create an empty file: Touch DocumentName

(2), change the time of the file to the current time:

Touch-c-T 050618032000 file

touch-d "6:03pm" file

touch-d "05/06/2000" file

touch-d "6:03pm 05/06/2000" file

5, the file preset permissions: When we set up the file, do not specify the permissions, then we set up the permissions of the file is what, here is the design to a default permissions problem:

(1), use Umask, umaks-s view the current preset permissions

(2), Umask 002 This number and chmod 002 means the opposite, the number after Umak represents the number removed from the user group other, and chmod represents the number given, see the following example: Umask 0 02 The file created under the permissions of 775 that is rwx rwx Rx, that is, to remove 0 from the user is also the RWX permission, and the group is the same, other removed the W permission!

Second, the directory and file system packaging and compression 1, packaging, compression commonly used directives:

(1),. Tar
Unpacking: Tar xvf filename.tar
Package: Tar cvf filename.tar DirName
(Note: Tar is packaged, not compressed!) )

(2),. GZ
Decompression 1:gunzip filename.gz
Decompression 2:gzip-d filename.gz
Compression: gzip FileName

(3),. GZ and. Tgz
Unzip: Tar zxvf FileName.tar.gz
Compress: Tar zcvf FileName.tar.gz DirName
(4),. BZ2
Unzip 1:bzip2-d filename.bz2
Decompression 2:BUNZIP2 filename.bz2
Compression: bzip2-z FileName

(5),. TAR.BZ2
Decompression: Tar jxvf FileName.tar.bz2
Compression: Tar JCVF FileName.tar.bz2 DirName

(6),. BZ
Decompression 1:bzip2-d filename.bz
Decompression 2:bunzip2 filename.bz
Compression: Unknown

(7) ,. TAR.BZ
Decompression: Tar jxvf FileName.tar.bz
Compression: Unknown

(8),. Z
Extract: uncompress filename.z
Compression: Compress FileName
(9),. Tar. Z

Decompression: Tar zxvf filename.tar.z
Compression: Tar zcvf filename.tar.z DirName

(10),. zip
Extract: Unzip Filename.zip
Compression: Zip filename.zip DirName

(11),. rar
Decompression: rar x filename.rar
Compression: rar a filename.rar DirName


(12),. Lha
Decompression: Lha-e Filename.lha
Compression: Lha-a Filename.lha FileName
(13),. rpm
Unpacking: Rpm2cpio filename.rpm | Cpio-div
(14),. Deb
Unpacking: ar p filename.deb data.tar.gz | Tar zxf-
(15),. Tar. tgz. tar.gz. Tar. Z. tar.bz. tar.bz2. zip. cpio. Arj. rar. Ace. Lha. Lzh. Lzx. Lzs., Arc. SDA. SFX. Lnx. Zoo. cab. Kar. cpt. P it. Sit. Sea
Decompression: sEx x filename.*
Compression: SEx a filename.* FileName


2. Instruction parameter Explanation:

(1), sex just call the relevant program, itself and no compression, decompression function, please note!

(2), gzip command to reduce file size has two obvious advantages, one is to reduce storage space, and the second is to transfer files over the network, you can reduce the transmission time. Gzip is a frequently used Linux system command to compress and decompress files, which is both convenient and useful.

(3), Syntax: gzip [option] File name for compression (decompression) The options for this command have the following meanings:

-C writes the output to the standard output and retains the original file.
-D Unzip the compressed file.
-L Displays the following fields for each compressed file: The size of the compressed file, the size of the uncompressed file, the compression ratio, the name of the uncompressed file-R recursively finds the specified directory and compresses all of its files or is decompressed.
-T test to check that the compressed file is complete.
-V for each compression and decompression file, display the filename and compression ratio.
-num adjusts the speed of compression with the specified number num,-1 or--fast represents the fastest compression method (low compression ratio), 9 or--best represents the slowest compression method (high compression ratio).
The system default value is 6.


instruction Example:
Gzip *% compress each file in the current directory into a. gz file.
GZIP-DV *% extracts each compressed file in the current directory and lists detailed information.
Gzip-l *% Detail shows the information of each compressed file in Example 1, and does not understand the pressure.
Gzip usr.tar% compress the tar backup file Usr.tar, at which time the compressed file has a. tar.gz extension.


Directory archive management under Linux (CentOS) and archive file System package compression

Related Article

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.