[Shell] Bash variables: Configuration file and login information for environment variables

Source: Internet
Author: User
Tags aliases system log

Only the environment variables are placed in the configuration file to automatically take effect each time the power-on. SOURCE command: Let the configuration file take effect directly without logging off or logging back in.

Source configuration file or . configuration file ( equivalent to the source configuration file)

"Five types of environment variable configuration files in the system"

/etc/profile

/etc/profile.d/*.sh

~/.bash_profile

~/.bashrc

/etc/bashrc

(The environment variable profile in the ETC directory is valid for all users, the start is only valid for the current user)

"Execution flow of configuration Files"

/etc/profile------> ~/.bash_profile------> ~/.BASH_RC------>/ETC/BASHRC-------Command prompt

| |

|-------------->/etc/profile.d/*.sh (Load all scripts in this) <--------|

|

|

/etc/profile.d/lang.sh----->/etc/locale.conf (lang= "en_US. UTF-8 ")

First route:

/etc/profile,/etc/profile.d/*.sh,

The second route:

VI ~/.bash_profile

#. bash_profile# Get the aliases and functions (if the home directory has. BASHRC, then execute) if [-F ~/.BASHRC]; Then    . ~/.bashrcfi# User specific environment and startup Programspath= $PATH: $HOME/.local/bin: $HOME/bin ( Environment variables appended to the home directory of the bin directory, my $home here is/home/weichen) export PATH (set as environment variable)

If you want to use a directory as the system default search command path, and permanent, it can be written in this configuration file.

VI ~/.BASHRC

#. bashrc# Source Global Definitions (if/ETC/BASHRC file is executed) if [-F/ETC/BASHRC]; Then    ./etc/bashrcfi# uncomment the following line if you don't like Systemctl ' s auto-paging feature:# export systemd_ pager=# User specific aliases and functions (if you need to define a system command alias, can be written in this configuration file) alias Vi=vimalias rm= ' rm-i ' Alias cp= ' Cp-i ' Alias mv= ' Mv-i '

Vi/etc/bashrc

Define PS1 variable Umaskpath variable call/etc/profile.d/*.sh file (this file is for no login shell only)

Summary

To make the configuration permanent, it can be written in any of the above configuration files, but note whether it is for all users or the current user, and the subsequent file configuration will overwrite the previous one, unless you use a variable overlay.

"Additional profile and login information"

  ~/.bash_logout

Default is empty, if you want to let the system log off when you execute some commands, you can write in this configuration file.

  ~/.bash_history

The history command saves the file, only history-w or the logoff log-in will write to the file, is the system to arrange the mistake the important basis, but after setting the password to clear the history command.

Shell Login Information:

1. Local Terminal login information:/etc/issue

\d Display the current system date

\s Display Operating system name

\l Displays the terminal number of the login, which is more commonly used

\m display hardware architecture, such as i386, i686, etc.

\ nthe host name is displayed

\o Display domain name

\ r Show Kernel version

\ t displays the current system time

\U Displays the serial number of the currently logged on user

2. Remote Terminal login information:/etc/issue.net

The above escape character cannot be used in the/etc/issue.net file

Whether to display this login information, by SSH configuration file/etc/ssh/sshd_config decision, add "banner/etc/issue.net" line to display (remember to restart the SSH service)

Editor: Vi/etc/ssh/sshd_config join: #Banner nonebanner/etc/issue.net restart: service sshd restart

3. Post-Login Welcome information:/ETC/MOTD

This welcome message can be displayed whether you are logged on locally or remotely.

[Shell] Bash variables: Configuration file and login information for environment variables

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.