Yesterday I needed to upgrade a single application on CentOS Linux. First I figured out that the application was part of the coreutils RPM package which is currently only available up to version coreutils 5.97-23 on CentOS. The current coreutils package is already up to coreutils 8.5 and upgrading coreutils is near impossible on CentOS because of other package requirements that it needs. Below are instructions on how to download the coreutils source, build the coreutils applications in a new directory, and then upgrade one application.
Download, Compile, & Upgrade One Application From coreutils Package On CentOS Linux:
- Download coreutils Source: I would recommend finding out which version of the application you are trying to update includes the functions you need. After this find out when that version of the application is included in the coreutils package and download that specific version so changes to the application you will be upgrading are kept to a minimum. For instance in this example I needed the “-R” switch from sort which was included in sort starting with coreutils 6.4 so in this example I am downloading coreutils 6.9 instead of the latest coreutils which is currently 8.5. Visit the GNU web site to figure out what version you want to download and then use syntax similar to the below to download the coreutils source.
- [root@dev ~]# cd /usr/local/src/
- [root@dev src]# wget http://ftp.gnu.org/gnu/coreutils/coreutils-6.9.tar.gz
- --2010-08-15 14:21:55-- http://ftp.gnu.org/gnu/coreutils/coreutils-6.9.tar.gz
- Resolving ftp.gnu.org... 140.186.70.20
- Connecting to ftp.gnu.org|140.186.70.20|:80... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 8194001 (7.8M) [application/x-gzip]
- Saving to: `coreutils-6.9.tar.gz'
- 100%[==========================================================================================>] 8,194,001 644K/s in 14s
- 2010-08-15 14:22:09 (591 KB/s) - `coreutils-6.9.tar.gz' saved [8194001/8194001]
- [root@dev src]#
- Unpack coreutils Source: Now use tar to unpack the coreutils source as shown in the below example syntax.
- [root@dev src]# tar -zxf coreutils-6.9.tar.gz
- [root@dev src]#
- Change Directory: Now change directory into the newly created coreutils directory which in this example is “/usr/local/src/coreutils-6.9” as shown below.
- [root@dev src]# cd coreutils-6.9
- [root@dev coreutils-6.9]#
- Make Output Directory & Configure: Now make a directory for the output which can be called anything but in this example we call it output. Then run the configure command that specifies that new directory for all of the items that will be built.
- [root@dev coreutils-6.9]# mkdir output
- [root@dev coreutils-6.9]# ./configure --prefix /usr/local/src/coreutils-6.9/output
There will be a bunch of output from the configure command which I didn’t include here because its to long.
- Make Coreutils: Once the configure complete issue the “make” command to build coreutils as shown below from the /usr/local/src/coreutils-6.9 directory.
- [root@dev coreutils-6.9]# make
Again there will be a bunch of output when issuing the make command but I didn’t include it because it would create a mess in this article.
- Install Coreutils: This is typically where you would be installing the new coreutils directly to “/usr/local/” which is the default for the configure command however since we have added the output directory using the prefix variable all of the installs will be done in /usr/local/src/coreutils-6.9/output using the “make install” command below.
- [root@dev coreutils-6.9]# make install
As you watch the installation happen you will see output that includes the prefix path that has been set.
- Verify Applications: Two directories including bin and share will be created within the output directory. The bin directory is where all of the applications from coreutils will be installed. First cd into “output/bin” and then test to make sure that the applications installed in the bin directory are working properly such as the example below with uniq.
- [root@dev bin]# uniq --version
- uniq (GNU coreutils) 5.97
- Copyright (C) 2006 Free Software Foundation, Inc.
- This is free software. You may redistribute copies of it under the terms of
- the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
- There is NO WARRANTY, to the extent permitted by law.
- Written by Richard Stallman and David MacKenzie.
- [root@dev bin]# ./uniq --version
- uniq (GNU coreutils) 6.9
- Copyright (C) 2007 Free Software Foundation, Inc.
- This is free software. You may redistribute copies of it under the terms of
- the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
- There is NO WARRANTY, to the extent permitted by law.
- Written by Richard Stallman and David MacKenzie.
- [root@dev bin]#
The first command issued shows the uniq version that is actually installed on the server in the path of the user and the second example shows running uniq from the /usr/local/src/coreutils-6.9/output/bin directory where all of the new applications have been installed.
- Backup & Install Applications: Before copying over any of the existing applications you should backup the original first in case you run into any problems it can be restored. In the example below we will be upgrading the sort command which is located by default on CentOS Linux in the /bin directory. So the process in the example below shows the sort version, copying the current sort to .orig, moving over the newly built sort, and then showing the new sort version.
- [root@dev bin]# cd /bin
- [root@dev bin]# sort --version
- sort (GNU coreutils) 5.97
- Copyright (C) 2006 Free Software Foundation, Inc.
- This is free software. You may redistribute copies of it under the terms of
- the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
- There is NO WARRANTY, to the extent permitted by law.
- Written by Mike Haertel and Paul Eggert.
- [root@dev bin]# cp -p sort sort.orig
- [root@dev bin]# cp -p /usr/local/src/coreutils-6.9/output/bin/sort .
- cp: overwrite `./sort'? y
- [root@dev bin]# sort --version
- sort (GNU coreutils) 6.9
- Copyright (C) 2007 Free Software Foundation, Inc.
- This is free software. You may redistribute copies of it under the terms of
- the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
- There is NO WARRANTY, to the extent permitted by law.
- Written by Mike Haertel and Paul Eggert.
- [root@dev bin]#
We now have the new version of sort installed on the server without actually upgrading the entire coreutils package.
Please make sure to investigate the backwards compatibility of whatever coreutils application you are upgrading as it is possible that switches or other functionality has changed. If an application is upgraded that other applications depend on it is possible to break things without realizing it.
Other Coreutils Applications: [, chroot dd, env, groups, kill, mkfifo, paste, pwd, sha256sum, split, tail, tty, vdir, base64, cksum, df, expand head, , link, mknod, pathchk, readlink, sha384sum, stat, tee, uname, wc, basename, comm, dir, expr, hostid, ln, mv, pinky, rm, sha512sum, stty, test, unexpand, who, cat, cp, dircolors, factor, hostname, logname, nice, pr, rmdir, shred, su, touch uniq, , whoami, chgrp, csplit, dirname, false, id, ls, nl, printenv, seq, shuf, sum, tr, unlink, yes, chmod, cut, du, fmt, install, md5sum, nohup, printf, sha1sum, sleep, sync, true, uptime, chown, date, echo, fold, join, mkdir, od, ptx, sha224sum, sort, tac, tsort, users
Thanks, that was helpful. I now can use “shuf”!
Hello Madelaine,
No problem. Thanks for taking the time to leave feedback.
Thanks.
alex
It was of big help …
Thanks
Hello Jose,
No problem. Thanks for posting feedback.
Thanks.
alex