Hello! As a noob and non-techy i have been using for a long time apt install command for finding out whether a package is installed.
apt install nano, oh, it is already installed, cool, ok.
Now i try to educate myself and read the Debian Administrator's Handbook. So i am looking for a more appropriate alternative.
For example in Handbook is mentioned apt-cache policy packagename command
Lets test three options. Package is installed (nano is installed on my system). Not installed (vim is not installed). Package is probably installed, but i have forgot the full name. Gnome-text-editor is installed. But i won't enter the full name.
apt-cache policy packagename. It shows both installed and non-installed packages. For example i see that nano is installed, and vim is not. But if i enter gnome-text-ed (editor) it gives me "N: Unable to locate package gnome-text-ed"apt search packagename understands that i want gnome-text-ed(itor). But for nano and vim its output is huge and irrelevant.
apt list -a packagename has the same problem as apt-cache policy. It shows (not)installed files, but fails to understand incomplete package names.
Some even advise which packagename, but it just shows no output for non-installed packages, which can be confused with a mistake.
apt list | grep packagename works fine in general. But again it gives huge list for nano and vim. Though it understands "text-edito"
Also there is
dpkg -l | grep -i packagename
It understands incomplete package name. But i can't understand its output for vim. "ii means "It should be installed and it is installed"" (src). Does it mean that vim is partially installed? "Common" files and "compact" version? apt install wants me to install only vim-runtime.
Lets try Konsole (not installed) instead of vim
No output. So it says nothing if the package is not installed. Not good.
But last two options are not a single commands unfortunately, but a combination of commands. Possible to remember, though, after a number of uses, i think.
What commands do you use for this purpose? Some articles even advise bash scripts for that.
apt install nano, oh, it is already installed, cool, ok.
Now i try to educate myself and read the Debian Administrator's Handbook. So i am looking for a more appropriate alternative.
For example in Handbook is mentioned apt-cache policy packagename command
Lets test three options. Package is installed (nano is installed on my system). Not installed (vim is not installed). Package is probably installed, but i have forgot the full name. Gnome-text-editor is installed. But i won't enter the full name.
apt-cache policy packagename. It shows both installed and non-installed packages. For example i see that nano is installed, and vim is not. But if i enter gnome-text-ed (editor) it gives me "N: Unable to locate package gnome-text-ed"
Code:
$ apt-cache policy nanonano: Installed: 7.2-1 Candidate: 7.2-1 Version table: *** 7.2-1 500 500 https://deb.debian.org/debian bookworm/main amd64 Packages 100 /var/lib/dpkg/status
Code:
$ apt-cache policy vimvim: Installed: (none) Candidate: 2:9.0.1378-2 Version table: 2:9.0.1378-2 500 500 https://deb.debian.org/debian bookworm/main amd64 Packages
Code:
$ apt-cache gnome-text-edE: Invalid operation gnome-text-ed
Code:
$ apt search nanoSorting... DoneFull Text Search... Donealpine-pico/stable 2.26+dfsg-1 amd64 Simple text editor from Alpine, a text-based email clientarduino-core-avr/stable,stable 1.8.6+dfsg-1 all Arduino Core for AVR microcontrollerbornagain/stable 1.19.0-3+b5 amd64 Simulate and fit X-ray and neutron GISAS -- binary........
Code:
$ apt search gnome-text-edSorting... DoneFull Text Search... Donegnome-text-editor/stable,now 43.2-1 amd64 [installed] simple text editor for GNOME
Code:
$ apt list -a nanoListing... Donenano/stable,now 7.2-1 amd64 [installed]nano/stable 7.2-1 i386
Code:
$ apt list -a vimListing... Donevim/stable 2:9.0.1378-2 amd64vim/stable 2:9.0.1378-2 i386
Code:
$ apt list -a gnome-text-edListing... Done
apt list | grep packagename works fine in general. But again it gives huge list for nano and vim. Though it understands "text-edito"
Code:
$ apt list | grep nanolibghc-nanospec-dev/stable 0.2.2-4+b1 amd64libghc-nanospec-dev/stable 0.2.2-4+b1 i386libghc-nanospec-doc/stable,stable 0.2.2-4 all...
Code:
$ apt list | grep gnome-text-edgnome-text-editor/stable,now 43.2-1 amd64 [installed]gnome-text-editor/stable 43.2-1 i386
dpkg -l | grep -i packagename
It understands incomplete package name. But i can't understand its output for vim. "ii means "It should be installed and it is installed"" (src). Does it mean that vim is partially installed? "Common" files and "compact" version? apt install wants me to install only vim-runtime.
Code:
$ dpkg -l | grep nanoii nano 7.2-1 amd64 small, friendly text editor inspired by Pico
Code:
$ dpkg -l | grep vimii vim-common 2:9.0.1378-2 all Vi IMproved - Common filesii vim-tiny 2:9.0.1378-2 amd64 Vi IMproved - enhanced vi editor - compact version
Code:
$ dpkg -l | grep gnome-text-edii gnome-text-editor 43.2-1 amd64 simple text editor for GNOME
Code:
$ dpkg -l | grep konsole$
But last two options are not a single commands unfortunately, but a combination of commands. Possible to remember, though, after a number of uses, i think.
What commands do you use for this purpose? Some articles even advise bash scripts for that.
Statistics: Posted by alienspy — 2024-05-29 19:43 — Replies 5 — Views 110