Categories

Archives

Perched Pelican

Perched_Pelican

Perched Pelican in St Marys, GA

This pelican was perched atop a post in the St. Marys River on a slightly overcast, March day.

(c) TealComp.com 20130322
Creative Commons License
This work is shared under a Creative Commons Attribution-ShareAlike 3.0 Unported License.


Configuring automatic upgrades on Ubuntu

Part of keeping systems safe and secure involves keeping them properly patched. This can be quite a chore when you need to manage many systems. One way of easing this burden is to let each system automatically apply some or all updates and patches.

This is easy to set up on Ubuntu systems.

Note: All commands should be entered with superuser privileges.

  1. Make sure the system is up-to-date:
    apt-get update
    apt-get upgrade
  2. Ensure that the ‘unattended-upgrades’ package is installed:
    apt-get install unattended-upgrades
  3. Configure unattended-upgrades settings:
    These settings are made in /etc/apt/apt.conf.d/50unattended-upgrades. Typically, the only required changes will be to specify which packages to include in automatic upgrades. This is done in the first section and should look something like:

    // Automatically upgrade packages from these (origin:archive) pairs
    Unattended-Upgrade::Allowed-Origins {
    “${distro_id}:${distro_codename}-security”;
    // “${distro_id}:${distro_codename}-updates”;
    // “${distro_id}:${distro_codename}-proposed”;
    // “${distro_id}:${distro_codename}-backports”;
    };

    In this case, we are allowing security updates to be handled automatically, but regular updates, proposed packages, and backports will still require manual intervention.

    This file, /etc/apt/apt.conf.d/50unattended-upgrades, is well-documented. Take some time to review additional options. For instance, we see:

    // Automatically reboot *WITHOUT CONFIRMATION* if a
    // the file /var/run/reboot-required is found after the upgrade
    //Unattended-Upgrade::Automatic-Reboot “false”;

    If we un-comment this option (by deleting the “//”) and change “false” to “true”, the system will reboot without user confirmation when required by an upgrade. This could cause any users on the system to lose unsaved work, so activating this feature is NOT recommended.

  4. Specify upgrade schedules:.
    Next we modify /etc/apt/apt.conf.d/10periodic

    APT::Periodic::Update-Package-Lists “1″; // download package lists
    APT::Periodic::Download-Upgradeable-Packages “1″; // download upgradeable
    APT::Periodic::AutocleanInterval “14″; // auto clean every 14 days
    APT::Periodic::Unattended-Upgrade “1″; // enable unattended upgrades
    APT::Periodic::Verbose “2″; // enable additional logging
    APT::Periodic::RandomSleep “1″; // reduces wait-time

    Here, we have specified that, periodically, a list of new packages will be downloaded and then upgradeable packages will be downloaded, the cache of downloaded packages will be cleaned every 14 days, unattended upgrades are enabled, and extra logging (to /var/log/unattended-upgrades) will be enabled.
    The RandomSleep setting is in seconds and defaults to 1800 seconds, causing the update process to wait some random number of seconds between 0 and 1800 seconds. Changing this value to 1, essentially, removes the delay.

  5. Set up a cron job to get things going:
    The cron daemon automatically runs scripts found in /etc/cron.daily once a day. The ‘unattended-upgrades’ package should have installed a new cron script, /etc/cron.daily/apt. This script does a lot to handle the automatic upgrades, using the settings files above to modify its behavior. The only thing that should be necessary to get things moving is to ensure the correct permissions on the file:
    chmod 755 /etc/cron.daily/apt

Well, that’s it!

References:



Introduction to Maxima

Maxima Logo

Maxima is a free and open source software system for manipulation of symbolic and numeric expressions, high-precision numeric computations, and plotting in two and three dimensions. Maxima is a descendant of Macsyma, the computer algebra system developed in the 1960s at MIT that inspired commercial systems, such as Maple and Mathematica. Maxima was maintained by William Shelter from 1982 until 2001, releasing the code under the GNU General Public License (GPL) in 1998. Maxima is currently maintained by an active group of users and developers.

 

Getting Maxima

Maxima is likely already in your favorite Linux distribution’s standard repository. For example, on Debian or one of its derivatives (like Ubuntu), you can install Maxima and one of its graphical front-ends, wxMaxima, with a command like:
: sudo apt-get install maxima wxmaxima
Pre-compiled versions for a variety of operating systems and environments can be found on the Maxima ports page.
If you want the latest version of Maxima and you want to tweak and optimize it for your particular computer system, you can download the source code and compile it yourself.

 

Interacting with Maxima

Whether you start Maxima by entering ‘maxima’ on the command-line or by clicking an application launcher icon depends on your operating system and how Maxima itself was installed. The figure below illustrates the command-line (terminal) version of Maxima.

Terminal Maxima

Maxima in the Terminal

Graphical interfaces also exist for Maxima, which can provide some useful shortcuts to features and functions within Maxima. The one shown in the figure below is wxMaxima.

wxMaxima

wxMaxima

 

Maxima is most often used in interactive mode in which users input commands and review outputs. Input lines are automatically labeled with a ‘%i’ followed by a line number. Output lines receive the same treatment, but with ‘%o’. The above figure of the terminal interface shows the prompt ‘(%i1)’ for the user to input the first command. wxMaxima may present a blank window and no prompt until the user has typed something.

Issuing a command to Maxima is fairly straight-forward. For example, we perform a simple computation with:

(%i1) 6 * 7 + 13;

And, Maxima returns:

(%o1)                                 55

Note that “(%i1)” and “(%o1)” are not typed, they are automatically generated by Maxima. Our input is just the “6 * 7 + 13;” part and Maxima’s output is “55.” In the terminal version of Maxima, we just press the ENTER key after our input to have Maxima perform the computation. For wxMaxima, we need to press the key combination, SHIFT+ENTER.

When are are done with our Maxima session, we can exit by issuing the quit() command:
(%i99) quit();

 

Using Maxima as a Calculator

Let’s do a few more computations …

We can reference previous inputs or outputs in new calculations:

(%i2) %o1 / 5;

Maxima returns:

(%o2)                                 11

As a shortcut, we can reference the immediately previous output with just the percent symbol (‘%’):

(%i3) % * 6;
(%o3)                                 66

Let’s try another:

(%i4) 22 / 7;
                                      22
(%o4)                                 --
                                      7

Notice here that, when the numerator and denominator are both integers, Maxima returns a reduced fraction or integer. If we want to have this fraction evaluated as a floating-point, we can use Maxima’s float() function:

(%i5) float(%o4);
(%o5)                          3.142857142857143

And, like any decent, scientific calculator, Maxima provides a large number of built-in operators and functions. For instance,

(%i6) cos(4*%pi/3);
                                        1
(%o6)                                 - -
                                        2

That is, the cosine of four-thirds of pi is negative one-half.

 

Doing Algebra with Maxima

First and foremost, Maxima is a computer algebra system. Let’s try doing some examples …

(%i7) expand( (x + 2*y)^2 );

Maxima returns:

                                  2            2
(%o7)                          4 y  + 4 x y + x

Maxima does an admirable job of representing mathematical expressions in the terminal, but it is not quite publication ready. Fortunately, Maxima can generate output in TeX, a popular and well-supported typesetting system, through its tex() function.

(%i8) tex(%o7);
$$4\,y^2+4\,x\,y+x^2\leqno{\tt (\%o7)}$$
(%o8) "(\%o7)"

In wxMaxima, we can also click on an expression and choose to copy it as LaTeX or as an image.

4*y^2 + 4xy + x^2

Expression as an Image

 

We can create and assign values to variables in Maxima with the colon (‘:’) operator:

(%i9) radius:2; height:10;
(%o9)                                 2
(%o10)                                10

Here, we assigned the value, 2, to the variable, radius, and 10 to the variable, height. And, we did so on the same input line, remembering to terminate each command with a semicolon (‘;’).

Maxima outputs the result of each command by default. The output of a variable assignment is just the value of the variable. In some cases, we may not wish to see such output. With Maxima’s alternate command terminator, the dollar-sign (‘$’), we can suppress the output. Thus:

(%i10) radius:2$ height:10$

Now, let’s make use of our radius and height variables to compute the volume of a cylinder:

(%i11) volume: %pi * radius^2 * height;
(%o11)                             40 %pi

That is, the computed volume is stored in the variable, volume, and is 40 times the constant pi. Remember that Maxima is a symbolic calculator and, since pi can not be represented with complete precision, Maxima normally does not attempt to evaluate it. We can, however, instruct Maxima to approximate a numerical answer by appending “,numer” to our expression:

(%i12) volume,numer;
(%o12)                         125.6637061435917

We can define functions too:

(%i13) volume(radius,height) := %pi * radius^2 * height;
                                                          2
(%o13)                volume(radius, height) := %pi radius  height

And, now, we can use our defined function:

(%i14) volume(2, 10);
(%o14)                40 %pi
(%i15) volume(3, 8), numer;
(%o15)                          226.1946710584651

If we have an equation, say 2*x^2 – 16 = 0, and we need to solve for the value of x, Maxima can help:

(%i16) solve(2*x^2-32, x);
(%o16)                         [x = - 4, x = 4]

Maxima can also solve a system of equations:

(%i17) solve([2*x - 3*y = 16, 3*x + y = 2], [x, y]);
(%o17)                        [[x = 2, y = - 4]]

 

Crunching Calculus with Maxima

Maxima can perform symbolic differentiation:

(%i17) diff( x^2 * cos(x), x );
                                          2
(%o17)                      2 x cos(x) - x  sin(x)

and integration:

(%i18) integrate(%e^(2*x) - sin(x), x);
                                           2 x
                                         %e
(%o18)                          cos(x) + -----
                                           2

‘%e’ is the base of the natural logarithms and is another of Maxima’s pre-defined constants.

 

For definite integration, just specify the limits:

(%i19) integrate(cos(x), x, 0, %pi/2);
(%o19)                                 1

 

Plotting with Maxima

Maxima offers us many plotting options and functions. We can create a simple, two-dimensional plot with plot2d():

(%i20) plot2d(x^3*sin(x), [x, -2*%pi, 2*%pi]);
Plot2D

Plot2D Example

and, for 3-D plots, there is plot3d():

(%i21) plot3d(sin(x)*cos(2*y),[x,-4,4],[y,-4,4],[grid,50,50]);
Plot3D

Plot3D Example

 

Saving a Maxima Session

The constants, variables, and functions we build in a Maxima session could represent a lot of hard work. If we wish to save some or all of this and later recall it, Maxima provides the save(), load(), and loadfile() functions to help us do this.
To save everything in the current session, just provide a filename to the save() function:

(%i66) save("mysession");

To save specific variables, functions, and so on, just list them after the filename:

(%i67) save("/home/lucy/maxima/myvolumes.mac", volume);

Note that the “.mac” extension is not required.

Loading a saved session is as easy as calling the load() or loadfile() function with the desired filename. The main difference between these two is that loadfile() typically requires us to specify the path and extension to our saved file.

loadfile("/home/lucy/maxima/myvolumes.mac");

 

Citing Maxima in Academic Publications

Maxima should be cited as:

Maxima.sourceforge.net. Maxima, a Computer Algebra System.
Version 5.30.0 (2013). http://maxima.sourceforge.net/

Obviously, substitute the version number and release year as appropriate.

 

Getting Help in Maxima

Maxima does have a fairly detailed, built-in help, which can be accessed with “describe(topic)” or “? topic.” For example,

(%i22) describe(permutation);

 -- Function: permutation (<n>, <r>)
     Returns the number of permutations of <r> objects selected from a
     set of <n> objects.

     To use this function write first `load(functs)'.




  There are also some inexact matches for `permutation'.
  Try `?? permutation' to see them.

(%o22)                               true

This description could just as easily been displayed by issuing,

(%i22) ? permutation

Notice that, in addition to describing the permutation() function and its arguments, we are also told that we must first load functs into our session with load(functs);. Also, we are told that there are other, possibly related functions, which we can list:

(%i23) ?? permutation;

 0: permutation  (Package functs)
 1: permutations  (Functions and Variables for Sets)
 2: random_permutation  (Functions and Variables for Sets)
Enter space-separated numbers, `all' or `none': 

For some functions, there are also well-prepared examples. We can access these with the example(topic) function, as in:

(%i24) example(factor);

 

Learning More About Maxima

We have barely scratched the surface of Maxima’s capabilities. There are many resources on the Internet, some of which are listed here:

EFF’s Legal Guide for Bloggers

The Electronic Frontier Foundation is working hard to defend bloggers’ legal rights. If you post or share information online, you should check out EFF’s Legal Guide for Bloggers.

Planet Four

Planet Four is a cool, citizen science project in the Zooniverse, where ordinary people can help scientists identify and measure features on the surface of Mars.

Image: NASA/JPL/University of Arizona

Currently, the Planet Four project scientists are asking for help finding and marking “fans” and “blotches” on the Martian surface. It is believed that these . . . → Read More: Planet Four

Clipping videos from the command-line

So, you need to create a short clip from a longer video. Sure, you could launch your favorite GUI video editor, like OpenShot or Kdenlive, and manipulate your video. But, why not use the command-line for such a simple edit?

This is where the Libav or FFmpeg project comes in handy. Both projects provide tools . . . → Read More: Clipping videos from the command-line

Crescent Moon steals the show

The young, crescent Moon was the “star” of this twilight …

Crescent Moon at Twilight

(c) TealComp.com 20130313 This work is shared under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

. . . → Read More: Crescent Moon steals the show

OpenShot Video Editor KickStarter Campaign

OpenShot is a free, open-source, non-linear video editor currently available for Linux. OpenShot has an impressive feature list.

The creators of OpenShot want to bring their product to other operating systems, including Mac OS X and Windows, and they’re trying to fund this effort through a KickStarter campaign. As we’ve discussed here and here, KickStarter . . . → Read More: OpenShot Video Editor KickStarter Campaign

Watermarking a video from the command-line

This article is not intended as a full treatment of this topic. There are far too many options and considerations to do it justice in one article.

First, we need some definitions …

Watermarks:

Originally, a watermark was a faint impression on paper. This idea is carried over to digital videos as a . . . → Read More: Watermarking a video from the command-line

Green-Winged Macaw

Green-Winged Macaw

This green-winged macaw (a.k.a. red-and-green macaw) was seen at the Alligator Farm Zoological Park in St. Augustine, FL.

The green-winged macaw (scientific name, Ara chloropterus) is a neotropical parrot found in the woodlands and forests of northern and central South America. While its colorful plumage is mostly red, like the scarlet macaw . . . → Read More: Green-Winged Macaw