How to install "last" in centos?

Searene asked:

When I tried to run last to get recently login users, I got an error:

-bash: last: command not found

So how can I install it? I’m using centos 7.0. Sorry if this is a simple question, but I cannot find any answer online regarding it.

My answer:

You can ask yum to search for the package that provides a specific file in the filesystem, and you can use globs to widen the search. For example:

yum whatprovides */last

This will tell you that the package sysvinit-tools provides /usr/bin/last.

I was a little surprised to see that you didn’t have last installed, as that’s a pretty basic program that ought to always be installed. But, you learn something new every day… In a future version of RHEL/CentOS, last will be provided in the util-linux package, and should always be installed even on the most minimal system.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.