File archive management of Linux commands

Source: Internet
Author: User

1. Documentation-related knowledge

How Linux saves files

Data

-The data here is the contents of the file

Meta data

-In a Linux system, all the extra information associated with a file is stored in a section called I-node (inode)

Filename

-File name is saved in an organization named directory entry (dentry)

I-node

All files have the following properties:

File type, number of links, user owner, group owner, permissions, and time information.

the number of links to the I-node record file, which is the number of directory entries (dentry) referencing the file. Usually there is only one file name for regular files, and the number of links is 1

Time Information

Each I-node holds three time information associated with a file, commonly called Atime, CTime, mtime, meaning the following

Abbreviation Name Objective
Atime Access time

File data is updated after each reading

CTime Change Time The I-node information is updated every time the file is changed
Mtime Modify Information File data is updated each time it is changed

To view the I-node information with the Stat command

The I-node information set for a file is called the state of the file (Startus).

We can do it. The stat command is considered a command of the status of a real file.

Usage:

Stat [option] File

Within a file system, each I-node is assigned a unique I-node number

Hard links and soft links

Hard Links :

Associating multiple directories to an I-node (the same file is saved in two places or different filenames)

ln destination File Link file

Soft links : are some different I-nodes, used to refer to other filenames (equivalent to shortcuts)

Ln-s destination File Link file

Find File Search command

Usage:

Find {Search Directory} {search condition} [action]

Search criteria:

-size N Size of file

Type of-type file (f normal, D directory, I soft link)

-name Search by file name. Wildcard characters are supported for reference

Linux learns some shortcut keys that can be used in terminal and the common wildcard characters used by the shell

-user Search by file owner

-group Search by the group to which the file belongs

-mitime N to find a file according to the file's change time

-atime n searches for files that have been read in the last n days

-ctime n searches for files that have been modified in the past n days

-N means file change time is less than n days, +n means file change time is now N days ago

Time-related options:-atime,-ctime,-mtime,-mtime instructions

-mtime N: = n is a number, meaning a file that has been changed in the previous (day)

-mtime +n: Lists the file name of the content that was changed before n days (excluding n days itself)

-mtime-n: Lists the names of the changed content within n days (including the N-day itself)

-print: Output search results and print

The Find command finds several ways to locate a file:

(1) Search by file name

For example, we want to find a file with a filename of lilo.config,

Find/-name Lilo.config

Search the entire hard disk after the/representation of the Find command

(2) Quickly find files

Finding files based on file names can have a real problem, which is to take a long time, especially when large Linux file systems and high-capacity hard disk files are placed in deep sub-directories. If we know that this file is in a directory, you can save a lot of time by looking down in that directory. For example, Smb.config file, from the file suffix config is known as a configuration file, you can find from/etc directory, as follows

Find/etc-name Smb.config

(3) Find a file with a hybrid search method

For example, if we want to find more than 300000 bytes in/etc and modify it within 24 hours, you can use-and to connect two lookup parameters together to form a hybrid lookup

Find/etc-size +300000c-and-mtime +1

2. File compression

Gzip

Usage:

gzip [option] File

Parameter:-c redirects output to standard output

-D Unzip the file

-R to the directory recursion, the inside of the files are compressed separately

-1 ... 9 specifying the compression level

File suffix:. gz

Bzip2

Usage:

bzip2 [option] files to be compressed after compression

Parameter:-c redirects output to standard output

-D Unzip the file

File suffix:. bz

File Archive tar

Archive files to keep the entire directory tree in one file

Tar commands for creating, listing, extracting archive files

Archive files are usually also compressed

Usage:

tar [option] File

-C Create an archive file

-X Release Document

-V Show More information

-F file name (can be taken with path)

-Z Using gzip compression

-j using BZIP2 compression

File archive management of Linux commands

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.