OS environment variables. bash_profile, bashrcbashshell

Source: Internet
Author: User
OS environment variables. bash_profile and bashrcbashshell are objects with specific names. they contain information that one or more applications will use. For example, if you want the system to run a program without telling it the complete path... OS environment variable. bash_profile, bashrc bash shell environment variable is an object with a specific name, it contains information that one or more applications will use. For example, if the system is required to run a program without telling it the complete path of the program, the system searches for this program under the current directory, you should also find the path specified in the path. You can set environment variables to better run processes. Directory basic definition environment variables solution for dual-system software sharing problem solving system operation problem common environment variables environment variable setting method for Linux editing method basic definition environment variables solution for dual-system software sharing problem solving system operation FAQ common environment variables in Linux environment variable setting method editing method basic definition environment variables generally refer to parameters used to specify the operating system runtime environment in the operating system, for example, the temporary folder location and the system folder location. This is a bit similar to the default path in the DOS period. when you run some programs, in addition to searching in the current folder, you will also find it in the set default path. Simply put, the "Path" is a variable, which stores the directory paths of some common commands. Environment variables are equivalent to some parameters set for the system or user application. the specific role of environment variables is related to the specific environment variables. for example, path tells the system that when the system is required to run a program without telling it the complete path of the program, the system searches for this program under the current directory, which directories should be searched? in tc or vc ++, set include = path1; path2; indicates where to find the compilation program. h-type File. of course, it does not only specify the path, but also has other functions, for example, set dircmd =/4 sets an environment variable to add/4 to your dir command as the default parameter, just like every command you add the/4 parameter, it is actually an environment variable set for the command interpretation program command, and it is set for the dir internal command. DWORD GetEnvironmentVariable (LPCSTR lpName, LPSTR lpBuffer, DWORD dSize). The lpName parameter is the name of the environment variable you want to query, and lpBuffer returns the value of the environment variable you specified, dSize indicates how many bytes the lpBuffer function can store. the reason for local failure analysis is probably because the default path in the environment variable is deleted. Once the default path is set, some DLL or EXE files are required for the current system to run the program, and the Active control will be searched in all the default paths. if the corresponding program is found in these directories, it will be automatically loaded. if the corresponding program is not found, an error message for the specified file will be reported. Environment variables solve the problem of software sharing in dual systems. many friends will install dual systems on their computers, such as Windows XP on drive C and Windows 7 on drive D. However, some software is often installed only in Windows XP systems, and Windows 7 systems cannot be used normally. the more troublesome but effective method is to install it again. When we understand the use of environment variables, we can solve the problem of software sharing in dual systems. Why does the software installed in Windows XP fail to run in Windows 7 (except for Green software )? The reason is that when installing software, you often need to copy some files to the system directory, and when using another system, these files cannot be run due to the lack of such files. Therefore, we can solve this problem by setting environment variables. Common Environment variables % ALLUSERSPROFILE % partially return the location of all "user configuration files. % APPDATA % Partial return the location where the application stores data by default. % CD % returns the current directory string. % CMDCMDLINE % returns the exact command line used to start the current Cmd.exe. % CMDEXTVERSION % the system returns the version number of the current "command handler extension. % COMPUTERNAME % the name of the computer returned by the system. % COMSPEC % the system returns the exact path of the executable program of the command line interpreter. % DATE % the system returns the current DATE. Use the same format as the date/t command. Generated by Cmd.exe. For more information about the date command, see Date. % ERRORLEVEL % the system returns the error code of the recently used command. A non-zero value is usually used to indicate an error. % HOMEDRIVE % the system returns the local workstation drive letter that is connected to the user's home directory. Set based on the main directory value. The user home directory is specified in "local users and groups. % HOMEPATH % the system returns the complete path of the user's home directory. Set based on the main directory value. The user home directory is specified in "local users and groups. % HOMESHARE % the system returns the network path of the user's shared home directory. Set based on the main directory value. The user home directory is specified in "local users and groups. % LOGONSEVER % returns the name of the domain controller that verifies the current logon session. % NUMBER_OF_PROCESSORS % number of processors installed on the computer. % OS % the system returns the name of the operating system. Windows 2000 displays the operating system as Windows_NT. % PATH % the system specifies the search PATH of the executable file. % PATHEXT % the system returns a list of file extensions that the operating system deems executable. % PROCESSOR_ARCHITECTURE % the system returns the processor's chip architecture. Value: x86 and IA64. % PROCESSOR_IDENTFIER % the system returns the processor description. % PROCESSOR_LEVEL % the system returns the model of the processor installed on the computer. % PROCESSOR_REVISION % the system returns the system variable of the processor revision number. % PROMPT % returns the command PROMPT settings of the current interpreter. Generated by Cmd.exe. % RANDOM % the system returns any decimal number between 0 and 32767. Generated by Cmd.exe. % SYSTEMDRIVE % the system returns a drive containing the Windows XP root directory (that is, the system root directory. % SYSTEMROOT % the system returns the location of the Windows XP root directory. % TEMP % and % TMP % the system and user return the default temporary directory used by the applications available to the current login user. Some applications require TEMP, while other applications require TMP. % TIME % the system returns the current TIME. Use the same format as the time/t command. Generated by Cmd.exe. For more information about the time command, see Time. % USERDOMAIN % Partial return the name of the domain containing the user account. % USERNAME % returns the name of the user Currently logged on. % UserProfile % returns the location of the configuration file of the current user. % WINDIR % the location of the operating system directory returned by the system. In Linux, the environment variable shell environment depends on the settings of multiple files. When the shell is called, it reads commands from two initial files. /Etc/profile contains System variables, which are maintained by the system administrator. the system administrator sets local system variables and special commands. The startup Information File ($ HOME/. bash_project) of a common user is maintained by each user. the file can be modified to initialize any specific system. The profile file is read only under specific circumstances, specifically when the user logs in. After running the shell script or subshell, you do not need to read the profile. all profiles are optional, but basically all systems have/etc/profile. if the variable ENV has been defined and is passed to the environment, not all bash shells need to read and call the commands contained in the file specified by this variable. This file defines all the features of the bash shell, not just logging on to the shell. The typical name of this file is $ HOME/and bashrc. When a user is created with the system administrator,. bash_profile, bashrc, and other public environment file templates will be copied to the/etc/skel directory. You can edit these initialization settings or add additional files in this directory. Example: a typical system profile (/etc/profile): PATH = $ PATH:/usr/qa/tools/binENV = $ HOME /. bashrcORACLE_HOME =/dbs/oracleORACLE_SID = qadbExport path env ORACLE_HOME ORCAL_SIDCat/etc/motd a typical user profile (. bashrc) PATH = $ PATH: $ HOME/binTEAM = uvt1224 export TERMsttyintr \ ^ Ccalmesg n a typical user bashrc file (. bashrc): alias dir = ls lf = 'ls-FC' PSI = '$ PWS [!]> 'Set-o vi alias and other bash-specific definitions should be placed in the. bashrc file (not defined in. bash_profile); otherwise, some commands may not be found. Remember the differences between the profile file and the. bashrc file: both profiles are read only once at system startup, while. bashrc is read at system startup and every time shell is called. Vi. bashrc # Sample. bashrc for SuSE Linux # Copyright (c) SuSE GmbH Nuernberg # There are 3 different types of shells in bash: the login shell, normal shell # and interactive shell. login shells read ~ /. Profile and interactive shells # read ~ /. Bashrc; in our setup,/etc/profile sources ~ /. Bashrc-thus all # settings made here will also take effect in a login shell. # NOTE: It is recommended to make language settings in ~ /. Profile rather than # here, since multilingual X sessions wocould not work properly if LANG is over-# ridden in every subshell. # Some applications read the EDITOR variable to determine your favorite text # editor. so uncomment the line below and enter the editor of your choice :-) # export EDITOR =/usr/bin/vim # export EDITOR =/usr/bin/mcedit # For some news readers it makes sense to specify the NEWSSERV ER variable here # export NEWSSERVER = your. news. server # If you want to use a Palm device with Linux, uncomment the two lines below. # For some (older) Palm Pilots, you might need to set a lower baud rate # e.g. 57600 or 38400; lowest is 9600 (very slow !) # Export PILOTPORT =/dev/pilot # export PILOTRATE = 115200 test-s ~ /. Alias &&.~ /. Alias | true setting method in windows, you can use my computer> Properties> advanced to set system environment variables, however, does the environment variable set here have corresponding items in the registry? The answer is yes. In. net, a class is provided to obtain the system environment variables and their values. Environment variables are classified into two types: User variables and system variables, which have corresponding items in the registry. Where the user variable is located: HKEY_CURRENT_USER \ Environment; the SYSTEM variable is located at \ HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet001 \ Control \ Session Manager \ Environment. In addition, you can also right-click my computer-advanced-environment variables-in the system variables, there is a path option-double-click to open-add a semicolon in the English state based on the original variables-and then change the path name enter. (Do not delete the original system variables. separate them with semicolons and add them) editing Method: you can edit environment variables in the command line to view all currently available environment variables (= system variables + User variables) set to view an environment variable, such as PATHset PATH to add environment variables, for example, xxx = aaset xxx = aa sets the environment variable (such as xxx) value to null set xxx = add a new value (such as d: \ xxx) set PATH = % PATH %; d: \ xxx (note: Operations on environment variables in the dos window in the command line mode are only valid for applications in the current window)
Related Article

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.