A detailed explanation of shell variables in Linux

Source: Internet
Author: User
Tags file size locale resource

Shell variables are divided into environment variables and custom variables, the difference is whether the variable can be used in the quilt process, look at the following diagram:

If you are an environment variable, you can continue to use it in a child process, but if it is a custom variable, it will fail in the subprocess.

View environment variables with env

The common environment variables are as follows:

1 home: User's main directory (CD ~)

2 Shell: User's default shell

3) Histsize: Number of historical records

4) Mail: Mail Box file

5 path: Execute File Lookup path

6) LANG: Language family

View environment variables and custom variables with set

Some of the more important custom variables are:

1) PS1: Prompt settings

2) $: This shell's PID

3)?: Return code of last execution command

Use export to turn custom variables into environment variables

As we mentioned above, only environment variables can be used by the quilt process, so if you want a custom variable to be used by the quilt process, use the Export command to turn it into an environment variable.

Display and cancellation of variables-echo unset

Echo is used to display the value of a variable, such as:

# echo $SHELL

/bin/bash

Unset is used to cancel a variable, such as:

# export A=1  
# echo $a  
1  
# unset A  
# echo $a  --return null

Language variables-locale and Lang

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

We can get the current language code through the locale command, as follows:

# locale  
Lang=en_us. UTF-8  
lc_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, just set the lang variable. The default language variables are defined by the following file:

# cat/etc/sysconfig/i18n

Lang= "en_US. UTF-8 "

Sysfont= "Latarcyrheb-sun16"

Declaration of a variable-declare

Variables declared by declare default to be custom variables, and if the-x parameter representation is defined as an environment variable (same as export effect)

Resource limitations for users-ulimit

Perform ulimit-a to list current user Resource usage restrictions:

# ulimit-a  
core file size          (blocks,-c) 0  
data seg size           (Kbytes,-D) unlimited  
scheduling /> (-e) 0  
file size               (blocks,-f) Unlimited  
pending signals (-I                 ) 29823  
max locked Memory       ( Kbytes, L)  
max memory size         (Kbytes,-m) unlimited  
open files                      (-N) 65535  
pipe Size            ( Bytes-P) 8  
POSIX message Queues     (bytes,-q) 819200  
real-time Priority              (-R) 0  
stack size< c24/> (Kbytes,-s) 10240  
CPU time               (seconds,-T) unlimited  
max User Processes              (-u) 1024  
virtual Memory          (Kbytes,-V) unlimited  
file Locks                      (-X) Unlimited
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.