Go Tutorial – Introduction to Go

Introductory Go Programming Tutorial

An Overview of the Core Language

Go Programming

Maybe you’ve heard of Go. It was first introduced in 2009, but like any new programming language, it took a while for it to mature and stabilize to the point where it became useful for production applications. Nowadays, Go is a well-established language that is used for network and database programming, web development, and writing DevOps tools. It was used to write Docker, Kubernetes, Terraform and Ethereum. Go is accelerating in popularity, with adoption increasing by 76% in 2017, and now there are Go user groups and Go conferences. Whether you want to add to your professional skills, or are just interested in learning a new programming language, you may want to check it out.

Why Go?

Go was created at Google by a team of three programmers: Robert Griesemer, Rob Pike, and Ken Thompson. The team decided to create Go because they were frustrated with C++ and Java, which over the years had become cumbersome and clumsy to work with. They wanted to bring enjoyment and productivity back to programming.

The three have impressive accomplishments. Griesemer worked on Google’s ultra-fast V8 JavaScript engine, used in the Chrome web browser, Node.js JavaScript run time environment, and elsewhere. Pike and Thompson were part of the original Bell Labs team that created Unix, the C language, and Unix utilities, which led to the development of the GNU utilities and Linux. Thompson wrote the very first version of Unix and created the B programming language, upon which C was based. Later, Thompson and Pike worked on the Plan 9 operating system team, and they also worked together to define the UTF-8 character encoding.

Go has the safety of static typing and garbage collection along with the speed of a compiled language. With other languages, “compiled” and “garbage collection” are associated with waiting around for the compiler to finish, and then getting slowly-running programs. But Go has a lightning-fast compiler that makes compile times barely noticeable, and a modern, ultra-efficient garbage collector. You get fast compile times along with fast programs. Go has concise syntax and grammar with few keywords, giving Go the simplicity and fun of dynamically-typed interpreted languages like Python, Ruby, and JavaScript.

If you know C, C++, Java, Python, JavaScript, or a similar language, many parts of Go, including identifiers, operators, and flow control statements, will look familiar. A simple example is that comments can be included as in ANSI C:

// This comment continues only to the end of the line.

/* This type
of comment
can span
multiple lines. */

In other ways, Go is very different from C. One obvious difference is its declaration syntax, which is more like that of Pascal and Modula-2. Here is how an integer variable is declared in Go:

var i int

This syntax may look “backwards” to a C or Java programmer, but it is much more natural and easier to work with. Declarations in Go can usually be directly translated to or from English or another human language. In the above example, the declaration can be read as, “Variable i is an integer.” Here are some more simple examples:

var x float32 // “Variable x is a 32-bit floating point number.”
var c byte // “Variable c is a byte.”
var s string // “Variable s is a string.”

And it is also possible to do this with more complex data types:

var a [32]int // “Variable a is an array of 32 integers.”

var s struct { // “Variable s is a structure composed of
i int // i, an integer,
b byte // b, a byte,
s []int // and s, a slice of integers.”
}

The idea of Go’s design is to have the best parts of many languages. At first, Go looks a lot like a hybrid of C and Pascal (both of which are successors to Algol 60), but looking closer, you will find ideas taken from many other languages as well.

Go is designed to be a simple compiled language that is easy to use, while allowing concisely-written programs that run efficiently. Go lacks extraneous features, so it’s easy to program fluently, without needing to refer to language documentation while programming. Programming in Go is fast, fun, and productive.

Let’s Go

First, make sure you have Go installed. The Go Team has easily-installed distributions for Linux (including Raspberry Pi), macOS, FreeBSD, and Windows on the Go website at https://golang.org/dl/

You will also need to make sure that your PATH environment variable is set properly to allow your shell or command line processor to find the programs that make up the Go system. On Linux, macOS, or FreeBSD, add /usr/local/go/bin to your PATH, somewhat like this:

$ PATH=$PATH:/usr/local/go/bin

On Windows, setting a PATH environment variable is a little more complicated. In either case, you can find directions for setting PATH in the installation instructions for your system, which appear in a web page after you click to download the installation package.

On Linux, you may be able to install Go using your distribution’s package management system. To find the Go package, try looking for “golang”, which is a synonym for Go. Even if you can do that, it may be better to download a distribution from the Go website to make sure you get the most recent version.

When you have Go installed, try this command:

$ go version
go version go1.11.1 linux/amd64

The output shows that I have Go version 1.11.1 installed on my 64-bit Linux machine.

Hopefully, by now you’ve become interested and want to see what a complete Go program looks like. Here’s a very simple program in Go that prints “hello, world”.

package main

import “fmt”

func main() {
fmt.Printf(“hello, worldn”)
}

The line package main defines the package that this file is part of. Naming main as the name of the package and the function tell Go that this is where the program’s execution should start. We need to define a main package and main function even when there is only one package with one function in the entire program.

At the top level, Go source code is organized into packages. Every source file is part of a package. Importing packages and exporting functions are child’s play.

The next line, import “fmt”, imports the fmt package. It is part of the Go standard library, and contains the Printf() function. Often you will need to import more than one package. To import the fmt, os, and strings packages, you can either type

import “fmt”
import “os”
import “strings”

or

import (
“fmt”
“os”
“strings”
)

Using parentheses, import is applied to everything listed inside the parentheses, saving some typing. You will see parentheses used like this again elsewhere in Go, and Go has other kinds of typing shortcuts, too.

Packages may export constants, types, variables, and functions. To export something, just capitalize the name of the constant, type, variable or function you want to export. It’s that simple.

Notice that there are no semicolons in the “hello, world” program. Semicolons at the ends of lines are optional. Although this is convenient, it leads to something to be careful about when you are first learning Go. This part of Go’s syntax is implemented using a method taken from the BCPL language. The compiler uses a simple set of rules to “guess” when there should be a semicolon at the end of the line, and it inserts one automatically. In this case, if the right parenthesis in main() were at the end of the line, it would trigger the rule, so it’s necessary to place the open curly bracket after main() on the same line.

This formatting is a common practice that’s allowed in other languages, but in Go, it is required. If we put the open curly bracket on the next line, we will get an error message.

Go is unusual in that it either requires or favors a specific style of whitespace formatting. Rather than allowing all sorts of formatting styles, the language comes with a single formatting style as part of its design. The programmer has a lot of freedom to violate it, but only up to a point. This is either a straitjacket or godsend, depending on your preferences! Free-form formatting, allowed by many other languages, can lead to a mini Tower of Babel, making code difficult to read by other programmers. Go avoids that by making a single formatting style the preferred one. Since it’s fairly easy to adopt a standard formatting style and get used to using it habitually, that’s all you have to do to be writing universally-readable code. Fair enough? Go even comes with a tool for reformatting your code to make it fit the standard:

$ go fmt hello.go

Just two caveats: Your code must be free of syntax errors for it to work, so it won’t fix problems such as failing to put an open brace on the same line. Also, it overwrites the original file, so if you want to keep the original, make a backup before running go fmt.

The main() function has just one line of code to print the message. In this example, the Printf() function from the fmt package was used to make it similar to writing a “hello, world” program in C. If you prefer, you can also use

fmt.Println(“hello, world”)

to save typing the n newline character at the end of the string. This is another example of Go being similar to C and Pascal. You get formatted printing and scanning functions closely resembling the ones C programmers are used to, plus simple and convenient functions like Println() that are similar to writeln() and other functions in Pascal.

So let’s compile and run the program. First, copy the “hello, world” source code to a file named hello.go. Then compile it using this command:

$ go build hello.go

And to run it, use the resulting executable, named hello, as a command:

$ hello
hello, world

As a shortcut, you can do both steps in just one command:

$ go run hello.go
hello, world

That will compile and run the program without creating an executable file. It’s great for when you are actively developing a project and you are just checking for errors before doing more edits.

Next, let’s look at a few of Go’s main features.

Concurrency

Go’s built-in support for concurrency, in the form of goroutines, is one of the language’s best features. A goroutine is like a process or thread, but is much more lightweight. It is normal for a Go program to have thousands (or maybe even a few millions) of active goroutines. Starting up a goroutine is as simple as

go f()

The function f() will then run concurrently with the main program and other goroutines. Go has a means of allowing the concurrent pieces of the program to synchronize and communicate using channels. A channel is somewhat like a Unix pipe; it can be written to at one end, and read from at the other. A common use of channels is for goroutines to indicate when they have finished.

The goroutines and their resources are managed automatically by the Go runtime system. With Go’s currency support, it’s easy to get all of the cores and threads of a multi-core CPU working efficiently.

Synchronization with Channels

Any language that supports multi-threaded or concurrent processing needs to have a mechanism that allows simultaneously or concurrently-running code to coordinate modifying and accessing data. For this purpose, Go has channels, which are first-in-first-out (FIFO) queues that function in a manner that allows them to be used to synchronize goroutines.

In the simplest case, a channel is unbuffered and allows only one pending operation at a time. Therefore, it is either empty or has a read or write that is waiting for another goroutine to perform the corresponding action.

Synchronization is performed as in this example: Suppose a goroutine attempts to receive (read) from an empty channel. The goroutine is put to sleep by the Go runtime system until another goroutine sends on (writes to) the channel. Then there is something there for the first goroutine to receive, so it’s awakened and the receive operation succeeds. This mechanism allows a channel to be used to make a goroutine wait for another to signal it by performing an operation on their shared channel. Go’s channels can be used to implement mutually-exclusive locks (mutexes) that are found in other languages, and the sync Go package does exactly that.

Using channels is very simple and concise. Before they are used, channels are allocated using Go’s built-in make() function. For example,

var intch chan int
intch = make(chan int)

declares and then creates a new channel named intch for sending and receiving integers. Sending on a channel is as simple as

intch // send the integer 1 on the channel

and receiving from a channel (in another goroutine) is just as simple:

var num int
num = // receive an integer from the channel

Here’s a complete example that shows a channel in use:

package main

import “fmt”

var intch chan int

func main() {
intch = make(chan int)
go print_number()
intch // send 37 on the channel
// wait for a response before exiting
}

func print_number() {
var number int

number = // receive an integer from the channel
fmt.Printf(“The number is %dn”,number)
intch // send a response
}

Types, Methods, and Interfaces

You might wonder why types and methods are together in the same heading. It’s because Go has a simplified object-oriented programming model that works along with its expressive, lightweight type system. It completely avoids classes and type hierarchies, so it’s possible to do complicated things with datatypes without creating a mess. In Go, methods are attached to user-defined types, not to classes, objects, or other data structures. Here’s a simple example:

package main

import “fmt”

type MyInt int

func (n MyInt) sqr() MyInt {
return n*n
}

func main() {

var number MyInt = 5

var square = number.sqr()

fmt.Printf(“The square of %d is %dn”,number,square)
}

Along with this, Go has a facility called interfaces that allow mixing of types. Operations can be performed on mixed types as long as each has the method or methods attached to it, specified in the definition of the interface, that are needed for the operations.

Suppose we’ve created types called cat, dog, and bird, and each have a method called age() that return the age of the animal. If we want to add the ages of all animals in one operation, we can define an interface like this:

type animal interface {
age() int
}

The animal interface then can be used like a type, allowing the cat, dog, and bird types to all be handled collectively when calculating ages.

Unicode Support

Considering that Ken Thompson and Rob Pike defined the Unicode UTF-8 encoding that is now dominant worldwide, it may not surprise you that Go has good support for UTF-8. If you’ve never used Unicode and don’t want to bother with it, don’t worry; UTF-8 is a superset of ASCII. That means you can continue programming in ASCII and ignore Go’s Unicode support and everything will work nicely.

In reality, all source code is treated as UTF-8 by the Go compiler and tools. If your system is properly-configured to allow you to enter and display UTF-8 characters, you can use them in Go source file names, command-line arguments, and in Go source code for literal strings and names of variables, functions, types, and constants.

Just below, you can see a “hello, world” program in Portuguese, as it might be written by a Brazilian programmer.

package main

import “fmt”

func faça_uma_ação_em_português() {
fmt.Printf(“Olá mundo!n”)
}

func main() {
faça_uma_ação_em_português()
}

In addition to supporting Unicode in these ways, Go has three packages in its standard library for handling more complicated issues involving Unicode.

Summing it Up

By now, maybe you understand why Go programmers are enthusiastic about the language. It’s not just that Go has so many good features, but that they are all included in one language that was designed to avoid overcomplication. It’s a really good example of the whole being greater than the sum of its parts.

To learn more about Go, visit the Go website and take A Tour of Go.

Contact the author

Source

Linux Today – Apple’s New Hardware With The T2 Security Chip Will Currently Block Linux From Booting

Nov 06, 2018, 04:00

Apple’s MacBook Pro laptops have become increasingly unfriendly with Linux in recent years while their Mac Mini computers have generally continued working out okay with most Linux distributions due to not having to worry about multiple GPUs, keyboards/touchpads, and other Apple hardware that often proves problematic with the Linux kernel. But now with the latest Mac Mini systems employing Apple’s T2 security chip, they took are likely to crush any Linux dreams.

Source

Download MorpheusArch Linux 2018.4

MorpheusArch Linux is an open-source, Linux-based operating system derived from Arch Linux and featuring the lightweight LXQt desktop environment. It’s designed as a live recovery ISO that comes preloaded with numerous data recovery tools that let you recover over 400 file types.

Standard Arch Linux boot menu, 64-bit only

Being based on Arch Linux, the MorpheusArch Linux distribution supports only 64-bit (x86_64) systems and features an identical boot menu with the one present on Arch Linux’s ISO images, allowing you to boot the live OS or an installed one, run a memory or hardware test, as well as to reboot or power off the PC.

The live ISO image can be written to a USB flash drive or DVD disc so you can use it on the go when you need to recover lost data form broken disks, including memory sticks. When using the MorpheusArch Linux live image, please keep in mind that you need to use the “arch” password (without quotes) when prompted.

Standard LXQt desktop environment, includes PhotoRec and TestDisk

MorpheusArch Linux features a standard LXQt desktop environment that’s not customized in any way. You will get the vanilla LXQt desktop experience because the point of this GNU/Linux distribution is to offer users a set of data recovery tools that you’ll have to run from a terminal emulator.

Among the included data recovery tools, we can mention the popular PhotoRec digital picture and file recovery utility, as well as the TestDisk partition recovery and file undelete software from CGSecurity. Additionally, MorpheusArch Linux comes with the GNU ddrescue is a data recovery tool and Zenmap security scanner.

Helps you recover more than 400 file types

According to the developers, MorpheusArch Linux is a nifty live GNU/Linux distribution that helps you recover more than 400 file types, and they choose to base it on the lightweight and highly efficient Arch Linux operating system and LXQt desktop environment.

However, MorpheusArch Linux is not a distro you can use as your main operating system. It doesn’t come with an installer as it’s intended to be used only as a live image, from a USB flash drive, to recover lost data from damaged or broken disk drives and memory sticks.

Source

The future is bright, the future is open source.

Share with friends and colleagues on social media

It’s fair to say that open source is an important part of many industries today. Whether you’re looking at open source server hardware, open source Linux software, open source software-defined networking, open source cloud management platforms, or even open source cola, no-one can deny that it’s everywhere now.

However, with so many open source options available today, it’s hard to work out how to get started – like walking into a used bookstore that hasn’t organised its books into categories or genres.

Are you experienced?

Here at SUSE we are, with over a quarter of a century of experience in making open source easier for businesses to choose, use and build their businesses upon. We have many skilled software engineers and developers around the world working on our software products and providing world-class support to our customers. In addition to these excellent engineering resources, we have other team members who are deeply involved in the open source world like Alan Clark in our CTO office. He’s somewhat of a legend within the open source community – he’s the chairman of the OpenStack Foundation, the chairman of the OpenHPC Foundation and is also on the board of directors of the Linux Foundation.

Our very own Kent Wimmer spent some time with him recently in our Provo office, chatting to him about all things open source and OpenStack. Whether you’re interested in IoT, Machine Learning, containisation, cloud computing or something else, watch the video here to hear Alan’s thoughts on the future of open source, the rise of multi-cloud and hybrid cloud, and how individuals and businesses can best get started in OpenStack.

Alan and Kent will be with us at the OpenStack Summit in Berlin next week (November 13th-15th), so if you’re visiting, come along to see us at the booth (booth B3, it’ll be the one staffed by people in pilot’s uniforms!) and find out more about how SUSE can make open source easier for you.

Source

Commandline quick tips: How to locate a file

We all have files on our computers — documents, photos, source code, you name it. So many of them. Definitely more than I can remember. And if not challenging, it might be time consuming to find the right one you’re looking for. In this post, we’ll have a look at how to make sense of your files on the command line, and especially how to quickly find the ones you’re looking for.

Good news is there are few quite useful utilities in the Linux commandline designed specifically to look for files on your computer. We’ll have a look at three of those: ls, tree, and find.

ls

If you know where your files are, and you just need to list them or see information about them, ls is here for you.

Just running ls lists all visible files and directories in the current directory:

$ ls
Documents Music Pictures Videos notes.txt

Adding the -l option shows basic information about the files. And together with the -h option you’ll see file sizes in a human-readable format:

$ ls -lh
total 60K
drwxr-xr-x 2 adam adam 4.0K Nov 2 13:07 Documents
drwxr-xr-x 2 adam adam 4.0K Nov 2 13:07 Music
drwxr-xr-x 2 adam adam 4.0K Nov 2 13:13 Pictures
drwxr-xr-x 2 adam adam 4.0K Nov 2 13:07 Videos
-rw-r–r– 1 adam adam 43K Nov 2 13:12 notes.txt

Is can also search a specific place:

$ ls Pictures/
trees.png wallpaper.png

Or a specific file — even with just a part of the name:

$ ls *.txt
notes.txt

Something missing? Looking for a hidden file? No problem, use the -a option:

$ ls -a
. .bash_logout .bashrc Documents Pictures notes.txt
.. .bash_profile .vimrc Music Videos

There are many other useful options for ls, and you can combine them together to achieve what you need. Learn about them by running:

$ man ls

tree

If you want to see, well, a tree structure of your files, tree is a good choice. It’s probably not installed by default which you can do yourself using the package manager DNF:

$ sudo dnf install tree

Running tree without any options or parameters shows the whole tree starting at the current directory. Just a warning, this output might be huge, because it will include all files and directories:

$ tree
.
|– Documents
| |– notes.txt
| |– secret
| | `– christmas-presents.txt
| `– work
| |– project-abc
| | |– README.md
| | |– do-things.sh
| | `– project-notes.txt
| `– status-reports.txt
|– Music
|– Pictures
| |– trees.png
| `– wallpaper.png
|– Videos
`– notes.txt

If that’s too much, I can limit the number of levels it goes using the -L option followed by a number specifying the number of levels I want to see:

$ tree -L 2
.
|– Documents
| |– notes.txt
| |– secret
| `– work
|– Music
|– Pictures
| |– trees.png
| `– wallpaper.png
|– Videos
`– notes.txt

You can also display a tree of a specific path:

$ tree Documents/work/
Documents/work/
|– project-abc
| |– README.md
| |– do-things.sh
| `– project-notes.txt
`– status-reports.txt

To browse and search a huge tree, you can use it together with less:

$ tree | less

Again, there are other options you can use with three, and you can combine them together for even more power. The manual page has them all:

$ man tree

find

And what about files that live somewhere in the unknown? Let’s find them!

In case you don’t have find on your system, you can install it using DNF:

$ sudo dnf install findutils

Running find without any options or parameters recursively lists all files and directories in the current directory.

$ find
.
./Documents
./Documents/secret
./Documents/secret/christmas-presents.txt
./Documents/notes.txt
./Documents/work
./Documents/work/status-reports.txt
./Documents/work/project-abc
./Documents/work/project-abc/README.md
./Documents/work/project-abc/do-things.sh
./Documents/work/project-abc/project-notes.txt
./.bash_logout
./.bashrc
./Videos
./.bash_profile
./.vimrc
./Pictures
./Pictures/trees.png
./Pictures/wallpaper.png
./notes.txt
./Music

But the true power of find is that you can search by name:

$ find -name do-things.sh
./Documents/work/project-abc/do-things.sh

Or just a part of a name — like the file extension. Let’s find all .txt files:

$ find -name “*.txt”
./Documents/secret/christmas-presents.txt
./Documents/notes.txt
./Documents/work/status-reports.txt
./Documents/work/project-abc/project-notes.txt
./notes.txt

You can also look for files by size. That might be especially useful if you’re running out of space. Let’s list all files larger than 1 MB:

$ find -size +1M
./Pictures/trees.png
./Pictures/wallpaper.png

Searching a specific directory is also possible. Let’s say I want to find a file in my Documents directory, and I know it has the word “project” in its name:

$ find Documents -name “*project*”
Documents/work/project-abc
Documents/work/project-abc/project-notes.txt

Ah! That also showed the directory. One thing I can do is to limit the search query to files only:

$ find Documents -name “*project*” -type f
Documents/work/project-abc/project-notes.txt

And again, find have many more options you can use, the man page might definitely help you:

$ man find

Source

Now Use Chainer 5.0 on AWS Deep Learning AMIs

Posted On: Nov 5, 2018

The AWS Deep Learning AMIs for Ubuntu and Amazon Linux now come with Chainer 5.0, which includes support for Python 3.6 and iDeep 2.0. As with other frameworks, Deep Learning AMIs offer optimized builds of Chainer 5.0 that are fine-tuned and fully-configured for high performance deep learning on Amazon EC2 CPU and GPU instances.

AWS Deep Learning AMIs also support other popular frameworks including TensorFlow, PyTorch, and Apache MXNet —all pre-installed and fully-configured for you to start developing your deep learning models in minutes while taking full advantage of the computational power of Amazon EC2 instances. For a complete list of frameworks and versions supported by the AWS Deep Learning AMI, see the release notes.

Get started quickly with the AWS Deep Learning AMIs using the getting-started guides and beginner to advanced level tutorials in our developer guide. You can also subscribe to our discussion forum to get launch announcements and post your questions.

Source

Install Netplan on Ubuntu | Linux Hint

Netplan is a utility for configuring network interfaces on Linux. Netplan uses YAML files for configuring network interfaces. YAML configuration file format is really simple. It has clear and easy to understand syntax. Netplan works with traditional Linux networking system Systemd-networkd and Network Manager. With Netplan you can configure the network of your Ubuntu machines easier than ever before. Starting from Ubuntu 18.04 LTS, Ubuntu uses Netplan to configure network interfaces by default.

In this article, I will show you how to install Netplan on Ubuntu 16.04 LTS and later, and how to use Netplan on Ubuntu. I will be using Ubuntu 18.04 LTS for the demonstration. But it should work the same way on every Ubuntu version where Netplan is installed. Let’s get started.

Netplan is available in the official package repository of Ubuntu. So, it is really easy to install. Netplan is not installed by default on Ubuntu 16.04 LTS. So, I am focusing on the installation method of Netplan on Ubuntu 16.04 LTS in this section. First, update the APT package repository cache with the following command:

The APT package repository cache should be updated.

Now, install Netplan with the following command:

$ sudo apt install netplan

Netplan should be installed.

By default, Netplan is disabled on Ubuntu 16.04 LTS. You have to enable it manually. To enable Netplan, you have to create a file netplan in the /etc/default/ directory and add ENABLED=1 to it.

To do that, run the following command:

$ echo “ENABLED=1” | sudo tee /etc/default/netplan

/etc/default/netplan file should be created.

Now, reboot your computer with the following command:

Netplan should be enabled.

Netplan Configuration Files:

On Ubuntu 18.04 LTS, the Netplan YAML configuration files are placed in the /etc/netplan/ directory. To configure a network interface, you have to create or modify required YAML files in this directory. YAML configuration files has the .yaml extension. The default Netplan YAML configuration file /etc/netplan/50-cloud-init.yaml is used to configure network interfaces using Netplan.

On Ubuntu 16.04 LTS, the configuration files are placed in the /etc/plan directory and the default configuration file is /etc/plan/netplan-acl.

Make sure you modify the correct configuration file depending on the version of Ubuntu you’re using.

Configuring Network Interface via DHCP with Netplan:

In this section, I will show you how to configure a network interface via DHCP on Ubuntu with Netplan. First, find the network interface name that you want to configure with the following command:

As you can see, I have one network interface card (NIC) installed on my Ubuntu 18.04 LTS machine and the network interface name is ens33. It does not have any IP address configured right now. Let’s use Netplan to configure it via DHCP.

To configure the network interface ens33 via DHCP using Netplan, open the default Netplan configuration file on Ubuntu 18.04 LTS /etc/netplan/50-cloud-init.yaml with the following command:

$ sudo nano /etc/netplan/50-cloud-init.yaml

You should see the following window.

Now add the following lines in the network section.

ethernets:
ens33:
dhcp4: yes

Here, dhcp4: yes means, use DHCP for IPv4 protocol to configure the network interface ens33.

NOTE: The indentations are really useful. Make sure you indent each line correctly. It will make the syntax clearer and comfortable to the eye.

Finally, the configuration file should look something like this.

Now, press <Ctrl> + x and then press y followed by <Enter> to save the file.

The good thing about Netplan is that before you apply the changes, you can make sure the configuration file has no typos or any other mistakes with the following command:

Now press <Enter>.

If everything is alright, you should see Configuration accepted message as marked in the screenshot below.

If there’s any problem with the configuration file, you will see appropriate error messages here.

This feature will surely help you to avoid complex hard to track future problems with Netplan configuration files. Finally, apply the changes permanently using Netplan with the following command:

As you can see, the network interface ens33 is configured via DHCP.

Setting Up Static IP Address with Netplan:

If you want to set up a static IP on your network interface using Netplan, then this section is for you. You can manually set the IP address, name server, gateway etc. of your network interface using Netplan. Let’s say, you want to configure your network interface ens33 as follows:

Static IP address: 192.168.10.33
Subnet mask: 255.255.255.0
Gateway: 192.168.10.1
DNS server: 192.168.10.1

First, check the network configuration of ens33 network interface with the following command:

This is to help you verify that the network interface settings really changed.

Now, edit the Netplan YAML configuration file /etc/netplan/50-cloud-init.yaml with the following command:

$ sudo nano /etc/netplan/50-cloud-init.yaml

If you’ve followed me throughout the article, then the configuration file should be like this. Now, remove the line as marked in the screenshot below.

And type in the lines as marked in the screenshot below.

NOTE: Remember, indentation is essential for YAML files. If you forget to indent correctly, Netplan will not let you apply the configuration file. So, you must indent every step of the YAML configuration file as shown in the screenshot below.

Now, press <Ctrl> + x and then press y followed by <Enter> to save the file.

Now, check whether there’s any error in the configuration file with the following command:

press <Enter>.

As you can see, the configuration file is accepted.

Finally, apply the configuration file with the following command:

As you can see, the IP address is changed as expected.

The gateway is also set correctly.

The DNS server is set correctly as well.

So, that’s how you install and use Netplan on Ubuntu to configure network interfaces using YAML files. If you want to learn more about Netplan, please visit the official website of Netplan at https://netplan.io. Thanks for reading this article.

Source

Linux Today – Feren OS Delivers Richer Cinnamon Flavor

Nov 06, 2018, 05:00

Feren OS is a nice alternative to Linux Mint and an easy stepping stone to transition to Linux from Microsoft Windows or macOS.

I am a long-time user of Linux Mint, but I am falling out of love with it. Mint is getting stale. It is annoyingly sluggish at times. I run it on a number of computers and experience the same symptoms on a variety of hardware configurations. Linux Mint is starting to suffer from a developmental malaise.

Source

Time-management thriller ‘Out of The Box’ released earlier this year with Linux support

One from the ‘inbox of no return’ that I sadly missed, Out of The Box from developer Nuclear Tales is a time-management thriller where you decide the fate of the quirky customers of a luxurious club and it has Linux support. Note: Key provided by the publisher.

As head of security, you will need to deal with the rules of the club which gradually get more complex. Find out who is lying, who is telling the truth and possibly throw a few punches. The story actually changes, depending on what you do during your time. Work with the police, gangsters or whoever.

About the game:

Every night, among the club’s visitors, you’ll find undercover cops, annoying celebrities, runaway criminals or ghosts from your past. As the new gatekeeper of The Box, you decide who enters and who doesn’t… by any means necessary. Be careful though, because each choice you make can influence the fate of the club and its clients. You’ll also need to keep your salary to avoid being evicted, to see your daughter again, and most importantly, to regain control of your life.

Will you let teenagers into the club in exchange for money? Will you confront a wealthy client to save his girlfriend when she asks you for help? Or will you work with the police to bring down the most powerful gangster in town?

There’s been a lot of comparisons with Papers, Please with a new setting, so if you liked that there’s a high chance you will enjoy this too. As for the Linux version, for me it worked without an issue. Performance was good and no noticable bugs I could see. It has some really nice art, the character design is done really well for sure and it’s not always easy to tell if someone is old enough to get in the club.

It does take a little while to get going, personally I thought the start was a bit too slow. Even so, it’s not bad at all.

Available now with Linux support on Steam.

Source

Torvalds is already more empathetic in Linux code reviews

Following a promise to address his unempathetic approach towards kernel developers, Torvalds already seems to be more considerate in code reviews.

Linux creator Linus Torvalds recently acknowledged his problems in an email to kernel developers in September.

In his email, Torvalds wrote:

“I am not an emotionally empathetic kind of person and that probably doesn’t come as a big surprise to anybody. Least of all me. The fact that I then misread people and don’t realize (for years) how badly I’ve judged a situation and contributed to an unprofessional environment is not good.

This week people in our community confronted me about my lifetime of not understanding emotions. My flippant attacks in emails have been both unprofessional and uncalled for. Especially at times when I made it personal.”

He ended the email saying he would be taking some time off to get assistance on understanding people’s emotions and how to respond appropriately.

Torvalds promised the email wasn’t him wanting to walk away from Linux development and that he ‘very much’ wants to continue working on it as he has for almost three decades.

Last week, Torvalds showed off his more empathetic approach in an issue with the HID pull request and its introduction of the BigBen game controller driver that was introduced. In particular, that it was enabled by default.

This was his response:

“We do *not* enable new random drivers by default. And we most *definitely* don’t do it when they are odd-ball ones that most people have never heard of.

Yet the new ‘BigBen Interactive’ driver that was added this merge window did exactly that.

Just don’t do it.

Yes, yes, every developer always thinks that _their_ driver is so special and so magically important that it should be enabled by default. But no. When we have thousands of drivers, we don’t randomly pick one new driver to be enabled by default just because some developer thinks it is special. It’s not.

So the default !EXPERT was completely wrong in commit 256a90ed9e46 (“HID: hid-bigbenff: driver for BigBen Interactive PS3OFMINIPAD gamepad”).

Please don’t do things like this.

Linus”

The response is firm but fair. It doesn’t come across demeaning or aggressive towards the developer, just sets them on the right course.

A response to a similar issue last November invoked the following response from Torvalds:

“You add new drivers and then default them to ‘on’.

THAT IS COMPLETELY UNACCEPTABLE.

I don’t know why I have to say this every single merge window, but let’s do it one more time:

As a developer, you think _your_ driver or feature is the most important thing ever, and you have the hardware.

AND ALMOST NOBODY ELSE CARES.

Read it and weep. Unless your hardware is completely ubiquitous, it damn well should not default to being defaulted everybody elses config.

But something like CONFIG_DELL_SMBIOS sure as hell does not merit being default on. Not even if you have enabled WMI.

EVERY SINGLE “default” line that got added by this branch was wrong.

Stop doing this. It’s a serious violation of peoples expectations. When I do ‘make oldconfig’, I don’t want some new random hardware support.”

So far, it seems Linus’ time off (which is well earned) has done his people skills a world of good. There’s less of his profanity-ridden messages and general lack of professionalism when it comes to communicating with developers.

For most of us, it’s good to see. For Linux kernel developers, it’s well overdue.

Source

WP2Social Auto Publish Powered By : XYZScripts.com