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
就是命令解释器,是用户访问系统的接口。
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