[Linux] Shell variable

Source: Internet
Author: User

Shell variables are divided into environment variables and custom variables. The difference between the two variables lies in whether the variables can be used by the process. See one of the following:

If it is an environment variable, the sub-process can still be used, but if it is a custom variable, the sub-process will become invalid.

Use env to view environment variables common environment variables are as follows: 1) HOME: Your main directory (cd ~) 2) SHELL: the user's default shell 3) HISTSIZE: Number of history records 4) MAIL: email box file 5) PATH: Execution File Search PATH 6) LANG: when you use set to view environment variables and custom variables, the most important custom variables include: 1) PS1: prompt setting 2) $: Current shell PID 3 )? : The return code of the previous command is used to convert the custom variable into the environment variable. As we mentioned above, only the environment variable can be used by the process, so if you want a custom variable to be used by the quilt process, use the export command to change it to an environment variable. Variable display and cancellation-echo unsetecho is used to display the value of a variable, for example:
# echo $SHELL/bin/bash
Unset is used to cancel variables, such:
# Export a = 1 # echo $ a1 # unset a # echo $ a -- return null
Language variables-locale and LANG we can use the locale command to obtain the current language encoding, as shown below:
# localeLANG=en_US.UTF-8LC_CTYPE="en_US.UTF-8"LC_NUMERIC="en_US.UTF-8"LC_TIME="en_US.UTF-8"LC_COLLATE="en_US.UTF-8"LC_MONETARY="en_US.UTF-8"LC_MESSAGES="en_US.UTF-8"LC_PAPER="en_US.UTF-8"LC_NAME="en_US.UTF-8"LC_ADDRESS="en_US.UTF-8"LC_TELEPHONE="en_US.UTF-8"LC_MEASUREMENT="en_US.UTF-8"LC_IDENTIFICATION="en_US.UTF-8"LC_ALL=
In actual use, you only need to set the LANG variable. The default language variables are defined by the following files:
# cat /etc/sysconfig/i18nLANG="en_US.UTF-8"SYSFONT="latarcyrheb-sun16"
Variable Declaration-declare the variables declared by declare are custom variables by default. If the-x parameter is added, the variables are defined as environment variables (the same effect as export) execute ulimit-a to list the resource usage restrictions of the current user:
# ulimit -acore file size          (blocks, -c) 0data seg size           (kbytes, -d) unlimitedscheduling priority             (-e) 0file size               (blocks, -f) unlimitedpending signals                 (-i) 29823max locked memory       (kbytes, -l) 64max memory size         (kbytes, -m) unlimitedopen files                      (-n) 65535pipe size            (512 bytes, -p) 8POSIX message queues     (bytes, -q) 819200real-time priority              (-r) 0stack size              (kbytes, -s) 10240cpu time               (seconds, -t) unlimitedmax user processes              (-u) 1024virtual memory          (kbytes, -v) unlimitedfile locks                      (-x) unlimited

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.