Setting the HOME variable to improve efficiency

Source: Internet
Author: User
Article Title: Setting the HOME variable to improve 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.

If you log on to the Unix operating system, the system automatically locates the appropriate directory. This can undoubtedly improve the efficiency of System Engineers. In Unix, the default directory is set by the HOME environment variable. This time I will introduce the mysteries of this HOME variable. We will discuss how to improve office efficiency by setting the HOME variable.

1. Default HOME variable value.

By default, the user's home directory is automatically created by system engineers when creating user accounts. Generally, the/home directory of the operating system contains subdirectories named by each user name. If the username is admin, A/home/admin sub-directory is located in the/home directory. This is the user's default directory. When the admin user logs on to the operating system, if the user logs on in text mode, the system automatically points the user's current location to this folder. That is to say, the user's default home directory is automatically created when the account is created. However, this default setting does not necessarily meet the requirements of System engineers or users. For example, for a database administrator, the database-related files (including installation programs) may all be under the directory/db. Therefore, the database administrator may want to automatically locate/in the/db directory instead of/home/db after logging on to the system. Otherwise, manual directory switching is required, which is more troublesome. In this case, you need to change the default settings of the system.

2. Change the value of the HOME variable to adjust the default directory.

In Unix operating systems, the user's default directory is actually set by the environment variable $ HOME. Run the echo $ HOME command (note that the system environment variables are generally uppercase) to view the current value of this environment variable. If the default setting is not changed, the user's default home directory is always in the/home directory. However, System Engineers can adjust this variable as needed to adjust the user's default directory. To meet this requirement, you must understand the following content.

First, you need to understand the storage structure of the HOME variable. The echo command can be used to display the value of the environment variable HOME, in the format of/home/user name. From this format, we can see that the HOME command stores an absolute path. In Unix systems, absolute paths are a sequence of directories. Use the/symbol to separate directories (note that this is different from the Windows operating system ). In this directory sequence, the first/symbol represents the root directory. The following/symbols are mainly used to separate directories. Therefore, if you want to redefine this HOME variable, you also need to follow this rule, that is, you must use an absolute path instead of a relative path.

Note that the directory sequence in the HOME variable is case sensitive. For example, the Environment Variable HOME is in upper case, while the/home directory in the directory sequence is in lower case. If the two are reversed, some inexplicable problems may occur. System Engineers should keep in mind that in Unix operating systems, Case sensitivity is generally applied. Therefore, when assigning an absolute directory to the HOME variable, you must note that the case must be the same as the actual directory name. In general, it is best to use the cd command to locate the directory from the root directory to the target directory, and then assign the directory sequence to the HOME environment variable by copying, pasting, and other operations. This improves accuracy. After setting, run the cd $ HOME command to test whether the environment variable setting is correct.

Third, it should be noted that the path names of the main directories are generally stored in/etc/passwd. System Engineers can also modify this file to change the user's home directory. The system administrator will find a message similar to/home/user name. This information is the value of the environment variable HOME. Change the absolute path to the default directory you want to locate to adjust the default directory. Note that the target directory must exist when the directory is adjusted. Otherwise, unexpected consequences may occur.

It can be seen that it is not too difficult to adjust the user's default directory. However, System Engineers must be careful when adjusting this directory. In my daily work, I found that many System engineers have incorrect absolute path input when adjusting this default directory, such as a space or case-insensitive error, leading to a logon error. To this end, it is best for System Engineers to perform tests to check whether the adjustments have taken effect. The most common error is Case sensitivity. In addition, relative paths are used instead of absolute paths. Third, the target directory user may not have the corresponding permissions. Finally, when setting the HOME environment variable, the adjusted value is not saved in the configuration file. This setting becomes invalid when you log on again next time. These common problems can be avoided if the user is careful enough.

 

[1] [2] Next page

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.