In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Introduction of Linux package
Like Windows, various compression formats can be manipulated in Linux systems. As long as there are relevant tools, you can generate files in various compressed formats or extract them. In Linux, the main package management tool is tar, and the two main compressed package formats are gzip and bzip2, which can be operated directly using tar tools, so most of the installation packages provided by unzipping ready-to-use software in Linux are in tar.gz format.
II. Packaging and decompression
The tar tool itself supports both packaging and decompression operations, and different functions are achieved through different parameters.
1. Packing
For the packaging operation, you mainly need to specify the files or folders to be packaged, the format of the generated package, and the name of the package, and you need to use the following options:
C: create a new zip file z: specify the format as gzipj: specify the format as bzip2f: specify the name of the package, which needs to be placed at the end, directly connected to the name of the package.
For example, if we want to record all the main configuration information of the current system using the gzip format, we need to package the / etc directory with the following name:
Tar-czf etc.tar.gz / etc
Put the content to be packaged in the location of the second parameter, and the execution effect is as follows:
two。 Decompression
When decompressing, you need to specify the compressed package to be operated, the corresponding decompression format, and the decompression target path. The following options are required:
X: decompress the package z: specify the format as gzipj: specify the format as bzip2f: specify the name of the package, which needs to be placed at the end, and connect it directly to the name of the package. C: specify the decompression directory, and the specified directory must exist v: display the detailed process.
If you need to decompress the etc.tar.gz you just packaged, you can use the following command (C and v are optional) according to the format of the package itself:
Mkdir targettar-zxf etc.tar.gz-C target/
By default, if the-C option is omitted, it is extracted to the current directory, and the command is executed as follows:
3. Note for most commands, the order of the options has no effect, but for the tar command, the f option must be placed immediately after the first parameter, that is, at the end of the first set of options, for the tar command option, c: package / x: extract / t: view, these three options cannot appear at the same time, the reason is very simple, each operation is independent, and the option for specifying the decompression path will not occur at the same time. You can put it after the first parameter. The specified directory must be an existing path and will not automatically create an unzipped installation.
For unzipped ready-to-use software and compiled and installed software are in the form of compressed packages, the essential difference is that the core installation steps of unzipped ready-to-use software are to extract and configure environment variables, because the commands and scripts that need to be used have been stored in the bin or sbin directory. The compiled and installed software is decompressed to get the source file, which can not be used directly. It must be compiled and installed before the corresponding command file is generated. In general, decompression ready-to-use software has the following established directories:
Bin: binary file directory, used to store various commands and executable files conf: configuration file directory lib: dependent file directory, will store dependent packages or library files and other logs needed for software operation: software operation log directory temp: temporary file directory
For software that needs to be compiled before it can be used, there are no commands that can be executed directly after decompression, and the steps for compilation and installation will be explained in detail in other articles.
1. Decompress
Take the installation of JDK as an example, the decompression step is very simple. You can use the decompression command above and extract it directly to the current directory:
Tar-zxf jdk-8u221-linux-x64.tar.gz
two。 Environment variable description
The configuration of environment variables varies slightly for different software, depending on the directory where the command file is located. For example, for JDK, commands are stored in the bin directory and jre/bin, respectively, so we usually add both paths to the environment variables. When configuring environment variables, for ease of use, a variable is first used to record the decompression path of the software, using a combination of all uppercase letters and underscores, such as JAVA_HOME. Then through the way of splicing, the path of the command is spliced to PATH, and the whole installation and configuration process is completed after refreshing.
Before you do this, there are a few concepts that are briefly explained:
Environment variable: environment variable refers to the variable that can be used in the command environment, general variables can only be used in a script file, using the export instruction can change a variable into an environment variable, so that the value of the variable can be used directly in the command environment. System environment variables: system environment variables are some of the variables that have been preset by the system, and they are a group of variables that can be used directly after the system user logs in. PATH variable: the PATH variable is one of the system environment variables, and its function is to record the search path when the command is executed, so that the command can be used anywhere without entering the full path where the command is located. For example, if we want to be able to use JDK-related commands anywhere, we need to append the path of the JDK command to the PATH variable. Environment variable configuration file system variable: the scope is for all users, which is a global configuration, and the path is / etc/profile (only root users can modify it) user variable: scope is a certain user, only the corresponding user is valid, and the path is: ~ / .user (~ is the current user's home directory) the environment variable takes effect: no matter it is a variable in the custom script It is also a variable in the environment variable configuration file, and after using the export operation, you need to use the source command to make it effective. 3. Environment variable configuration
The following are the steps for configuring environment variables for JDK:
Use the pwd command to copy the full path of JDK decompression
Edit ~ / .bash_profile and add the following: JAVA_HOME=/home/test/jdk1.8.0_221PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/binexport JAVA_HOME
Use the source command to refresh the environment variables and verify: source .bash _ profileecho $JAVA_HOMEecho $PATH
Note: Linux uses the $symbol to refer to variables, which is equivalent to%% in Windows, and uses colons as path separators, which is equivalent to the semicolon of Windows.
After the configuration is complete, you can use the commands in JDK to verify, and the refresh operation only needs to be done once, because two environment variable configuration files are automatically read each time when the user logs in.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.