Article Title: how to modify the environment variables of a user's language in Linux. Linux is a technology channel of the IT lab in China. Some basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open-source systems are managed on the server. Some can input Chinese characters in the terminal, while others cannot, garbled characters are displayed. Compare the corresponding environment variables. We found that the environment variables for the language are different. I searched a lot of materials online and did not find a solution. After reading the relevant sections in the book, I found a solution. (The amount of information on the network is too large, sometimes it will waste a lot of time, but you still don't find what you want)
Record the methods and principles.
Bash shell configuration file:
/Etc/profile is used to set several important variables, such as PATH, USER, MAIL, HOSTNAME, HISTSIZE, and UMASK.
-Bash-3.00 # more/etc/profile #/Etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in/etc/bashrc Pathmunge (){ If! Echo $ PATH |/bin/egrep-q "(^ |:) $1 ($ |:)"; then If ["$2" = "after"]; then PATH = $ PATH: $1 Else PATH = $1: $ PATH Fi Fi } # Path manipulation If ['id-U' = 0]; then Pathmunge/sbin Pathmunge/usr/sbin Pathmunge/usr/local/sbin Fi Pathmunge/usr/X11R6/bin after # No core files by default Ulimit-S-c 0>/dev/null 2> & 1
USER = "'id-UN '" LOGNAME = $ USER MAIL = "/var/spool/mail/$ USER" HOSTNAME = '/bin/hostname' History Size = 1000 If [-z "$ INPUTRC"-! -F "$ HOME/. inputrc"]; then INPUTRC =/etc/inputrc Fi Export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC For I in/etc/profile. d/*. sh; do If [-r "$ I"]; then . $ I Fi Done Unset I Unset pathmunge |
/Etc/bashrc: used to plan umask and prompt content.
-Bash-3.00 # more/etc/bashrc #/Etc/bashrc # System wide functions and aliases # Environment stuff goes in/etc/profile # By default, we want this to get set. # Even for non-interactive, non-login shells. If ["'id-gn '" = "'id-un'"-a 'id-U'-gt 99]; then Umask 002 Else Umask 022 Fi # Are we an interactive shell? If ["$ PS1"]; then Case $ TERM in Xterm *) If [-e/etc/sysconfig/bash-prompt-xterm]; then PROMPT_COMMAND =/etc/sysconfig/bash-prompt-xterm Else PROMPT_COMMAND = 'echo-ne "\ 033] 0; $ {USER }@$ {HOSTNAME %. * }:$ {PWD/# $ HOME /~} \ 007 "' Fi ;; Screen) If [-e/etc/sysconfig/bash-prompt-screen]; then PROMPT_COMMAND =/etc/sysconfig/bash-prompt-screen Else PROMPT_COMMAND = 'echo-ne "\ 033 _ $ {USER }@$ {HOSTNAME %. * }:$ {PWD/# $ HOME /~} \ 033 \\"' Fi ;; *) [-E/etc/sysconfig/bash-prompt-default] & PROMPT_COMMAND =/etc/sysconfig/bash-prom Pt-default ;; Esac # Turn on checkwinsize Shopt-s checkwinsize ["$ PS1" = "\ s-\ v \ $"] & PS1 = "[\ u @ \ h \ W] \ $" Fi If! Shopt-q login_shell; then # We're not a login shell For I in/etc/profile. d/*. sh; do If [-r "$ I"]; then . $ I Fi Done Unset I Fi # Vim: ts = 4: sw = 4 Alias ls = "ls -- color" |
After setting, You need to log out and then log on to the system.
Personal setting value:
~ /. Bash_profile File Name of the personal path and environment variable. -Bash-3.00 # more. bash_profile #. Bash_profile # Get the aliases and functions If [-f ~ /. Bashrc]; then .~ /. Bashrc Fi # User specific environment and startup programs PATH = $ PATH: $ HOME/bin Export PATH Unset USERNAME LANG = zh_CN.gbk ~ /. Bashrc: Important Profile -Bash-3.00 # more. bashrc #. Bashrc # User specific aliases and functions # Source global definitions If [-f/etc/bashrc]; then ./Etc/bashrc Fi ~ /. Bash_history: This file records commands that have been used. |
You can modify the language environment variables of individual users. Bashrc or. Bash_profile.
-Bash-3.00 # env HOSTNAME = example ............. LANG = en_US.UTF-8 After modification:
QUOTE: -Bash-3.00 # env HOSTNAME = example ............. LANG = en_US.UTF-8 LANG = zh_CN.gbk |
Terminal garbled issues are solved.