Linux apt Debian package manager
The Advanced package tool, or apt for short command in Linux is the standard go to software package manager in Debian Linux as well as just about any Linux Distribution Based off of Debian. For the most part if I want to install, uninstall, or update software in a Debian Based system I will want to do so at least in park by way of apt.
Checking if something in installed first
When I learn about a new command that I would like to look into more the first thing that I like to do is find out if the command is installed to begin with. If the command is installed to begin with I would also like to find out what the version number of that command might in fact be as well. If the command is not installed at all I might want to to check if it is available by way of the Linux Apt command, and if so install it. In the event that it is not available by way of apt I can look into other ways to get the software installed. So then in this section I will be going over a few things that have to do with a command that I always want to have installed and updated in a Linux system and that would be node.js.
List packages to see if they are installed
Some times I might want to check if some packages that follow a given patter name are installed or not to begin with. For example I have read this post that says that the GNOME virtual file system causes kernel panics. The post says that I should purge the packages gvfs-backends gvfs-fuse. At the time of this writing I have not tested this out, or looked into it further just yet, so I will not be writing about doing that just yet here. However this caused me to look into other ways to check if a package is installed or not to begin with becuase using the type bash built in is not always the best way to do so if the package is a librray, or anything other than a command.
|
|
Uisng type will not work great for checking if what needs to get purged is installed to begin with as these are not commands.
|
|
Using the type bash built in command to check if a command is installed
The Linux type command which is one of the many commands that come with Linux bash can be used to find out if a command is installed or not to begin with. So in this case I can use the type command to check what the deal is with node. Keep in mind that this is only good for checking if a command is installed to begin with, and not just any package as some packages are things like libries and plug ins thus you should use the list sub command of apt, or a command like dpkg-query.
|
|
The output that I get with type shows me that node, or some binary called node is installed. It also shows be the location of the binary, symbolic link or whatever the case might be for the node command which also proves to be useful for many other reasons. However as far as I am concerned for this matter I know that I all ready have node installed. However there is still the matter of the version that is installed and how that may compared to what I can use by way of apt.
Checking the versions node -v, and apt show
So I have found that I have node installed, but I need to know what the version number is. Also I would like to know what version I can use by way of apt to see if they match up or not. So then there is using whatever option there might be with the command to get the version number of the binary. The option for this will change from one binary to the next but in this case with node at least it is the -v option. There is then using the apt show command to find out what version of node I can get by way of apt.
So then I can just call node with the -v option to get the version of node
|
|
Looks like I am using 8.14.2, okay great now I just need to check what the version is by way of apt by using the apt-show command. In order to do this I will need to know what the name of the command is to begin with. In this case I know that it is nodejs sense there is another package called node that is something else completely.
|
|
Anyway it looks like the version of node that I am using is more up to date than that of what I can get threw apt. The reason why is because I installed the 10.24.0 version first, and then use the n npm package to update from that version of nodejs to the version that I am using now. With that said I will not be moving forward with using apt to install or update this version of node as I am using a more up to date version that I installed by another means.
This is also one of the draw backs of using apt that I have found, at least with the typical default repositories that are set up with apt to say the least. The version numbers of packages are often far out of date and I need to use something else outside of apt to install or in this case update software. When it comes to nodejs there are a lot of great options out there that help to make this easy, but some times it is not so easy.
In any case it is always a good idea to check if something is there to begin with before installing something. With this case I all ready have what I want. Also if I where to install I would end up downgrading what I have which I do not want to do of course.
Update and full-upgrade
One of the major functions of apt is to use it to make sure all the various binaries and libraries of the underlying operating system are up to date. To do this I just need to call apt update with the sudo command as this is very much something that I need root level permission to do so.
|
|
In this case all the packages are up to date. However if there where some updates to install I would want to use full-upgrade to do so. There is also the upgrade option as well. However full-upgrade will also remove software as well if that is what is needed in order to fully upgrade the system.
|
|
Install if you know the package to install
If you know the name of the package that you want to insatll in apt, doing so is often just a matter of calling apt install and then just typing in the name of the package.
|
|
However what if you do not know what the package name is? Well for that there is the apt search, apt list, or using one of the many options out there when it comes to front ends for apt such as aptitude which is a nice command line option for that. Just about every Debian Base Linux distribution comes with some kind of front end as a way to browse. You might have noticed that in this post I am using Raspberry PI OS and for that one there is pi-packages. This can be used by clicking Add / Remove software in Preferences menu, for whatever distribution you are using there is just making use of whatever front end it comes with to browse that way.
List packages that are to be upgraded
Often I might want to get a list of the packages that are to be upgraded after doing an apt update call. With that said this is one of the use cases for the apt list -u command.
|
|
|
|
|
|
Using the apt search command to kind packges
Although it might be best to use some kind of front end to search for what there is to install, there are of course CLI tools to do this sort of thing. One useful command might prove to be the apt search command. For this I can type apt search, and then give one or more keywords to look for. The search will then be preformed on names of the package itself, as well as any text in the description as well.
|
|
Conclusion
Although apt is a great tool for installing and update software it does have a few draw backs, at least when it comes to how it is set up to begin with at least. One major thing that I have found is that software is often out of date, however that might not always be such a bad thing in some cases. New versions of Debian come out every few years, and it would seem that packages get frozen at a certain point and stay fixed at those version numbers until a new major version of Debian comes out. Often the versions of the packages still wok just fine until it is time to update to a new major version of Debian, or in my case a Debian based system.
If I really need a newer version there is looking into other options for installing software, or figuring out how to built from source. In some cases I can even find pre compiled binaries from trusted sources, but that is not often the case.