Add environment variables to centos 7 and environment variables to centos
To configure environment variables in centos 7, you do not need to run the command source after each boot:
The environment variables configured previously Add a path after/etc/profile, but after each startup, the source/etc/profile command can be used. You can use the following methods directly:
Edit the/etc/environment file and change the PATH environment variable.
For example, add/soft/jdk/bin to the environment variable.
JAVA_HOME =/soft/jdk
PATH =/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/soft/jdk/bin
Save and remember source/etc/environment. You do not need source after restarting.
Note: The/etc/environment file has not been used before. It may be empty. Make sure to write the existing environment variables in the preceding format, then add the path to be added to the backend.
Otherwise, the system may fail to log on to the operating system. If logon fails, you can log in to the system in tty mode to modify the etc/environment file.