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