How can I search for a package which provides an uninstalled command? [duplicate]

Solution 1:

Install apt-file

sudo apt install apt-file

Perform an initial update of its database

sudo apt-file update

Then (for example)

$ apt-file search 'bin/xclock'
x11-apps: /usr/bin/xclock

See also How do I find the package that provides a file?

Solution 2:

Normally on default installs of Ubuntu, when you type an uninstalled command in the terminal you should get a list of packages that provide it, or else a list of similarly-named commands if that specific command wasn't found; it seems that xlock is simply no longer provided in the main Ubuntu repositories. It was available for 12.04 (http://manpages.ubuntu.com/manpages/precise/en/man1/xlock.1.html), but no longer.

For xlock:

$ xlock
No command 'xlock' found, did you mean:
 Command 'mlock' from package 'mlock' (universe)
 Command 'xclock' from package 'x11-apps' (main)
 Command 'vlock' from package 'vlock' (universe)
 Command 'lxlock' from package 'lxlock' (universe)
 Command 'wlock' from package 'sendfile' (universe)
 Command 'slock' from package 'suckless-tools' (universe)
 Command 'rlock' from package 'ruby-lockfile' (universe)
 Command 'flock' from package 'util-linux' (main)
 Command 'clock' from package 'xview-clients' (universe)

Example for one not installed but available:

$ rlock
The program 'rlock' is currently not installed. You can install it by typing:
sudo apt install ruby-lockfile