setenv设置环境变量

Linux and Unix ecosystem mainly used command line based. While working with command line and C Shell we generally need some values to use with commands. Shells provide environment variables for this. This environment variables can be managed with setenv command like add, change and remove.

Linux和Unix生态系统主要使用基于命令行的。 在使用命令行和C Shell时,我们通常需要一些值才能与命令一起使用。 外壳为此提供了环境变量。 可以使用setenv命令(例如添加,更改和删除)来管理此环境变量。

句法 (Syntax)

Syntax of setenv command is very simple we just need to provide the variable name and data

setenv命令的语法非常简单,我们只需要提供变量名称和数据

setenv VARIABLENAME DATA

列出所有环境变量 (List All Environment Variables)

We can use setenv in order to list all environment variables currently defined in C Shell.

我们可以使用setenv来列出C Shell中当前定义的所有环境变量。

$ setenv

List All Environment Variables
列出所有环境变量

添加环境变量(Add Environment Variable)

We will start by creating come environment variable and setting some data to it. We can use lowercase or uppercase letters bu the general usage is uppercase letters. In this case we will create a variable named MYIP and set value 192.168.1.10

我们将首先创建环境变量并为其设置一些数据。 我们可以使用小写或大写字母,一般用法是大写字母。 在这种情况下,我们将创建一个名为MYIP的变量,并将其值设置为192.168.1.10

$ setenv MYIP 192.168.1.10

打印环境变量 (Print Environment Variable)

We can print specific environment variable with echo command. We will provide the environment variable and and prefix with $ . In this example we will print environment variable named MYIP like below.

我们可以使用echo命令打印特定的环境变量。 我们将提供环境变量and并带有$前缀。 在此示例中,我们将如下打印名为MYIP环境变量。

$ echo $MYIP

Print Environment Variable
打印环境变量

将环境变量传递给子外壳或子外壳(Pass Environment Variables To Sub or Child Shell)

Linux process and shell architecture provides the ability to run sub process or shell. Sub process and shell will create a new environment. If we need to use current environment variables in the sub process or shell we just need to use them accordingly. For example in the following example we will print previously defined MYIP in the bash sub-shell.

Linux进程和Shell体系结构提供了运行子进程或Shell的能力。 子进程和shell将创建一个新环境。 如果我们需要在子进程或shell中使用当前环境变量,我们只需要相应地使用它们即可。 例如,在以下示例中,我们将在bash子外壳中打印先前定义的MYIP

$ echo $MYIP

Pass Environment Variables To Sub or Child Shell
将环境变量传递给子外壳或子外壳

设置或更新一个环境变量值(Set OR Update One Environment Variable Value)

After assigning a value to a environment variable we may need to update it with new value. We can use set command in order to update current environment variable with a new value. In this example we will update our variable MYIP with 192.168.1.20

将值分配给环境变量后,我们可能需要使用新值对其进行更新。 我们可以使用set命令来用新值更新当前环境变量。 在此示例中,我们将使用192.168.1.20更新变量MYIP。

$ set MYIP=192.168.1.20

Set OR Update One Environment Variable Value 
设置或更新一个环境变量值

有用的环境变量(Useful Environment Variables)

There are a lot of default enviroment variables. Here are some of them.

有很多默认环境变量。 这里是其中的一些。

  • USER stores current user name

    USER存储当前用户名

  • PWD current working directory

    PWD当前工作目录

  • SSH_CLIENT the ssh client IP address with source and destination port numbers

    SSH_CLIENT带有源和目标端口号的ssh客户端IP地址

  • SHELL current shell

    SHELL当前外壳

.u949ab96ca0e9ed15e43db7b225e9bb0f , .u949ab96ca0e9ed15e43db7b225e9bb0f .postImageUrl , .u949ab96ca0e9ed15e43db7b225e9bb0f .centered-text-area { min-height: 80px; position: relative; } .u949ab96ca0e9ed15e43db7b225e9bb0f , .u949ab96ca0e9ed15e43db7b225e9bb0f:hover , .u949ab96ca0e9ed15e43db7b225e9bb0f:visited , .u949ab96ca0e9ed15e43db7b225e9bb0f:active { border:0!important; } .u949ab96ca0e9ed15e43db7b225e9bb0f .clearfix:after { content: ""; display: table; clear: both; } .u949ab96ca0e9ed15e43db7b225e9bb0f { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u949ab96ca0e9ed15e43db7b225e9bb0f:active , .u949ab96ca0e9ed15e43db7b225e9bb0f:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u949ab96ca0e9ed15e43db7b225e9bb0f .centered-text-area { width: 100%; position: relative; } .u949ab96ca0e9ed15e43db7b225e9bb0f .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u949ab96ca0e9ed15e43db7b225e9bb0f .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u949ab96ca0e9ed15e43db7b225e9bb0f .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u949ab96ca0e9ed15e43db7b225e9bb0f:hover .ctaButton { background-color: #E67E22!important; } .u949ab96ca0e9ed15e43db7b225e9bb0f .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u949ab96ca0e9ed15e43db7b225e9bb0f .u949ab96ca0e9ed15e43db7b225e9bb0f-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u949ab96ca0e9ed15e43db7b225e9bb0f:after { content: ""; display: block; clear: both; }

LEARN MORE  Linux Tee Command Tutorial with Examples For Stdout Management

.u949ab96ca0e9ed15e43db7b225e9bb0f , .u949ab96ca0e9ed15e43db7b225e9bb0f .postImageUrl , .u949ab96ca0e9ed15e43db7b225e9bb0f .centered-text-area { min-height: 80px; position: relative; } .u949ab96ca0e9ed15e43db7b225e9bb0f , .u949ab96ca0e9ed15e43db7b225e9bb0f:hover , .u949ab96ca0e9ed15e43db7b225e9bb0f:visited , .u949ab96ca0e9ed15e43db7b225e9bb0f:active { border:0!important; } .u949ab96ca0e9ed15e43db7b225e9bb0f .clearfix:after { content: ""; display: table; clear: both; } .u949ab96ca0e9ed15e43db7b225e9bb0f { display: block; transition: background-color 250ms; webkit-transition: background-color 250ms; width: 100%; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #ECF0F1; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -o-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.17); } .u949ab96ca0e9ed15e43db7b225e9bb0f:active , .u949ab96ca0e9ed15e43db7b225e9bb0f:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; background-color: #D35400; } .u949ab96ca0e9ed15e43db7b225e9bb0f .centered-text-area { width: 100%; position: relative; } .u949ab96ca0e9ed15e43db7b225e9bb0f .ctaText { border-bottom: 0 solid #fff; color: #3498DB; font-size: 16px; font-weight: bold; margin: 0; padding: 0; text-decoration: underline; } .u949ab96ca0e9ed15e43db7b225e9bb0f .postTitle { color: #27AE60; font-size: 16px; font-weight: 600; margin: 0; padding: 0; width: 100%; } .u949ab96ca0e9ed15e43db7b225e9bb0f .ctaButton { background-color: #e6e6e6!important; color: #3498DB; border: none; border-radius: 3px; box-shadow: none; font-size: 14px; font-weight: bold; line-height: 26px; moz-border-radius: 3px; text-align: center; text-decoration: none; text-shadow: none; width: 80px; min-height: 80px; background: url(https://www.poftut.com/wp-content/plugins/intelly-related-posts/assets/images/simple-arrow.png)no-repeat; position: absolute; right: 0; top: 0; } .u949ab96ca0e9ed15e43db7b225e9bb0f:hover .ctaButton { background-color: #E67E22!important; } .u949ab96ca0e9ed15e43db7b225e9bb0f .centered-text { display: table; height: 80px; padding-left: 18px; top: 0; } .u949ab96ca0e9ed15e43db7b225e9bb0f .u949ab96ca0e9ed15e43db7b225e9bb0f-content { display: table-cell; margin: 0; padding: 0; padding-right: 108px; position: relative; vertical-align: middle; width: 100%; } .u949ab96ca0e9ed15e43db7b225e9bb0f:after { content: ""; display: block; clear: both; }

了解更多Linux Tee命令教程,以及有关Stdout管理的示例

翻译自: https://www.poftut.com/setenv-command-tutorial-to-add-delete-and-change-environment-variables-in-linux/

setenv设置环境变量

setenv设置环境变量_setenv命令教程在Linux中添加,删除和更改环境变量相关推荐

  1. linux中添加环境变量

    linux中添加环境变量 一般是在/etc/profile中添加环境,但是建议在/etc/profile.d/下创建一个以.sh结尾的文件 vim /etc/profil.d/my_env.sh 输入 ...

  2. windows和linux中搭建python集成开发环境IDE——如何设置多个python环境

    本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...

  3. cad2016中选择全图字体怎么操作_cad教程分享CAD中如何删除顽固图层?

    Autocad教程公众号,专注于cad教程.cad教程视频的分享,欢迎关注,下载你所需的教程资源! 如你还未关注,请点击文章标题下方蓝色字体的"Autocad教程"进行关注. ca ...

  4. linux wget 命令_在Linux中如何使用wget命令?

    linux wget 命令 In this tutorial, let's learn how to download a file using the wget command in Linux. ...

  5. linux中安装配置golang开发环境

    linux中安装配置golang开发环境 不要误以为linux配置环境很难,其实也不一定.可能更简单[windows 安装后安装程序给你配一半,你再配置,可能还出问题,先删除软件给你配的,再自己配置. ...

  6. linux中sed命令用例,Linux中使用sed命令或awk命令修改常规配置文件

    一.方案: Linux中使用sed命令或awk命令修改常规配置文件 二.步骤: 1.假设有一个a.txt,内容如下: #!/bin/bash aa= bbb= ccc= #ddd= 2.如果想要把里面 ...

  7. 使用adduser命令在Debian Linux中创建用户

    在本教程中,我们将学习如何使用命令行界面在Debian Linux中添加用户. Debian Linux使用adduser命令从命令行创建用户.使用adduser命令后跟用户名来创建具有默认选项的新用 ...

  8. 【LaTeX技巧】 | LaTeX数学公式环境中添加删除线

    LaTeX数学公式环境中添加删除线 LaTeX数学公式环境中添加删除线 LaTeX数学公式环境中添加删除线 作者:刘兴禄,清华大学,博士在读 cancel包 下面是一个例子. \documentcla ...

  9. linux vsftpd删除用户,Linux/CentOS添加/删除FTP用户并设置权限

    在linux中添加ftp用户,并设置相应的权限,操作步骤如下: 1.环境:ftp为vsftp.被设置用户名为test.被限制路径为/alidata/www/test 2.建用户:在root用户下: u ...

最新文章

  1. 09 numpy 聚合函数 - 极值,方差,标准差
  2. python 获取指定文件夹里面的图片文件的信息
  3. javascript 代码分离 的那些事儿
  4. CentOS 7下安装samba
  5. 铃儿响叮当用计算机怎么弹,铃儿响叮当钢琴弹奏教学视频
  6. keil c语言循环嵌套,keil软件中C语言嵌套汇编
  7. java入门到精通第六版_java从入门到精通-第6章.pdf
  8. LaTeX 常用符号大全(from wikipedia)
  9. Ubuntu(Linux)腾达U12网卡驱动的离线安装
  10. Python 算法之 动态规划详解
  11. Flink 常见问题总结
  12. 乌云沙龙:赛棍的自我修养
  13. 机械硬盘显示数据错误循环冗余检查文件如何寻回
  14. 插上翅膀,看华为云CDN如何带你网上冲浪
  15. 上海到底是一座什么样的城市?
  16. (完结项目)fpga采集双路CCD摄像头1000帧图像上传到上位机显示
  17. POJ3614 [USACO07NOV]防晒霜Sunscreen
  18. [黑马IOS自学第十篇]OC语言基础,面向对象概念,类学习
  19. 工具变量:顶刊中的Shock-IV整理
  20. H3C无线接入控制器特点

热门文章

  1. html与css编程证书,利用CSS布局做一个简单的荣誉证书(代码示例)
  2. 理解MMORPG、回合制、ARPG、SLG、Roguelike、卡牌、竞技类
  3. SDLC开发过程:基于DevSecOps理念的解决方案
  4. MATLAB坐标轴位置调整
  5. excel如何一次批量选中工作表全部图片
  6. Apollo代码学习(二)—车辆运动学模型
  7. python 办公常用一:从文本文件中提取手机号码
  8. [025] 微信公众帐号开发教程第1篇-引言
  9. git更换主分支master
  10. double值精确到小数点后两位