Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux, set and view environment variables     - Linux use glibc2 library and crypt () function to generate the user password (Programming)

- Linux for enterprises to build a firewall (Linux)

- Elasticsearch 2.20 Highlight (Server)

- SpringMVC garbage processing (Programming)

- Linux NIC driver and version information (Linux)

- Oracle Database High-Risk Vulnerability Warning (Database)

- Android custom title bar (Programming)

- Install Debian Linux with R on the Android system (Linux)

- How to install Linux Go Language (Linux)

- How to use nmap command in Linux (Linux)

- Linux kernel compilation, the configuration of the motor drive (Programming)

- Linux environment variables inside (Linux)

- Oracle database physical file backup / restore (Database)

- To setup a ftp server under Linux (Server)

- Oracle 11g can not export a variety of empty table solution (Database)

- Gitblit adopted Ticket collaborative development model (Linux)

- Android memory optimization of the optimal load Bitmap (Linux)

- Netcat Example (Linux)

- Performance issues under CentOS 6.5 VLAN devices (Linux)

- How to install OpenOffice Ubuntu or Linux Mint (Linux)

 
         
  Linux, set and view environment variables
     
  Add Date : 2016-08-25      
         
         
         
  Variable types of Linux

Press lifetime variable to divide, Linux variables can be divided into two categories:
1 permanent: the need to modify the configuration files, variables permanent.
Temporary 2: Use the export command to declare the variable fail in the closed shell.

Three ways to set variables

1 variables in the / etc / profile file for all users [entry into force of (permanent)]
Increase in variable file / etc / profile file using the VI, the variable will be effective for all users to Linux, and is "permanent."
For example: Edit / etc / profile file add the CLASSPATH variable
# Vi / etc / profile
. Export CLASSPATH = / JAVA_HOME / lib; $ JAVA_HOME / jre / lib

NOTE: After modifying the file in order to take effect immediately even run # source / etc / profile or only the next time the user re-enter into force.

2 increase variable in .bash_profile in the user directory under [the entry into force of a single user (permanent)]
Increase with VI in the .bash_profile file in the user directory variable, the amount of change is only valid on the current user, and is "permanent."
For example: .bash_profile edit guok user directory (/ home / guok) under
$ Vi /home/guok/.bash.profile
Add the following:
. Export CLASSPATH = / JAVA_HOME / lib; $ JAVA_HOME / jre / lib
NOTE: After modifying the file in order to take effect immediately will run for $ source /home/guok/.bash_profile otherwise only the next time the user re-enter into force.

3 run directly export command to define variables [only for the current shell (BASH) effective (temporary)]
Use [export variable name = variable value] to define variables directly in the shell command line,

The only variable in the current shell (BASH) or a sub-shell (BASH) below is valid,

Close up of shell variables also fails, you do not have this variable and then open a new shell, if you need to use also need to be redefined.

Check environment variables

1 Use the echo command to view a single environment variable. E.g:
echo $ PATH
2 Use env to see all the environment variables. E.g:
env
3 Use set to see all the local environment variables defined.

Use unset to delete the specified environment variable

set can set the value of an environment variable. Clear the environment variable with the unset command. If you do not specify a value, the value of the variable will be set to NULL. Examples are as follows:
$ Export TEST = "Test ..." # add an environment variable TEST
$ Env | grep TEST # this command input, proof environment variable TEST already exists
TEST = Test ...
unset TEST # delete the environment variable TEST
$ Env | grep TEST # this command no output, proven environment variable TEST have been deleted

Common environment variables

PATH to determine the shell which directories to find commands or programs
HOME The current user's home directory
HISTSIZE history records
LOGNAME current user's login name
HOSTNAME refers to the name of the host
SHELL Current User Shell type
LANGUGE language-related environment variables, multi-language environment variables can be modified
MAIL current user's mail store directory
PS1 primary prompt for the root user is #, for the average user is $
     
         
         
         
  More:      
 
- Open source backup software installed on Ubuntu Systemback 1.6.201 (Linux)
- Iptables on the request URL for IP access control (Linux)
- Hibernate Search 5.5 in the search results sorted (Linux)
- Ubuntu 14.10 / 14.04 / 12.04 virtual users to install the printing software Boomaga (Linux)
- Linux delete duplicate files Artifact: dupeGuru (Linux)
- Shell scripts quickly deploy Tomcat project (Server)
- CentOS6.3 build a Python 3.3 environment to access Oracle 11gR2 (Database)
- Do not enter password login ssh (Server)
- Oracle table space usage monitoring (Database)
- Install the Red Hat Container Development Kit on OSX (Server)
- Oracle user password problem (Database)
- CentOS 6/7 Series Docker Installation (Linux)
- Resolve the host via KVM console can not connect clients (Linux)
- Android Studio Clear Project or Rebuild Project Error (Linux)
- Upgrade installation manual CentOS6.5 GCC4.8.2 (Linux)
- Linux Timing task Crontab command Detailed (Linux)
- Android start automatically and add and delete a desktop shortcut (Programming)
- How LUKS encrypted disk / partition to perform remote incremental backup (Linux)
- Android Application Development: an argument between Activity (Programming)
- Ubuntu and Archlinux install Notepadqq 0.50.2 (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.