linux - Get "timeout" command from GNU coreutils 8 on RHEL 5.7 machine
2014-07
What is the best way to install the Gnu timeout
command on an RHEL 5.7 machine?
I would prefer to install with yum
, but I can compile from source if that is the only way.
timeout
was introduced in Coreutils 8+, but RHEL 5.7 only has Coreutils 5.97, so far as I can tell.
Do I have to install from source? Will that interfere with yum?
coreutils doesn't depend on gcc in Red Hat land. That's just daft :) Probably the handiest is to use the script that I based the timeout command on:
(This question is very similar to 6338. It was suggested that it be split from it as Fedora and Ubuntu/Debian are different enough to warrant different answers.)
As I use any Fedora setup I gradually install a number of packages over and above the baseline installation. If I reinstall, or if I need to install a new machine, I usually want to reinstall those specific packages, and I want to do it fast to get back to work with a minimum of hassle. As far as I've seen all of the package managers (yum
and pirut
) can tell me which packages are installed, and they all have logs (albeit different ones for each tool, which is a hassle). But none of them can tell me which packages I've installed, as opposed to their dependencies or system updates. Even the logs are tricky in that I'm not entirely sure what I should be extracting from them, or how to integrate them (in the case of the various apt family tools). This means that each time I re-install, or even just backup, I'm not sure how to re-create that list.
I'm not necessarily expecting any of the tools to do this for me, but if they don't I'm looking for workarounds. Even patterns to grep for, good rules of thumb, or a clear idea of what exactly is being logged, would be useful. There may not be a "best answer" here but good ones would be very helpful.
yum list installed
and yum.log
will show what's been installed, but I don't think anything on the system differentiates between packages you chose to install and those that were installed as dependencies
Presuming you still have the /root/install.log
file from the original installation, you could create the files rpm.orig and rpm.curr thus:
cd /root
rpm -qa --qf '%{NAME}\n' | sort -u > rpm.curr
awk '($1=="Installing"){print $2}' install.log | sort -u > rpm.orig
Then, to see packages added:
comm -13 rpm.orig rpm.curr
And ones removed:
comm -23 rpm.orig rpm.curr
Note that if you have an x86_64 installation, it won't tell the difference between the 32- and 64-bit packages.
This is an easy one.
Just run the below command in your favorite shell. The manpage for RPM will be painfully illustrative if you need to take a deeper dive on this.
rpm -qa
The file /root/install.log will tell you which packages were included in the initial install. Here's a quick script that will compare the contents of this file with the output of rpm -qa
:
rpm -qa | sort > /root/postinstall.list
for P in `sed -n 's/Installing \(.*\)/\1/p' </root/install.log`
do
sed -ie "/$P/d" /root/postinstall.list
done
The file /root/postinstall.list contains what you want. Note that packages that are an upgraded version of an originally installed package will appear in the file. If this is not what you want, you will need a more sophisticated pattern in the sed statement.
rpm -qa --last
from the man pages:
--last Orders the package listing by install time such that the latest packages are at the top.
Sample output:
mdadm-3.2.2-9.el6 Mon 12 Dec 2011 10:06:17 AM EST
libdrm-2.4.25-2.el6 Mon 12 Dec 2011 09:54:51 AM EST
tcp_wrappers-libs-7.6-57.el6 Mon 12 Dec 2011 09:54:50 AM EST
Assuming you always used "yum" to install everything you can do:
sudo yum history info \* | grep "^Command Line : install"
It should show you all "yum install" commands performed on the system after installation.