环境centos release 6.7
1.查看当前bash版本
[root@localhost ~]# bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 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.
2.查看gcc是否安装(gcc:后面有路径说明已安装)
[root@localhost ~]# whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz
3.查看bash安装路径
[root@localhost ~]# whereis bash
bash: /bin/bash /usr/share/man/man1/bash.1.gz #find / -name bash也是查找和bash相关的文件,建议此处查到的bash文件备份,最大程度保证安全
4.备份bash
[root@localhost ~]# cp -a /bin/bash /bin/bash.bak
5.解压bash-4.4.tar.gz
[root@localhost tmp]# tar -zxvf bash-4.4.tar.gz
........
bash-4.4/CWRU/misc/sigstat.c
bash-4.4/CWRU/misc/bison
bash-4.4/CWRU/misc/errlist.c
bash-4.4/CWRU/misc/hpux10-dlfcn.h
6.进入bash-4.4编译
./configure命令就是执行当前目录的名为configure的脚本,主要的作用是对即将安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系,--bindir=/bin把生成的可执行文件默认放到/bin目录下(只./configure 的话安装成功后bash不生效,需其他配置后才生效),其他文件默认系统安装路径。
[root@localhost tmp]# cd bash-4.4
[root@localhost bash-4.4]# ./configure --bindir=/bin #安装后会覆盖之前的/bin/bash
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
7.make编译
[root@localhost bash-4.4]# make
.........
gcc -c -DHAVE_CONFIG_H -DSHELL -I/tmp/bash-4.4 -I.. -g -O2 -Wno-parentheses -Wno-format-security man2html.c
gcc -DHAVE_CONFIG_H -DSHELL -I/tmp/bash-4.4 -I.. -g -O2 -Wno-parentheses -Wno-format-security man2html.o -o man2html -ldl
make[1]: Leaving directory `/tmp/bash-4.4/support'
8.make test测试是否编译成功,没有error信息证明成功
[root@localhost bash-4.4]# make test
...................
< test-tests: the test suite should not be run as root
run-tilde
run-tilde2
run-trap
warning: UNIX versions number signals and schedule processes differently.
warning: If output differing only in line numbers is produced, please
warning: do not consider this a test failure.
71,72d70
< +[8] false
< +[8] cat
73a72,73
> +[8] cat
> +[8] false
run-type
run-varenv
run-vredir
9.安装 make install
[root@localhost bash-4.4]# make install
............
unlink
realpath
strftime
mypid
setpgid
make[1]: Leaving directory `/tmp/bash-4.4/examples/loadables'
10.bash --version 查看版本是否安装成功
[root@localhost bash-4.4]# bash --version
GNU bash, version 4.4.0(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2016 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.