To set environment variables on Fedora, you can use several methods depending on whether you want the variable to be temporary or permanent.
Temporary Environment Variables:
You can set a temporary environment variable by using the export command in the terminal. This variable will only last for the duration of your current terminal session.
Example:
export MY_VARIABLE="Hello World"
After running this command, you can access MY_VARIABLE in the same terminal session with echo $MY_VARIABLE.
Permanent Environment Variables:
For permanent environment variables, you need to add the export command to your shell's configuration file. For Bash shell, this is typically ~/.bashrc or ~/.bash_profile.
Example:
nano ~/.bashrc
export MY_VARIABLE="Hello World"
source ~/.bashrc
Now, MY_VARIABLE will be available in all new terminal sessions.
Using Systemd Environment Variables:
If you are working with systemd services, you might need to set environment variables in a systemd service file.
Example:
sudo nano /etc/systemd/system/my_service.service
Environment line within the [Service] section:[Service]
Environment=MY_VARIABLE="Hello World"
sudo systemctl restart my_service
For managing environment variables in a cloud environment, consider using services like Tencent Cloud's Cloud Functions or Container Service, which provide mechanisms to set and manage environment variables for your applications.