I recently installed Ubuntu Server edition 13.10 (Saucy Salamander). But I have run into a bit of problem.
At the end of the installation, it asks about several extra packages whether you want them or not, like OpenSSH server and virtual machine host. Here's what I'm looking at:
Now, my problem is that I can't remember if I have checked the "virtual machine host" checkbox. How do I check if my server has the corresponding packages?
What packages come with the virtual machine host?
Are you looking to know about all dpkg commands with options? Have a read from the below link.
15 dpkg commands to Manage Debian based Linux Servers
To List all Installed Packages
Here
less
is a simple text reader used to scroll through the list of packages in a new buffer that opens in the existing terminal window. The list will not be mixed with other terminal commands and output. Hit q to return to the terminal prompt. Seeman less
for more info.To check whether a package is installed or not:
To check if the package is installed or not (for example,
vlc
). If installed, launch the package:Show the location where the package is installed. The
-S
(capital S) stands for "search"To use Grep to search:
apt -qq list PACKAGE
can also be used for checking whether the PACKAGE is installed.If installed it'll print something like (with
[installed]
at the end of the line):If not installed the output will be:
Use
dpkg
This command is the Debian package manager.
You can list all the installed packages with
You can see details for a specific package with
And to learn if it is installed, use
You can learn which package contains the software you want with
In your case you should use this command to search the package name you want
I've found a way to check for package installation with just
dpkg-query
command and no pipes.I searched for such solution while writing a task for ansible playbook.
You can do something like this:
This is just one another way to do the thing.
Simpler solution:
There is now an
apt list
command that lists available packages, and the--installed
command will show only installed packages. You can also search for a specific package withOr to see only the matching installed packages
There are also the
--upgradeable
and--all-versions
flags.If you do not know the exact package name, you can use
apt search
followed by part of it to see a list of related packages. This will allow you to use a partial name or regex term(s) to filter a list of available packages, but it does not have the nifty flags for filtering thatapt list
has.Also see
man apt
for more information.I am writing a new answer as Tasksel 'Task names' DO NOT show up in
dpkg
orapt
queries. Meaning the other answers are incomplete (or wrong)."I can't remember If I have checked the 'virtual machine host' checkbox.."
Check if there is an asterisk by the name after re-running
sudo tasksel
(or an ' i ' if runningtasksel --list-tasks
).If you do not see this, then you probably do not have the 'tasksel meta-package' installed.
"..How do I check if my server has the corresponding packages?"
If you want to find out what is installed under the Virtual Machine Host tasksel meta-package:
(in your case
tasksel --list-tasks | grep virt
is enough)This gives the proper task name and an indication as to whether it is installed.
In your case this tasksel name is
virt-host
."What packages come with the virtual machine host?"
From the last command, find the tasksel task name. This is needed for the next command:
This lists the individual Tasksel meta-package (denoted by appended '^') that make up the name. In your case it's
virt-host^
.Once you find proper meta-name you can use apt:
(or
apt-cache show
...
ifapt show
doesn't work.)This will show all packages making up the given meta package.
Then:
This will tell you if the individual package is installed/uninstalled (noted by 2nd letter: 'i' status means installed). Do this for all packages listed under the task/meta package.
This should answer the original questions.
Side note:
/usr/share/tasksel/descs/ubuntu-tasks.desc
also holds descriptions of Tasksel meta-packages. If you:grep "virt" /usr/share/tasksel/descs/ubuntu-tasks.desc
it will show the proper APT meta-package name. (In your case this isubuntu-virt-server
). You can also useapt
commands with this meta-name.If you are wanting to remove tasksel packages, this gets into the weeds a bit. Please consult this Ask Ubuntu answer or any number of other answers out there.
Please note that "meta" apt packages do not match Tasksel package names. Please consult the Tasksel Community Page for more info.
Use tasksel (
sudo apt-get install tasksel
if you don't already have it) and runtasksel --list-tasks
.tasksel will print out a list of the tasks, and there will be an
i
next to each task that is installed, and au
next to each task that is not installed.If you wish to install the task, use
tasksel install <task>
. The name of the task you are looking for isvirt-host
.The software selection items are called "tasks".
I created a little script with which you can automatically install from a list of packages or applications or simply check if they are already installed:
Hope it helps someone.
Check if some packages are installed and install missing ones otherwise
More info at: https://stackoverflow.com/questions/1298066/check-if-an-apt-get-package-is-installed-and-then-install-it-if-its-not-on-linu/54239534#54239534
Similar technique previously mentioned at: https://askubuntu.com/a/1102572/52975
Another (not necessarily better) way: see whether the field
APT-Manual-Installed
appears inapt show <pkgname>
. If it is absent then the package isn't installed. Unfortunately it's not shown inapt-cache show <pkgname>
.As always, the
apt
is for interactive use and not recommended for scripting.