Tar is commonly used on Linux packaging, compression, compression tools, he has a lot of parameters, folding only to enumerate the commonly used compression and decompression parameters
Parameters:
-c:create set up the parameters of compressed archives;
-X: Extracting parameters of compressed archives;
-Z: Whether to use gzip compression;
-V: Files are displayed during compression;
-F: The top document name, immediately after F to answer the file name, can not add parameters
Example: First, the entire/home/www/images directory of files are packaged as/home/www/images.tar
[[email protected] ~]# tar-cvf/home/www/images.tar/home/www/images← package only, do not compress
[[email protected] ~]# tar-zcvf/home/www/images.tar.gz/home/www/images← after packing, compress with gzip
The compressed file name after the parameter F is self-fetching, used in tar to do, if the z parameter, then tar.gz or tgz to represent the gzip compressed tar file file
Example: Two, extract/home/www/images.tar.gz to/home/www below
[Email protected] ~]# cd/home/www
[Email protected] ~]# tar-zxvf/home/images.tar.gz
Unzip to the specified directory
[Email protected] ~]# tar-zxvf/home/images.tar.gz-c/specific dir
Unpacking to the specified directory
Tar xvf filename.tar-c/specific dir
-----------------------------------------------------------------------
Linux commands-commands for managing files and directories 2007-05-24 17:07
Commands for managing files and directories
Several frequently used functions for managing file and directory commands are shown in table 3-1:
Table 3-1 commands for managing files and directories
Command function
PWD determines the current directory
CD Change Directory
LS View the contents of the directory
Cat Displays the contents of the file
Grep finds a character in a file
Touch Create File
CP Copy File
MV Moving files
RM Delete File
I. commands for creating and deleting directories
1. mkdir command
(1) General format: mkdir [options] Directory name
(2) Description: This command creates a directory named after the directory name.
(3) Example 1: Create a subdirectory under directory/usr/fedora data, and only the main file has read, write and Execute permissions (that is, 700 refers to
RWX------), the remaining users have no access.
[Email protected]/root] #mkdir-M 700/usr/fedora/data
(4) Example 2: In the current directory to establish Inin and Inin under the/mail directory, that is, the continuous construction of two directories.
$ mkdir-p-M/inin/mail/
2. rmdir command
When the directory is no longer in use or the disk space has reached the use of a qualified value, you need to remove the lost value directory from the file system.
(1) General format: rmdir [options] Directory name
(2) Description: This command removes one or more empty subdirectories from a directory.
(3) Example: Delete sub-directory bak and its parent directory bin.
[[email protected]/root] #cd/usr/fedora
[[email protected]/root] #rmdir-P/bin/bak
Two. Changing the working directory and displaying directory content commands
1. CD command
(1) General format: CD [directory name]
(2) Description: This command is used to change the working directory. Returns to the user's home directory when no parameters are taken.
(3) Example: Change the current directory to/usr/li
[[email protected]/root] #cd/usr/li
2. PWD command
(1) General format: PWD
(2) Description: The command does not have any selection or parameters to display the absolute path of the current working directory.
(3) Example: Displays the current working directory.
[Email Protected]/root] #pwd
/root
3. ls command (shorthand for the English word list, similar to the dir command under Dos)
(1) General format: LS [option] [directory or file]
(2) Description: This command lists the contents of the specified directory, and by default, the output entries are sorted alphabetically.
(3) Example: List the contents of the current directory and sort by the modified time.
[[Email Protected]/root] #ls-C
Data m1.c Desktop mbox anaconda-ks.cfg
Wc.txt m2.c chap.txt Evolution Install.log
m3.c A.C w.txt screenshot.png install.log.syslog
(4) Parameters:
By default, the output entries are sorted alphabetically. When a directory name or file name is not given, the current directory information is displayed.
The meanings of the options in the command are as follows:
-a displays all subdirectories and files in the specified directory, including hidden files.
-A displays all subdirectories and files in the specified directory, including hidden files. But do not list "." and ".".
-B The non-displayed characters in the file name are displayed with octal escape characters.
-C Sort by the modified time of the file.
-C is divided into multiple columns to display the items.
-D If the parameter is a directory, only its name is displayed and the files below it are not displayed. Often used with the L option in order to get the detailed information of the directory
Interest.
-F is not sorted.
-F Mark "/" After the directory name, "*" After the executable file, Mark "@" after the symbol link, after the pipe (or FIFO)
Mark "|", after the socket file, mark "=".
Three. commands to link files
The link File command is the LN command, which creates a link between files. This operation is actually to give a file already in the system to specify another
A name that can be used for access outside.
(1) General format: LN [options] source file [target]
(2) Description: The linked object can be a file, or it can be a directory.
(3) Example: Link the file m1.c under directory/usr/fedora to the directory/usr/li file a2.c
[Email protected]/root] #ln/usr/fedora/m1.c/usr/li/a2.c
Four. File Display command
1. Cat command
Cat commands connect files and print to standard output devices
(1) General format: Cat [option] File name 1 [file name 2]
(2) Description: This command has two functions, one is to display the contents of the file.
(3) Example: Display Clear.txt file contents with cat command
[Email protected]/root] $cat clear.txt
2. More commands
The text file is displayed on the terminal screen by screen. If the file is too long, you can only see the last page of the file with the Cat command, and when you use the more command
Can be displayed on a page-by-page.
(1) General format: more [options] file name
(2) Description: The command displays one screen of text at a time, the display stops after the full screen, and a message appears at the bottom of each screen, giving
The percentage of the file that has been displayed so far:--more-(xx%).
(3) Example: Display the file Chap.txt in the format of 10 lines per page.
[Email protected]/root] #more –10 clear.txt
3. Less command
As with the more command, the less command is also used to split the contents of the file, but the function is more powerful than the more commands.
(1) General format: less [option] file name
(2) Description: Less is actually more of the improved version, the direct meaning of its command is more antisense. It's more powerful than command
More flexible.
(3) Examples:
With more
4. Head command
The head command displays the beginning of the specified file on the screen if it is on line.
(1) General format: head [parameter] file name
(2) Description: The head command displays several lines at the beginning of the specified file on the screen, and the number of rows is determined by the parameter values. The default value for displaying the number of rows is
10.
(3) Examples:
Display the first 5 lines of the Test file
Input: head-5 test or head-n 5 test
5. Tail command
The tail command displays several lines at the end of the specified file on the screen.
(1) General format: tail [parameter] file name
(2) Description: Displays the last part of the file.
(3) Example: Displays the last 10 lines of the Cd.txt file.
[Email protected]/root] #tail cd.txt
Five . match, sort command
1. The grep command
This command is used to find words or essays in a specified pattern in a text file, and to display all lines that include a given string pattern on standard output
(1) General format: grep [option] filename
(2) Description: The grep command is useful for searching for specific patterns in specified files and for locating specific topics.
(3) Example: Find all lines that contain "xyz" in the password file/etc/passwd
[[[email protected]/root] #grep –f xyz /etc/ passwd
54:xyz:x:504:504:wuxueyi:/home/xyz:/bin/bash
2. The Find command
searches the directory structure for a file that satisfies the query criteria and performs the specified action.
(1) General format: Find [path ...] [Expression]
(2) Description: The Find command parses each parameter from left to right, and then searches the directory in turn.
(3) Example: Find all the. c files with a letter or number starting with m in the current directory, and display some files interactively
The
content.
[[email protected]/root] #find -maxdepth 1–name ' m?. C ' –ok cat{}\;
3. The sort command The
Sort command is used to sort the lines of a text file.
(1) General format: sort [options] file List
(2) Description: The sort command sorts all the rows in the specified file line by row and displays the results on standard output.
(3) Example: The system has a file A.C, its content is:
x f b e I
4. Uniq Command
This command displays all the rows in the file that are not duplicates.
(1) General format: uniq [option] file
(2) Description: Uniq command reads the input file, compares adjacent rows, removes duplicate rows, leaving only one row.
(3) Example: Displays rows that are not duplicated in the file A.C.
[[email protected]/root]# uniq–u A.C
Six. Commands to compare file contents
1. Comm Command
This command is used to find words or essays in a specified pattern in a text file and to display all rows that include a given string pattern on standard output
(1) General format: Comm. [-123] File 1 file 2
(2) Description: The comm command compares two files that have already been sequenced in a row.
(3) Example: Compare Files m1.c and m2.c to show only the rows they have in common
[Email protected]/root] #comm –12 m1.c m2.c
2. Diff command
(1) General format: diff [Options] file 1 file 2
(2) Description: The command compares two files line by row, lists their differences, and tells the user that in order to make two files consistent, you need to
Which rows they are modified.
(3) Example: Compare the differences between files m1.c and m3.c with the diff command
[[email protected]/root] #diff m1.c m3.c
Seven. commands for copying, deleting, and moving files
1. CP command (like a copy command under DOS)
(1) General format: CP [option] source file or directory destination file or directory
(2) Description: The CP command copies the source file or directory to the target file or directory.
(3) Example: Copy file m3.c to directory/usr/fedora/tem and rename to M3bak.c
[Email protected]/root] #cp m3.c/usr/fedora/tem/m3bak.c
2. RM command
(1) General format: RM [options] File list
(2) Description: This command can delete one or more files or directories in a directory, or you can have a directory and all of its subordinate files
and subdirectories are deleted.
(3) Example: interactively delete files in the current directory test and example.
[Email protected]/root] #rm-I test example
Remove test? Y
Remove example? N
The file test will be deleted.
3. MV Command (like a combination of Ren and move under Dos)
(1) General format: MV [option] source file destination file
(2) Note: This command is used to move a file or directory, and also to modify the file name or directory name while moving.
(3) Example: Renaming the file m3.c to M3B.C.
[Email protected]/root] #mv m3.c M3B.C
Package-Compress and unzip the tar and extract to the specified directory