如何在CentOS 7上安装Bash 5.0

时间:2020-02-23 14:30:37  来源:igfitidea点击:

Bash是sh兼容的命令语言解释器,它执行从标准输入或者文件读取的命令。 Bash还结合了Korn和C shell(ksh和csh)的有用功能。本教程将向Linux用户展示如何在CentOS 7上安装Bash 5.0。

CentOS 7 Linux机器上可用的Bash版本是4.2. 可以通过在终端中运行命令bash version来确认。

$bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

在CentOS 7上安装Bash 5.0

在本文更新时,最新的Bash稳定版本是5.0。此发行版在默认的上游存储库中不可用。很好,需要从源代码构建它。

更新系统

更新CentOS 7计算机。

sudo yum -y update

如果我们有内核更新,请重新引导操作系统。

sudo reboot

在CentOS 7上安装开发工具

在CentOS 7上安装开发人员工具。

sudo yum -y install curl
sudo yum -y groupinstall "Development Tools"

下载Bash 5.0 tar文件。

curl -O https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz

在CentOS 7上安装Bash 5.0

解压缩下载的存档。

tar xvf bash-5.0.tar.gz

配置

cd bash-5.0
./configure

确认命令执行输出中没有错误:

.....
config.status: creating Makefile
config.status: creating builtins/Makefile
config.status: creating lib/readline/Makefile
config.status: creating lib/glob/Makefile
config.status: creating lib/intl/Makefile
config.status: creating lib/malloc/Makefile
config.status: creating lib/sh/Makefile
config.status: creating lib/termcap/Makefile
config.status: creating lib/tilde/Makefile
config.status: creating doc/Makefile
config.status: creating support/Makefile
config.status: creating po/Makefile.in
config.status: creating examples/loadables/Makefile
config.status: creating examples/loadables/Makefile.inc
config.status: creating examples/loadables/perl/Makefile
config.status: creating support/bash.pc
config.status: creating support/bashbug.sh
config.status: creating config.h
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing default commands
[theitroad@localhost bash-5.0]#

在CentOS 7上安装Bash 5.0:

make
sudo make install

在CentOS 7上确认Bash的当前版本:

$bash --version
GNU bash, version 5.0.0(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

现在,我们可以构建任何需要Bash版本高于4.2的应用程序。