How Do I Set the Hostname Variable in Linux?
Contents How Do I Set Environment Variables in Linux? to Make an Environment Persistent for a User’s Environment, We Export the Variable from the User’s...
Contents
How do I set environment variables in Linux?
To make an environment persistent for a user’s environment, we export the variable from the user’s profile script.
- Open the current user’s profile into a text editor. vi ~/.bash_profile.
- Add the export command for every environment variable you want to persist. export JAVA_HOME=/opt/openjdk11.
- Save your changes.
Must Read
How do I find my environment variable hostname?
$HOSTNAME is a Bash variable that’s set automatically (rather than in a startup file). Ruby probably runs sh for its shell and it doesn’t include that variable. There’s no reason you can’t export it yourself. You could add the export command to one of your startup files, such as ~/.