Get the App
SLTechnology News&Howtos  ›  Development  › 

Commands for viewing, adding, and configuring environment variables under Linux

Shulou Source: shulou.com Published: 2022-06-03 15:05:02 10月26日 Update

This article introduces the knowledge of "commands to view, add and configure environment variables under Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. You can view the path value with the export command

[root@localhost u-boot-sh5] # export can view all variables

two。 To view the PATH environment variables separately, you can:

[root@localhost u-boot-sh5] # echo $PATH

3. Add PATH environment variable (temporary), available:

[root@localhost u-boot-sh5] # export PATH=/opt/STM/STLinux-2.3/devkit/sh5/bin:$PATH

4. Permanently add environment variables (affecting the current user)

# vim ~ / .bashrc

Export PATH= "/ opt/STM/STLinux-2.3/devkit/sh5/bin:$PATH"

5. Permanently add environment variables (affecting all users)

# vim / etc/profile

At the end of the document, add:

Export PATH= "/ opt/STM/STLinux-2.3/devkit/sh5/bin:$PATH"

Save, exit, and then run:

# source / etc/profile

Ag:

Java use yum installation do not know where the installation path, want to configure the environment variable how to operate?

View the java installation path

View and use: set java_home under windows

View and use: whereis java under linux

The following is how I view linux

Java: / usr/bin/java / etc/java / usr/lib/java / usr/share/java / usr/share/man/man1/java.1.gz

Usually the first / usr/bin/java = > this is a file, according to which you can find the final installation directory

My final installation directory is / usr/lib/jvm/java

Configure the environment variables after finding the installation directory

Here are the environment variables that configure linux: (remember source .bash _ profile) vi this file / etc/profileexport JAVA_HOME=/usr/lib/jvm/javaexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Add at the end of the .bash _ profile file: export PATH=$JAVA_HOME/bin:$PATH.shell terminal executes the following command: (temporary) export PATH=$JAVA_HOME/bin:$PATH

Tags: Variable environment command configuration file directory content more user knowledge path permanent influence practical successful learning next dilemma reality situation document Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info Microsoft Docker MySQL