Shell 脚本语言是弱类型语言,变量名称无需指定数据类型,Linux 系统下主要分为Bourne Shell 和 C Shell两种。Bourne Shell 包括 sh 和bash等,C Shell 包括 csh 和 tcsh 等。shell
本文假设用户已经完成安装 CentOS7.6,推荐我的用户使用 XShell 我的版,本文大部分命令在该软件下执行并显示,您还能够使用Putty等软件。系统和软件安装本文不涉及。bash
下文开始演示 shell 命令。编写环境以下编辑器
#Shell 查看系统信息方法1 [root@promote ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) #Shell 查看系统信息方法2 #安装系统信息查看软件redhat-lsb [root@promote ~]# yum install redhat-lsb -y [root@promote ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.6.1810 (Core) Release: 7.6.1810 Codename: Core
经过 Shell 脚本指令 cat 能够查看系统信息文件 /etc/redhat-release 显示当前系统为 CentOS Linux release 7.6.1810 (Core) 。后一个命令输出结果更为详细。学习
其余脚本语言还包括 PHP、Perl、JavaScript、Python 等,不在本文介绍范围内,再也不加以详细介绍。Python 近几年很流行,能够在掌握 Shell 之后加以学习提高。code
查看系统默认 shell 编辑器和所有解释器。ip
#系统默认shell 解释器 [root@promote ~]# echo $SHELL /bin/bash [root@promote ~]# #系统shell 解释器 [root@promote ~]# cat /etc/shells /bin/sh /bin/bash /usr/bin/sh /usr/bin/bash [root@promote ~]# #CentOS 7.6 Bash和sh实际为同一个文件 [root@promote ~]# which sh /usr/bin/sh [root@promote ~]# ls -al /usr/bin/sh lrwxrwxrwx. 1 root root 4 2月 21 23:24 /usr/bin/sh -> bash [root@promote ~]# which bash /usr/bin/bash [root@promote ~]# ls -al /usr/bin/bash -rwxr-xr-x. 1 root root 964608 10月 31 01:07 /usr/bin/bash [root@promote ~]#
下一讲将详细演示如何建立 Shell 脚本文件。io