Linux system environment variable configuration file

Linux system is the foundation of environment variables and their profiles


Here Insert Picture Description

First, the environment variable configuration file

  • /etc/profile # Global configuration file
  • /etc/profile.d/*.sh # Global configuration file, lang language
  • ~/.bash_profile # User specific configuration file defines the user environment
  • ~/.bashrc # User-specific configuration file, user-defined alias (alias)
  • /etc/bashrc # Global configuration file, the prompt (PS1)

Second, the role of the configuration file

/etc Directory take effect for all users under

~/ Only the current user directory into force

  1. The basic process of loading system login process is as follows:
/etc/profile
~/.bash_profile
~/.bashrc
/etc/bashrc
命令提示符
/etc/profile.d/*.sh
/etc/profile.d/lang.sh

A process, started Login:

/etc/profile
/etc/profile.d/*.sh
/etc/profile.d/lang.sh

Process II finished loading lang.sh etc., loaded environment variable configuration file:

/etc/profile
~/.bash_profile
~/.bashrc
/etc/bashrc
命令提示符

Process III: by su - command to log in, you only need to reload /etc/bashrcfiles, and other documents lang.sh:

/etc/bashrc
/etc/profile.d/*.sh
/etc/profile.d/lang.sh
命令提示符

Case 1, the loading process demonstration system environment variables:

# 最初登录系统,加载系统环境变量配置文件流程
/etc/profile
.bash_profile
.bashrc
/etc/bashrc
# 通过su 命令切换root 用户,环境变量的加载流程
[chenman@localhost ~]$ su
Password:
~/.bashrc
/etc/bashrc
[root@localhost chenman]# exit
# 通过su - 命令切换root 用户,环境变量的加载流程
[chenman@localhost ~]$ su -
Password:
Last login: Fri Mar 20 17:40:47 CST 2020 on pts/0
/etc/profile
~/.bash_profile
~/.bashrc
/etc/bashrc

The default login environment variable loading process is as follows:

/etc/profile
~/.bash_profile
~/.bashrc
/etc/bashrc
命令提示符

After su switch user, loading process environment variables is as follows:

~/.bashrc
/etc/bashrc
命令提示符

su - after the handover user, the environment variable loading process is as follows:

/etc/profile
~/.bash_profile
~/.bashrc
/etc/bashrc
命令提示符

By the above case demonstrates, can be drawn:
the default login will be loaded by the process environment variables, su command to switch loads only ~/.bashrc, /etc/bashrcconfiguration files, su -it will, and the default login the same, according to the process environment variable loads. Therefore, when we need to add environment variables need to declare variables by using the scene.
Note: The maximum file permissions are 666

The highest authority of the directory is 777 x permissions for the directory is cd

umaskThe permissions are defined default permissions permissions prepared discarded, umask value is a value obtained by subtracting the letter (XOR);

E.g:

umask = 022 that is created

The default file permissions are rw-rw-rw- ---- w-w- = rw-r-r-- 644

The default directory permissions are rwxrwxrwx ---- w-w- = rwxr-xr-x 755

Third, other profiles

  1. Environment variables into effect profiles on logoff ~/.bash_logout

    You can perform some specified command when you log out.

  2. Command history ~/.bash_history

  3. Local terminal login welcome message :( warning messages) /etc/issueremote failure

    1. Remote terminal display a message: /etc/issue.net

      1. Transfer character can not be used in /etc/issue.net
      2. In the ssh configuration file / etc / ssh / sshd_config decision, adding "Banner /etc/issue.net", and restart the service.
    2. After landing a welcome message: /etc/motd

/ Etc / ssh / sshd_config decision, adding "Banner /etc/issue.net", and restart the service.

  1. After landing a welcome message: /etc/motd

    Whether local or remote login, you can display the information in the file!

Published 55 original articles · won praise 20 · views 70000 +

Guess you like

Origin blog.csdn.net/AMimiDou_212/article/details/104994421