Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am writing a script that is supposed to run every day to check if there are any new security updates for Ubuntu.

If there are, it will make a list of those updates, it will download them, and then run some tests.

The purpose of this script is to make sure that no security updates break our code running on the Ubuntu.

I am not an experienced user with Ubuntu, so forgive me if this question seems trivial. I have researched quite a bit, and found information like this Which is useful I presume to those who are home-users or such. But I can not install extra packages, nor does this provide any solutions for doing it without installing packages, (I tried every answer that did not include downloading new packages)

So to refine my question, I would like a command that will fetch all the security updates (so I can see them as a list, and include it in the daily report of which security packages have updates) and then also download and install them. The testing and such I do myself (obviously) I just need help understanding which commands to run.

Since scripts will be running these commands, they do not need to be human-readable in any specific way, so they can be long and extraneous, or such, and preferably 1-liners that do not require pre-configuration.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

After some of my own research, and some fiddling around, this is the solution I have found for myself:

grep security /etc/apt/sources.list > /tmp/su.list
apt-get -o Dir::Etc::Sourcelist=/tmp/su.list -q update
apt-get -o Dir::Etc::Sourcelist=/tmp/su.list -q upgrade -s 2>&1 | tee /tmp/security_updates_fetch.log
apt-get -o Dir::Etc::Sourcelist=/tmp/su.list -q upgrade -ym --force-yes 2>&1 | tee /tmp/security_updates_install.log

This will output to the stdout as well as create a few files in /tmp/:

  • /tmp/su.list : Which is a throw-away file after the operation completes.
  • security_updates_fetch.log : Contains the updates which will be performed.
  • security_updates_install.log : Contains the log of the actual update.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.