使用.sh脚本设置环境变量 [英] Using .sh script to set an environment variable

查看:1657
本文介绍了使用.sh脚本设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写一个.sh脚本将在Ubuntu 14上全局设置一个环境变量。

How do I write an .sh script what will globally set an environment variable on Ubuntu 14.

#!/bin/sh
sets this in to master /etc/environment 
export DB_HOST="123"

我知道我可以运行这个脚本,它会将其设置为仅限会话!,但是我实际上想要做的是将.sh脚本将环境变量复制到/ etc / environment,以便系统地使用。

I am aware I could just run this script and it would set it for the session only!, but what I actually want to do is have the .sh script copy the environment variable to /etc/environment so it is system wide.

有没有办法运行全局设置的脚本?

is there a way to run the script that it gets set globally?

推荐答案

/ etc / profile 运行你的脚本,然后你会得到你以后的东西。

Run your script from /etc/profile, then you'll get what yuo're after.

这篇关于使用.sh脚本设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆