Shell编程-基础

10 篇文章 0 订阅
1.shell是什么?
就是命令解释器,是用户访问系统的接口。
shell还是一门编程语言,shell是一种解释执行的编程语言。
shell是从前往后执行的。
一个操作系统中可以存在多个shell
[root@VM_0_16_centos ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh


2.shell的种类
1)sh
 bash(Linux)

2)csh



3.查看使用的shell
echo $SHELL

[root@VM_0_16_centos ~]# echo $SHELL
/bin/bash




4.shell环境定义
1)临时环境变量:即当前登录的环境有效,重新登录则失效
[root@VM_0_16_centos ~]# pstree
systemd─┬─YDLive───{YDLive}
        ├─YDService───6*[{YDService}]
        ├─acpid
        ├─2*[agetty]
        ├─atd
        ├─auditd───{auditd}
        ├─barad_agent─┬─barad_agent
        │             └─barad_agent───3*[{barad_agent}]
        ├─crond
        ├─dbus-daemon
        ├─dockerd-current─┬─docker-containe───6*[{docker-containe}]
        │                 └─9*[{dockerd-current}]
        ├─lsmd
        ├─lvmetad
        ├─ntpd
        ├─polkitd───5*[{polkitd}]
        ├─rsyslogd───2*[{rsyslogd}]
        ├─sgagent───{sgagent}
        ├─sshd─┬─sshd───bash───pstree
        │      └─sshd───sshd
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        └─tuned───4*[{tuned}]
[root@VM_0_16_centos ~]# pstree
systemd─┬─YDLive───{YDLive}
        ├─YDService───6*[{YDService}]
        ├─acpid
        ├─2*[agetty]
        ├─atd
        ├─auditd───{auditd}
        ├─barad_agent─┬─barad_agent
        │             └─barad_agent───3*[{barad_agent}]
        ├─crond
        ├─dbus-daemon
        ├─dockerd-current─┬─docker-containe───6*[{docker-containe}]
        │                 └─9*[{dockerd-current}]
        ├─lsmd
        ├─lvmetad
        ├─ntpd
        ├─polkitd───5*[{polkitd}]
        ├─rsyslogd───2*[{rsyslogd}]
        ├─sgagent───{sgagent}
        ├─sshd─┬─sshd───bash───pstree
        │      └─sshd───sshd
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        └─tuned───4*[{tuned}]
[root@VM_0_16_centos ~]# bash
[root@VM_0_16_centos ~]# pstree
systemd─┬─YDLive───{YDLive}
        ├─YDService───6*[{YDService}]
        ├─acpid
        ├─2*[agetty]
        ├─atd
        ├─auditd───{auditd}
        ├─barad_agent─┬─barad_agent
        │             └─barad_agent───2*[{barad_agent}]
        ├─crond
        ├─dbus-daemon
        ├─dockerd-current─┬─docker-containe───6*[{docker-containe}]
        │                 └─9*[{dockerd-current}]
        ├─lsmd
        ├─lvmetad
        ├─ntpd
        ├─polkitd───5*[{polkitd}]
        ├─rsyslogd───2*[{rsyslogd}]
        ├─sgagent───{sgagent}
        ├─sshd───sshd───bash───bash───pstree
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        └─tuned───4*[{tuned}]
[root@VM_0_16_centos ~]# bash
[root@VM_0_16_centos ~]# pstree
systemd─┬─YDLive───{YDLive}
        ├─YDService───6*[{YDService}]
        ├─acpid
        ├─2*[agetty]
        ├─atd
        ├─auditd───{auditd}
        ├─barad_agent─┬─barad_agent
        │             └─barad_agent───3*[{barad_agent}]
        ├─crond
        ├─dbus-daemon
        ├─dockerd-current─┬─docker-containe───6*[{docker-containe}]
        │                 └─9*[{dockerd-current}]
        ├─lsmd
        ├─lvmetad
        ├─ntpd
        ├─polkitd───5*[{polkitd}]
        ├─rsyslogd───2*[{rsyslogd}]
        ├─sgagent───{sgagent}
        ├─sshd─┬─sshd───bash───bash───bash───pstree
        │      └─2*[sshd───sshd]
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        └─tuned───4*[{tuned}]


只在当前环境有效
[root@VM_0_16_centos ~]# aa=123
[root@VM_0_16_centos ~]# echo $aa
123
[root@VM_0_16_centos ~]#






将环境变量永久生效

超级用户的环境变量
/etc/profile  针对系统所有用户生效,次文件应用于所有用户

普通用户的环境变量
$home_name/.bash_profile



系统定义好的环境变量
如$HOME,$PWD等

[root@VM_0_16_centos ~]# echo $HOME
/root
[root@VM_0_16_centos ~]# echo $PWD
/root
[root@VM_0_16_centos ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib/jvm/java/bin:/root/bin


















  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值