Home Blog Page 275

Microsoft Releases Windows 10 Preview with Support for Linux Files

Microsoft yesterday released a new Windows 10 preview with support for Linux files, gaming improvements, and a Chrome extension for Timeline. The update bumps Windows 10 from build 18334 (made available to testers on February 9) to build 18342. These builds are from the 19H1 branch, which represents the Windows 10 update that will arrive in the first half of this year.

Windows 10 is being developed as a service, meaning it receives new features on a regular basis. … The seventh update will bring the ability for users to access Linux files in a WSL distro from Windows. These files can be accessed through the command line by navigating to \wsl$ (see a list of running distributions by navigating to \wsl$). Windows apps like File Explorer and Visual Studio Code can also interact with these files.

Read more at VentureBeat

A Linux Noob Reviews: The openSUSE Leap 15.0 Installer

Forbes covers your very first experience with a desktop Linux operating system: the installer. Read more at Forbes.

The Calico Cloud

You know what’s one of the real pains of cloud and container based computing? Networking. Workloads on a cloud come and go faster than you can read this story. Connecting those workloads, especially when they become even more ephemeral containers, is not easy. That’s where the open-source Software Defined Network (SDN) Calico comes in.

SDN enables you to centrally manage and monitor your network across not just routers and switches from a single vendor, but across any hardware that implements standardized SDN protocols. This enables network administrators to create efficient virtual networks independent of the infrastructure.

Calico takes these concepts to the cloud and simplifies them so they can work without a netadmin snapping a whip over the network. Calico does this with a simplified Layer 3 networking model designed for cloud-native applications. It also uses good old Internet Protocol, which makes it simpler than SDN overlay approaches. With it, you can set network policies for your virtual machines (VM)s and containers.

Read more at DXC Technology

Do Linux Distributions Still Matter with Containers?

There are two major trends in container builds: using a base image and building from scratch. Each has engineering tradeoffs.

Some people say Linux distributions no longer matter with containers. Alternative approaches, like distroless and scratch containers, seem to be all the rage. It appears we are considering and making technology decisions based more on fashion sense and immediate emotional gratification than thinking through the secondary effects of our choices. We should be asking questions like: How will these choices affect maintenance six months down the road? What are the engineering tradeoffs? How does this paradigm shift affect our build systems at scale?

It’s frustrating to watch. If we forget that engineering is a zero-sum game with measurable tradeoffs—advantages and disadvantages, with costs and benefits of different approaches— we do ourselves a disservice, we do our employers a disservice, and we do our colleagues who will eventually maintain our code a disservice. Finally, we do all of the maintainers (hail the maintainers!) a disservice by not appreciating the work they do.

Understanding the problem

To understand the problem, we have to investigate why we started using Linux distributions in the first place. I would group the reasons into two major buckets: kernels and other packages. 

Read more at OpenSource.com

GhostBSD: A Solid Linux-Like Open Source Alternative

The subject of this week’s Linux Picks and Pans is a representative of a less well-known computing platform that coexists with Linux as an open source operating system. If you thought that the Linux kernel was the only open source engine for a free OS, think again. BSD (Berkeley Software Distribution) shares many of the same features that make Linux OSes viable alternatives to proprietary computing platforms.

GhostBSD is a user-friendly Linux-like desktop operating system based onTrueOS. TrueOS is, in turn, based on FreeBSD’s development branch. TrueOS’ goal is to combine the stability and security of FreeBSD with a preinstalled GNOME, MATE, Xfce, LXDE or Openbox graphical user interface.

Read more at Linux Insider

Today is a Good Day to Learn Python

Get started learning Python with this tutorial from our archives.

The cool thing about Linux and FOSS is also an aggravating thing, which is that sometimes there’s too much of a good thing. There is such an abundance of goodies that it can be overwhelming. So I am here to help you decide which programming language you should learn next, and that is Python. Oh, yes, it is.

Why Python? I like it because it is clean and straightforward. It’s a great introduction to object-oriented languages. The Python world is beginner-friendly and, as a general-purpose language, Python can be used for all sorts of things: quick simple scripts, games, Web development, Raspberry Pi — anything you want. It is also in demand by employers if you’re thinking of a career.

There are numerous excellent Python books and tons of online documentation. I want to show off Python’s coolness for beginners so you will get excited and go “Yes! I too must love Python!”

But what about all the other languages? Don’t worry, they won’t get lonesome, and everything you learn in Python is applicable to many other languages as well.

What Stuff Means

I think most of us learn terminology better with hands-on exercises, but there are four things to know from the start.

The first is Python is strongly typed. As you study Python, you will see this repeated a gazillion times. What does this even mean? Who uses a typewriter? Fortunately, it has nothing to do with typewriters, but rather with how Python handles data types. All computer programs are made of two things: data, and operating on that data. Data comes in different types, and the types determine how your programming language will handle them. Data types include characters or strings, which are literal numbers and letters, like names and addresses; integers and floating point numbers that are used in calculations; Boolean values (true/false); and arrays, which are lists of data of all the same data types.

Python enforces data types and relies on you to define them. Weakly typed languages decide for themselves what your data types are, so the data type can change depending on context.

For example, most any programming language will add the integers 1 + 2 + 3. A weakly typed language may also let you add integers and text strings, for example 5 + helloworld. If you try to do this in Python, your code will fail and you will get an error message. Weakly typed languages don’t do this randomly; this is a feature intended to add speed and flexibility by not requiring you to define your data types.

However, weak typing can lead to strange errors. One of the most common errors involves converting strings of numbers to integers when you really want them to be a literal string, like 221B Baker Street, 10,000 Maniacs, or 23andMe. In my modest opinion, it is better to learn the discipline and structure of a strongly typed language, and then try out weakly typed languages after you have experience and good grounding in the basics.

The second thing to know is what the heck is object oriented programming (OOP)? An object is a clump of data and procedures grouped into a single reusable entity. If you were coding a car racing game you might have a car object, an obstacle object, and a driver object. So, you say, objects are just like functions, right? Yes. If you already understand how to organize code into properly grouped functions and variables, then you already understand OOP. There are finer points to OOP such as classes, inheritance, and polymorphism; again, if you think in terms of sensible organization these things are easier to understand.

Third, white space has meaning in Python. You have to get your white spaces right or your code won’t work.

Fourth, Python is an interpreted language. You don’t have to compile and link your Python programs. If you’re experienced with the Bash shell, then you already know about interpreted languages, how fast they are to code in, and how you can test out your programs interactively before writing them into a script.

The downside to interpreted languages is the overhead of the interpreter. Usually, programs written in compiled languages run faster. However, you can link your Python programs to functions written in many other languages, including C/C++, Lisp, Fortran, Java, and Perl, and many more so you can mix and match to get the results you want.

Try It

Python is included in most Linux distributions, and usually the python package installs the base components and Python command interpreter. The text in bold is what you type.

$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> topics

Here is a list of available topics.  Enter any topic name to get more help.

ASSERTION  DEBUGGING LITERALS SEQUENCEMETHODS2
ASSIGNMENT DELETION  LOOPING  SEQUENCES
[...]
help> quit

Of course we must do the traditional Hello World! Strings must be enclosed in single or double quotes.

>>> 'Hello, world!'
'Hello, world!'
>>> hell = "Hello, world!"
>>> hell
'Hello, world!'

Now create the simplest possible Python script, save it as hello.py, and run it from your normal Linux shell:

#!/usr/bin/python

print "Hello World!";

carla@studio:~$ python hello.py
Hello World!

Let’s go back to the Python interpreter and play with data types.

>>> 2 + 2
4
>>> 2 + foo
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'foo' is not defined
>>> foo = 5
>>> 2 + foo
7

Now try a short interactive script. It asks you to input your age, responds according to the age you type, and checks if your response is in the correct data type. This is a great little script to tweak in different ways. For example, you could limit the acceptable age range, limit the number of incorrect tries, and get creative with your responses. Note that raw_input is for Python 2.x, and 3.x uses input.

Watch your indentation; the indented lines must be four spaces. If you are using a proper code editor, it should take care of this for you.

#!/usr/bin/python

while True:
    try:
        age = int(raw_input("Please enter your age: "))
    except ValueError:
        print("I'm so very sorry, that does not compute. Please try again.")
        continue
    else:
        break
if age >= 18: 
    print("Very good, you are old enough to know better, but not too old to do it anyway.")
else:
    print("Sorry, come back when you're 18 and try again.")

Modules and Learning

There are a great number of Python modules, and you can learn to write your own. The key to writing good Python programs and making them do what you want is learning where to find modules. Start at Python.org because of the abundant documentation and good organization. Plan to spend a lot of time here, because it contains the best and authoritative information. It even has an interactive shell you can practice with.

Learn more about Linux through the free “Introduction to Linux” course from The Linux Foundation and edX.

Ubuntu 18.04.2 Refreshes This Long-Term Support Linux Distro

Do you want the best compromise between the latest and greatest open-source software and the stability of an established Linux? If that’s you, and you’re an Ubuntu user, then you want Ubuntu 18.04.2.

This latest version of Ubuntu 18.04, the Long-Term Support (LTS) edition, will be supported until April 2028. If you’re using Ubuntu in business, this is the one you want.

Why? For starters, Ubuntu 18.04.2 has upgraded its Linux kernel from 4.15 to the  4.18 Linux kernel. This kernel comes with Spectre and Meltdown security patches and improved hardware drivers.

Read more at ZDNet

6 Must-Attend Talks at Cloud Foundry Summit on Serverless, Knative, Microservices

Tech conferences often feel the same to me. It’s all about the ratios. Too much technical stuff and you wonder how any of it actually applies to your business problems. Too much business-speak and you might end up looking for a slide deck escape hatch to take you to a code repository. Like Goldilocks eating porridge, or me eating a cupcake, you want to find a mix that’s “just right.” Finding a good balance between deep technical content and compelling business outcomes makes for a better conference. (Now that I think about it, so would serving cupcakes!)

This is one reason why I love Cloud Foundry Summit—the ratios are right! There are always plenty of compelling user stories where you can follow what companies like AllstateRoyal Bank of Canada, and CSAA have been able to accomplish with Cloud Foundry. But Cloud Foundry Summit has a lot to offer for tech enthusiasts too, including plenty of opportunities to learn about related projects and emerging technologies. Last year, Kubernetesfunctions, and event-driven architectures were hot topics.

This year’s Cloud Foundry Summit is right around the corner… If you’re as intrigued by all things serverless as I am, here’s my list of must-attend talks:

Read more at The New Stack

Logical & in Bash

One would think you could dispatch & in two articles. Turns out you can’t. While the first article dealt with using & at the end of commands to push them into the background and then diverged into explaining process management, the second article saw & being used as a way to refer to file descriptors, which led us to seeing how, combined with < and >, you can route inputs and outputs from and to different places.

This means we haven’t even touched on & as an AND operator, so let’s do that now.

& is a Bitwise Operator

If you are at all familiar with binary operations, you will have heard of AND and OR. These are bitwise operations that operate on individual bits of a binary number. In Bash, you use & as the AND operator and | as the OR operator:

AND

0 & 0 = 0

0 & 1 = 0

1 & 0 = 0

1 & 1 = 1

OR

0 | 0 = 0

0 | 1 = 1

1 | 0 = 1

1 | 1 = 1

You can test this by ANDing any two numbers and outputting the result with echo:

$ echo $(( 2 & 3 )) # 00000010 AND 00000011 = 00000010

2

$ echo $(( 120 & 97 )) # 01111000 AND 01100001 = 01100000

96

The same goes for OR (|):


$ echo $(( 2 | 3 )) # 00000010 OR 00000011 = 00000011

3

$ echo $(( 120 | 97 )) # 01111000 OR 01100001 = 01111001

121

Three things about this:

  1. You use (( ... )) to tell Bash that what goes between the double brackets is some sort of arithmetic or logical operation. (( 2 + 2 )), (( 5 % 2 )) (% being the modulo operator) and ((( 5 % 2 ) + 1)) (equals 3) will all work.
  2. Like with variables, $ extracts the value so you can use it.
  3. For once spaces don’t matter: ((2+3)) will work the same as (( 2+3 )) and (( 2 + 3 )).
  4. Bash only operates with integers. Trying to do something like this (( 5 / 2 )) will give you “2”, and trying to do something like this (( 2.5 & 7 )) will result in an error. Then again, using anything but integers in a bitwise operation (which is what we are talking about now) is generally something you wouldn’t do anyway.

TIP: If you want to check what your decimal number would look like in binary, you can use bc, the command-line calculator that comes preinstalled with most Linux distros. For example, using:


bc <<< "obase=2; 97"

will convert 97 to binary (the o in obase stands for output), and …


bc <<< "ibase=2; 11001011"

will convert 11001011 to decimal (the i in ibase stands for input).

&& is a Logical Operator

Although it uses the same logic principles as its bitwise cousin, Bash’s && operator can only render two results: 1 (“true”) and 0 (“false”). For Bash, any number not 0 is “true” and anything that equals 0 is “false.” What is also false is anything that is not a number:


$ echo $(( 4 && 5 )) # Both non-zero numbers, both true = true

1

$ echo $(( 0 && 5 )) #  One zero number, one is false = false

0

$ echo $(( b && 5 )) #  One of them is not number, one is false = false

0

The OR counterpart for && is || and works exactly as you would expect.

All of this is simple enough… until it comes to a command’s exit status.

&& is a Logical Operator for Command Exit Status

As we have seen in previous articles, as a command runs, it outputs error messages. But, more importantly for today’s discussion, it also outputs a number when it ends. This number is called an exit code, and if it is 0, it means the command did not encounter any problem during its execution. If it is any other number, it means something, somewhere, went wrong, even if the command completed.

So 0 is good, any other number is bad, and, in the context of exit codes, 0/good means “true” and everything else means “false.” Yes, this is the exact contrary of what you saw in the logical operations above, but what are you gonna do? Different contexts, different rules. The usefulness of this will become apparent soon enough.

Moving on.

Exit codes are stored temporarily in the special variable ? — yes, I know: another confusing choice. Be that as it may, remember that in our article about variables, and we said that you read the value in a variable using a the $ symbol. So, if you want to know if a command has run without a hitch, you have to read ? as soon as the command finishes and before running anything else.

Try it with:


$ find /etc -iname "*.service"

find: '/etc/audisp/plugins.d': Permission denied 

/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service 

/etc/systemd/system/dbus-org.freedesktop.ModemManager1.service

[etcetera]

As you saw in the previous article, running find over /etc as a regular user will normally throw some errors when it tries to read subdirectories for which you do not have access rights.

So, if you execute…


echo $?

… right after find, it will print a 1, indicating that there were some errors.

(Notice that if you were to run echo $? a second time in a row, you’d get a 0. This is because $? would contain the exit code of echo $?, which, supposedly, will have executed correctly. So the first lesson when using $? is: use $? straight away or store it somewhere safe — like in another variable, or you will lose it).

One immediate use of ? is to fold it into a list of chained commands and bork the whole thing if anything fails as Bash runs through it. For example, you may be familiar with the process of building and compiling the source code of an application. You can run them on after another by hand like this:


$ configure

.

.

.

$ make

.

.

.

$ make install

.

.

.

You can also put all three on one line…


$ configure; make; make install

… and hope for the best.

The disadvantage of this is that if, say, configure fails, Bash will still try and run make and sudo make install, even if there is nothing to make or, indeed, install.

The smarter way of doing it is like this:


$ configure && make && make install

This takes the exit code from each command and uses it as an operand in a chained && operation.

But, and here’s the kicker, Bash knows the whole thing is going to fail if configure returns a non-zero result. If that happens, it doesn’t have to run make to check its exit code, since the result is going to be false no matter what. So, it forgoes make and just passes a non-zero result onto the next step of the operation. And, as configure && make delivers false, Bash doesn’t have to run make install either. This means that, in a long chain of commands, you can join them with &&, and, as soon as one fails, you can save time as the rest of the commands get canceled immediately.

You can do something similar with ||, the OR logical operator, and make Bash continue processing chained commands if only one of a pair completes.

In view of all this (along with the stuff we covered earlier), you should now have a clearer idea of what the command line we set at the beginning of this article does:

mkdir test_dir 2>/dev/null || touch backup/dir/images.txt && find . -iname "*jpg" > backup/dir/images.txt &

So, assuming you are running the above from a directory for which you have read and write privileges, what it does it do and how does it do it? How does it avoid unseemly and potentially execution-breaking errors? Next week, apart from giving you the solution, we’ll be dealing with brackets: curly, curvy and straight. Don’t miss it!

The Future of Artificial Intelligence at Scale

For this week’s episode of the The New Stack Analysts podcast, TNS editorial director Libby Clark and TNS London correspondent Jennifer Riggins sat down (via Zoom) with futurist Martin Ford, author of “Architects of Intelligence: The truth about AI from the people building it,” and Ofer Hermoni, chair of the technical advisory council for The Linux Foundation’s Deep Learning Foundation projects, to talk about the current state of AI, how it will scale, and its consequences.

Hermoni believes that the open source community — and the still very complicated AI landscape — will act as the democratization of both the future of AI technology and the necessary ethical boundaries. He talks about how to leverage open governance and common standards to make this happen.

Read more at The New Stack