Article Title: unix uses file comparison commands to improve system management efficiency. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The biggest difference between Unix and Windows systems is that Unix systems are built based on configuration files. Therefore, Unix System engineers work on Unix files. Such as network IP address configuration and environment variable management can all be implemented through related configuration files. Therefore, how to quickly and conveniently manage these configuration files is a challenge for Unix System Engineers. In fact, many file management tools are provided in Unix systems. If System Engineers can use these tools flexibly, they can achieve surprising success. This is not a big story. Now, we will take file comparison commands as an example to talk about how to use these tools to improve system management efficiency.
In daily work, interacting with Unix will take most of the time for System Engineers. System Engineers often need to switch directories, display files, edit and compile programs, and constantly repeat these actions. If the environment variable is not suitable, the system engineer will be miserable. It takes a lot of time to switch to the appropriate directory. For this reason, experienced System Engineers like the author often configure relevant environment variables based on their operating interests after installing the Unix operating system to improve the efficiency of subsequent system maintenance. This environment variable is not only related to the Operation habits of the system administrator, but also to the normal operation of the application. Environment variables are strings containing information about the system and the environment of the currently logged-on user. Some software programs use this information to determine where to place files. For example, THE path environment variable tells the operating system that when the system is required to run a program without telling it the complete path, the system searches for this program under the current directory, you should also go to those directories to find them. After the JDK software package is installed, the system administrator must set environment variables for it. Otherwise, the program will not run properly. We can see the importance of environment variables to System Engineers and applications.
However, if you accidentally make an inappropriate adjustment to the environment variables, the problem may occur. If you accidentally change the environment variables of the JDK software package, the JAVA program may not run properly and the system will prompt that the path cannot be found. Therefore, the system should be able to provide a means to compare the similarities and differences between environment variables. Only in this way can we quickly find and adjust the modified content in hundreds of environmental variable records. For this purpose, you can use the file comparison command. For example:
After installing the Unix operating system, I will use the env command to display the environment variables of the current operating system. Then, use the redirection symbol to save the displayed results in a file (j is assumed to be env1) for future comparison. If one month later, the author finds that the environment variable has a problem (for example, the application may have modified the environment variable or manually changed the environment variable but forgot it ), I will use the env command again to redirect the latest environment variable of the system to a file, for example, env2. Then the author can use the cmp command to compare the two files and find out their differences. To achieve this goal, many file comparison commands are provided in Unix systems. Specifically, there are three commands: cmp, diff, and comm to complete this task. These three commands have their own characteristics. System Engineers should learn to select appropriate commands based on their own needs to reduce their workload.
1. Determine whether the file has been modified.
During routine maintenance of Unix systems, System Engineers often need to determine whether the two files are the same. In the above case, you need to determine whether the two environment variable files are the same. If they are the same, the environment variable has not been changed. If so, the environment variable is modified later. In this case, you can use the cmp command for comparison. This command compares two files specified by System Engineers one by one. When the first character is found to be different, the location of the character is output. By default, the cmp command stops working after it finds that the first character is different. Unless the system engineer adds the-l parameter when using this command, the system will list the detailed list, indicating different locations. However, for System Engineers, they only need to know that the file has been modified. If you want to know where the modification was made, you need to use other commands.
When using this command, I think the system engineers should pay attention to two issues. For example, if the file env1 is identical to the file env2, the system will not reflect any information and directly return to the prompt. This is the "no response method" for Unix operating systems ". It seems that no result is returned, but this is not the case. If the two files are the same, the system returns a value of true. This value is very important during shell program development. This value can be used as a condition statement in the script program to control the process of the program. In addition, this command only displays the positions of different characters, but does not display the differences. Generally, the author uses this command to determine whether two files are different. If the difference is found, use the following two commands to find out what is different.
[1] [2] Next page