How to identify the package that provides the file /usr/bin/chsh

Hi Everyone, i am just started linux basic test and stuck at Question 5.

Identify the package that provides the file /usr/bin/chsh and save the answer in a file called /opt/required_software .
Use sudo if you need to run any command with root level permissions.

Can you please guide what are the commands for this?

Do you have a link to the lab? Labs normally have a hint and/or a solution button that you can use to get the information you need.

It is not clear what version of Linux you are asking about.

For Ubuntu run:
dpkg -S /usr/bin/chsh

For Redhat run:
rpm -qf /usr/bin/chsh

Its Ubuntu.
After i type the command, it shows the package is not installed. Any idea?

This is what is looks like on my Ubuntu system:

$ dpkg -S /usr/bin/chsh
passwd: /usr/bin/chsh

If the file does not exist you will get this error:

$ dpkg -S /usr/bin/invalid
dpkg-query: no path found matching pattern /usr/bin/invalid

Can you copy and paste what you have done and include it in a code block </> so we can see what is happening?

uname -a suggests Ubuntu but if you cat /etc/os-release you will see that it’s actually Centos 8.
You will therefore use: yum whatprovides /usr/bin/chsh

@zin.sumyatnoez To clarify what @marko.vukovic is saying, uname -a is not the best way to identify the system you are running on.

If the system providing the command prompt is running as a container, uname will report the kernel version of the host machine.

cat /etc/os-release is the way to identify whether the commands you should be using are centos, ubuntu or any other distro.

So in this case, the lab is a centos container running on an ubuntu host.

1 Like

I had the same question about finding which package provides /usr/bin/chsh on CentOS 9. After some research, I found the answer. As of now, the OS in our lab is CentOS 9. You can use:

yum provides /usr/bin/chsh
dnf provides /usr/bin/chsh

Just sharing this to help anyone who might face the same problem. Hope it helps!

1 Like

yum whatprovides will work as well:

[root@student-node bob]# yum whatprovides /usr/bin/chsh
Last metadata expiration check: 1:16:55 ago on Tue Dec 17 23:28:31 2024.
util-linux-user-2.37.4-10.el9.x86_64 : libuser based util-linux utilities
Repo        : baseos
Matched from:
Filename    : /usr/bin/chsh

Thanks for your input! It’s interesting to see another way to solve this problem. Your guidance is appreciated.