Update SQL Server Applications on Ubuntu Linux with Apt
You are a SQL Server DBA that is used to working on Windows environments and you started working with SQL Server on Linux. Suddenly you realize the arrival of SQL Server on Linux brings more challenges for you. For example, you know how to upgrade applications on Windows systems, but what about doing the same task on Linux? In this tip I will show you how easy it is.
The arrival of SQL Server 2017 with support for Linux has revolutionized the market and made some noise in the SQL Server DBA communities. For developers the impact is almost zero, but we as DBA’s are forced to learn Linux administration. Of course, if your company has a Linux system administrator you will need less knowledge about Linux administration than those SQL Server administrators who work without sysadmins in their workplace.
Why You Have to Update Applications?
Every application has a lifecycle and when an application is released by the manufacturer it doesn’t mean that the development process has finished. In fact, an application release to the general public is just a stable version of an application under constant development.
Just to give you an example of the previous statement please consider the following T-SQL script:
SELECT @@VERSION SELECT * FROM sys.dm_os_wait_stats WHERE wait_type LIKE 'QDS%' AND wait_time_ms > 0
The script returns the SQL Server version as well as the wait stats for wait types related to the Query Store feature which was introduced in SQL Server 2016. Take a look at the next screen capture and you will see that the execution of this script in a SQL Server 2014 instance returns wait stats of a feature that doesn’t exist in SQL Server 2014.
But the addition of new features is not the only reason to update your applications. The major reason is to fix bugs which were discovered before the release of the application and how it affects functionality and performance. Furthermore, the other reason is the correction of security issues.
How to Update Applications on Ubuntu Linux?
You know that on Windows operating systems Windows Update takes care of this for you. And of course, we have by default a graphical interface that in one single window allows us to configure the mechanism of installing updates as shown below.
Of course, if your Linux server was installed with a graphical interface you would have a visual tool to aid you like on the following screen capture. But it’s very hard to find a Linux server with a GUI and even if you have one, you will realize that it is easier to use the console.
Apt is a command line package (remember that on Linux programs are delivered as packages) handling utility. This is not the only package handling utility on Linux. Each Linux distribution uses its own package handling utility. Just to give a few examples: Red Hat uses rpm, Suse uses yum and Debian uses dpkg. It is considered the user's "back-end" to other tools using the APT library, such as apt-get.
In the following table I list the apt command parameters.
|list||List packages based on package names. It has options to list installed (--installed), upgradeable (--upgradeable) or all available (--all-versions) versions.|
|update||Synchronizes the package index with its source repositories which you can edit on the following text file /etc/apt/sources.list.|
|upgrade||This parameter is used to install the most recent version of all the packages on the system.|
|search||Search in package descriptions|
|install||Installs the specified packages.|
|Remove||This parameter is used to uninstall a package.|
|autoremove||Removes all unused packages from the system.|
|full-upgrade||It does the same thing that the upgrade parameter does but also installs the updated version of the distribution core packages.|
|edit-sources||Edit the source information file|
|show||Returns information about a package like its dependencies, installation and download size and more.|
|remove||Uninstalls the specified packages.|
|source||This will find out the specified package's source code. If the --compile options is specified then the package will be compiled to a binary using rpmbuild, if --download-only is specified then the source package will not be unpacked.|
|check||Updates the package cache and checks for broken dependencies.|
|clean||Clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.|
Now we have the theory behind the apt command, but how do we put it all together so we can install an update or patch to a given application? The first step we must do is to update our package index list with the last version of those packages. To do so we use the following command.
This command will resynchronize the last version of each package with the version installed on the system.
After getting the last versions of each package it’s time to apply updates, but first we must decide if we want to apply the last available update for all applications or just for a few specific ones. If our intentions are to update all the packages on the system then we should execute the following command:
Otherwise, if we aim to update a specified package we must first check if that package has a new version to upgrade. If we want to check for available updates we can execute the following command.
apt list --upgradable
The next image is a screen capture showing the output of the previous command execution.
Also, if our intentions are to check updates for SQL Server related packages we can use the grep command to limit the previous list as follows.
apt list --upgradable | grep mssql
As a side note, if you are curious about apt you can browse the /etc/apt directory which is the place you will find the configuration settings of apt.
- If you need to upgrade SQL Server on Linux this tip will help: Upgrading SQL Server running on Ubuntu to latest update.
- New on Linux? On the following tip you will find the most used commands for SQL Server DBA’s: Top 10 Linux Commands for SQL Server DBAs.
- Also, if you want to learn other Linux administration basics you can read my previous tips on which I cover how to check for CPU Usage, Disk I/O and Disk Space.
- For more information regarding SQL Server and Linux check the SQL Server on Linux Tips Category.
About the author
View all my tips
Article Last Updated: 2018-05-16