Environment variables are closely related to the shell, and a shell is launched when the user logs in to the system. For Linux it is generally bash, but you can also reset or switch to another shell. Depending on the release version, bash has two basic system-level configuration files: /etc/bashrc and /etc/profile. These configuration files contain two different sets of variables: shell variables and environment variables. The former is only fixed in a specific shell (such as bash), which is fixed in different shells. This article is based on the article at the end of the article to streamline, organize, non-Tianyuan original, hereby declare. First, the environment variable settings 1, display environment variables $ echo $HOME example uses echo to display the variable HOME. Other variables are similarly used. 2, set a new environment variable $ export MYDIR = & rdquo; /usr /local /include & rdquo; set MYDIR to /usr /local /include3, display all environment variables $ env4, use the set command to display all locally defined shell variables $ set5 Use the unset command to clear the environment variable $ unset $MYDIR to delete the environment variable MYDIR. 6. Add to the system PATH example to modify the .bash_profile file: $ vi .bash_profile #Modify the environment variable definition file and edit your PATH statement in the format: PATH=$PATH:<PATH 1>:<PATH 2>: ---:<PATH N> Just separate the newly added path from the other path by a colon. 7. Immediately take effect. $source.bash_profile 2. Environment Variable Access The following example uses a C program to access and set environment variables. We have three functions to set or access an environment variable. 1.getenv() accesses an environment variable. The input parameter is the name of the variable that needs to be accessed, and the return value is a string. If the accessed environment variable does not exist, it will return NULL. 2.setenv () in the program to set a function of a certain environment variable. 3.unsetenv() clears the function of a particular environment variable. In addition, there is a pointer variable environ that points to a list of all environment variables. The following program can print out all the environment variables in the current running environment: #include <stdio.h>extern char**environ;int main (){char**var;for (var =environ;*var !=NULL ;++var)printf (”%s /n “,*var);return 0;
}
tcpdump is a commonly used capture tool under the Linux command line, record the usual way, the test
One of the benefits of learning Linux is that you can understand how the hardware works and the pri
vmstat is a tool for viewing virtual memory usage. General format: vmstat [-V] [-n] [delay [count]]C
Cant write data on the hard disk of Linux or UNIX-like systems? Want to solve the problem of disk co
How to install software in Linux operating system
Steam host will enable Linux system
Overview of Linux I2C Driver Architecture
Df and du commands using basic tutorials
How to use the Linux operating system Rar compressed file package
Linux/Windows/Mac refresh DNS cache
Research and transplantation of MiniGUI in embedded Linux environment
Virtualbox command line sharing CentOS directory
Nginx SSL/TLS configuration for “A+” Qualys SSL Labs ratin
Linux kernel interrupt mechanism analysis
The Win10 system creates a local account where to create a local account. Steps
A detailed description of the six major flaws in Windows 7 "XP mode"
How to watch movies for free with win7
Win7 can not be shut down properly
Quickly create standard users under windows7 has a coup
How to close the network card in win7 system
Let QQ personal data follow the example of the
Windows theme crack (general patch) installation instructions
Question: Why is there no Beijing time zone selection in Beijing?