(3) compression and Packaging Commands
Compress related commands
Command Definition Format
Bzip2. bz2 File compression or decompressionProgramBzip2 [Option] compressed (decompressed) file name
Bunzip2. bz2 file decompression program bunzip000000000000.bz2 compressed file
Bzip2recover is used to repair the damaged. bz2 file bzip2recover.bz2 compressed file
Gzip. GZ File compression program gzip [Option] compressed (decompressed) file name
Gunzip decompress the file name of the program gunzippressed by gzip.
Unzip decompress the. Zip program of winzipzip to compress the file.
Tar package or decompress the file directory. Tar [Option] [package file name] file directory list
1. gzip [Options] compressed (decompressed) file name
Compress and decompress files, and gzip can automatically identify compression or decompress files based on file types.
Common Parameters
-C: Write the output information to the standard output and keep the original file.
-D. decompress the compressed file.
-L list information about compressed files
-R: Find the specified directory and compress or decompress all the files.
-T test whether the extracted files are complete.
-V displays the file name and compression ratio for each compressed and decompressed file.
Gzip can only be used to compress a single file, but not to compress the directory.-R is used to compress all files in the directory one by one, instead of compressing the Directory into a file.
2. Tar [Options] [package file name] file directory list
Package or unpackage the file directory
Note: compression and decompression are two different concepts. Compression refers to a certain amount of compression. Algorithm Convert a large file into a small file. packaging is to convert some files or directories into a total file.
Tar can also automatically package and package based on the file name. The file name is the custom package name, and the file directory list can be the list of files to be packaged and backed up, it can also be a list of file directories to be decompressed.
Main parameters:
-C, -- Create create a new packaging File
-R, -- append: append an object to the end of the package.
-X and extract Extract files from the package file (the file name to be decompressed can be specified separately. If not specified, extract all files)
-O: Decompress the file to the standard output.
-U, -- Update only replaces the files updated from the backup files.
-V, verbose outputs relevant information during processing
-F, -- file ( This parameter is a required parameter and is the last parameter. Only the package name can be followed. )
-Z, -- gzip call gzip to compress the package file, and call gzip to decompress the package when it is used with-X.
-Z, -- compress uses the compress command to process backup files.
-J calls Bzip2 to compress the package file
-T, -- list to list the content in the TAR file
-- Delete: delete a specified file in the TAR file.
Note: Only one parameter can exist in the C/X/t parameter.
The tar file can only be decompressed to the path of the current system.
In addition to conventional Packaging Commands, tar commands are frequently used to decompress different files by calling gzip or Bzip2 with the option "-z" or "-J.
List of common Linux file decompression commands
File suffix decompression command
. A tar XV
. Z uncompress
. GZ gunzip
. Tar. Z tar xvzf
Tar.bz2 tar jxvf
. Zip unzip
(4) commands for comparing merged files
1. Diff [Options] File 1 file 2
Compare two different files or two files with the same name in different directories, and generate patch files (different files)
Diff compares the differences between file 1 and file 2 and outputs them in the specified format according to the options. the diff format is divided into command format and Upper/lower format. The upper/lower format is also divided into the old version and the new version.
Upper/lower format. If the option is missing, use the hybrid mode.
Main parameters:
-R recursively processes Directories
-Q: only report different files without output results
-E,-ed Command Format
-F: simple command mode of the RC (Revision Control System)
-C, -- Context old version and Upper/lower format
-U, -- the upper and lower formats of New uniied versions
Supplement:
When output in the earlier version of context format, the upper and lower lines of the row are displayed while each line has different differences. Use it elsewhere "! "Mark it.
When output in the context format of the new version, only the differences between the two files are listed separately.
Only different lines are output when the Command Format operator is output. The number in the Command operator "4C" indicates the number of lines. The letter meaning is a-add, B-delete, and C-change.
Creating a patch file is a functional question of diff. Different option formats can generate corresponding patch files.
TIPS:
Output redirection "> ". generally, when you execute a shell command in Linux, three standard files are automatically opened: The standard input file (stdin), which is usually the keyboard of the corresponding terminal; the standard output file (stdout) and
Standard Error output file (stderr). The first two files correspond to the terminal screen. the process will get the input data from the standard input file and output the normal output file to the standard output file.
The file is sent to the standard error file. This is the standard input/output method.
Directly using standard input/output files has the following problems: first, the user can only use the input files once, and the user has to re-enter the data the next time he wants to use the data. Similarly, the user cannot
To do more processing, you can only wait until the program ends.
To solve the preceding problem, Linux introduces two methods for transmitting input/output information: the input/output redirection mechanism and the pipeline. The input redirection refers to the Command (or executable program) standard input
Redirects to a specified file. That is to say, the input can come from a specified file instead of the keyboard. similarly, output redirection refers to the standard output or standard error of a command (or executable program ).
In this way, the output of this command is not displayed on the screen, but written to the specified file. This greatly increases the flexibility of input/output.
2. Patch [Options] [files to be patched] [patch files]
The patch command allows you to modify and update the original file by setting the patch file. If only one file is modified at a time, you can issue commands in the Command column for sequential execution. If files are patched together, a large number of files can be repaired at a time, which is also one of the core upgrade methods for Linux systems.
Common Format: patch-pnum [patch file]
Common parameters:
-B. Generate the backup file.
-D: Set dir to the current directory for interpreting the patch file.
-E regards the entered patch file as an Ed script.
-Pnum: strip the contents of the first num directory in the file name. For example, the files of the two patches are Taq/hello. CF and zzl/hello. CF, you need to remove the first "/" from the target path and use p1
-T no input is required during execution
-V: displays the patch version number.
If the patch fails, the patch command will generate a backup file and A. rej file .. The rej file contains a patch line that is not successfully submitted and must be manually patched. This may occur during source code upgrade.
In most cases, the patch program can determine the format of the patch file. When it cannot be identified, it can use-C,-E, -N or-u options to specify the format of the input patch file. since only GNU patch can create and read patch files in the new Contextual format, unless it can be determined that the patch is only intended for users who use the GNU tool, otherwise, the patch file should be generated in the context format of the old version.
To make the patch program work properly, the number of lines in the context must be at least two (that is, at least one different file ).
(5) network-related commands
Common network-related commands:
Netstat displays network links, route tables, and network interface information. netstat [-An]
NSLookup: view the IP address of a machine and the corresponding domain name NSLookup [IP Address/domain name]
FINGER: Query user information. Finger [Option] [user] [user @ host]
Ping is used to check whether hosts on the network are working. Ping [Option] Host Name/IP Address
Ifconfig: View and configure network interface parameters ifconfig [Options] [network interface]
Use ftp to upload and download files
Telnet browsing information using the Telnet protocol Telnet [Option] [IP Address/domain name]
Use SSH to log on to the host over SSH [Option] [IP address]
1. ifconfig
This interface is used to view and configure network interface addresses and parameters, including IP addresses, network masks, and broadcast addresses. Its permission is for a Super User.
Format:
Ifconfig can be used to view and change network interfaces.
① Ifconfig [Option] [network interface]: used to view the network configuration of the current system.
② Ifconfig Network Interface [Option] address: used to configure the IP address, network mask, broadcast address, and so on of the specified interface (such as eth0 and eth1.
Common parameters:
-Network Interfaces specified by interfaces, such as eth0 and eth1
Up to activate the specified network interface card
Down to disable the specified network interface card
Broadcastaddress
Point to Point
Address: sets the IP address of the specified interface.
Netmast address: sets the subnet mask of the interface.
The network device parameters configured using the ifconfig command take effect without restarting, but will become invalid after the machine is restarted.
2. FTP [Option] [host name/IP address]
This command allows users to upload and download files using the FTP protocol
FTP-related names include commands and Internal commands. The command format is described above, which is mainly used to log on to the FTP server. an internal command is a series of operations performed after successful login. if the user defaults to "host name/IP Address", you can continue to log on after the command is transferred to the FTP.
Common parameters:
-V: displays all the corresponding information of the remote server.
-N: Restrict FTP Automatic Login
-D use the debugging method
-G cancel the Global File Name
FTP common internal commands such as tables:
Account [Password] provides the password not required to access system resources after logging on to the remote system.
ASCII: uses the ASCII transmission mode, which is the default transmission mode.
Bin/Type Binary File Transfer Mode
Bye exit FTP session
CD remote-Dir: Enter the remote host directory
Cdup enters the parent directory of the remote host directory
Chmod mode file-Name: sets the file-name of the remote host to mode.
Close interrupt and remote host session (corresponding to open)
Delete remote-file Delete remote host files
Debug [debug-value] sets the debug mode and displays each command sent to the host.
DIR/ls [Remote-Dir] [local-file]: display the remote host directory and save the result to the local file.
Disconnection and close
Get remote-file [local-file] transfers the remote-file of the remote host to the local-file of the local hard disk.
LCD [dir] switches the local working directory to Dir
Mdelete [Remote-file] Delete remote host files
Mget remote-files transfers multiple remote files
Mkdir Dir-Name: create a directory in the remote host
Mput local-file transfers multiple files to the remote host
Open host [port] creates a connection to the specified FTP server. You can specify the connection port.
Passive enters the passive transmission mode (In this mode, the data connection is initiated by the client)
Put local-file [Remote-file] transfers the local-file to the remote host.
Reget remote-file [local-file] is similar to get, but if local-file does not exist, it will be resumed from the last transmission interruption.
Size file-Name: displays the file size of the remote host.
System displays the remote host operating system
Other commands
Id [Options] [username]
Output user and user group information. The default value is the user currently logged on.
Witch command
Display the complete path of the command Command run by the terminal, that is, specify which command is executed in the system
Multiple commands with the same name may exist locally. After a command is called in shell, the system searches for the command according to the specified directory and runs the First Command
Parameters:
-A shows all the searched commands, not just the first command.
Whereis command
Search for tool-related files in the standard path
Apropos
You can use apropos to query specific commands without knowing the command name. For example, apropos tar will list all commands containing the tar words.
Whatis
Similar to whereis, this command only searches for commands that exactly match the keyword.
WHO: List users on the System
The first column is the username, the second column is the terminal, workstation, or terminal simulator linked to the user (tty1: First console; PTS/0: virtual console), and the third column is the date and time when the user logs on.
When using the write command to communicate with other users, you can use the who command to check whether the user is online.
If you want to obtain the terminal or logon time that the user is using, you can use the Who am I command to view it.
W: List users on the System
Similar to who, but more information can be listed
The first column is the user, the second column is the terminal device number used by the user, the third column is the system used by the remote user to log on, the fourth column is the time when the user logs on to the system, and the fifth column is the time when the user is idle, the last two columns describe the logon times of each user and the CPU processing time occupied by the running tasks. The last column is the running commands of each user. The first line of information includes the current time, computer running time, number of logged-on users, and average system load.
Use skill-9 pts/3 to interrupt the third virtual terminal
White username [terminal]
Username is the user login name for communication
Used to send information to a logged-in user. The two users send messages through write, which is a two-way communication method.
Mesg to check whether the current user can accept the information
Mesg n is used to prohibit messages sent by other users. On the contrary, mesg y is used to enable messages sent by other users.
Wall message
Send messages to all users
Last
View user login information
Lastlog
View the final login information of each user