Linux system is the foundation of environment variables and their profiles
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
- The basic process of loading system login process is as follows:
A process, started Login:
Process II finished loading lang.sh etc., loaded environment variable configuration file:
Process III: by su - command to log in, you only need to reload /etc/bashrc
files, and other documents 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:
After su switch user, loading process environment variables is as follows:
su - after the handover user, the environment variable loading process is as follows:
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/bashrc
configuration 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
umask
The 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
-
Environment variables into effect profiles on logoff
~/.bash_logout
You can perform some specified command when you log out.
-
Command history
~/.bash_history
-
Local terminal login welcome message :( warning messages)
/etc/issue
remote failure-
Remote terminal display a message: /etc/issue.net
- Transfer character can not be used in /etc/issue.net
- In the ssh configuration file / etc / ssh / sshd_config decision, adding "Banner /etc/issue.net", and restart the service.
-
After landing a welcome message:
/etc/motd
-
/ Etc / ssh / sshd_config decision, adding "Banner /etc/issue.net", and restart the service.
-
After landing a welcome message:
/etc/motd
Whether local or remote login, you can display the information in the file!