Home Blog Page 348

​Google Doubles Down on Linux and Open Source

Google couldn’t exist without Linux and open-source software. While you may not think of Google as a Linux company in the same way as you do CanonicalRed Hat, or SUSE, it wouldn’t be the search and advertising giant it is today without Linux. So, it makes sense that Google is moving up from its Silver membership in The Linux Foundation, to the Platinum level.

With this jump in status, Google gets a seat on the Foundation’s board of directors. This position will be filled by Sarah Novotny, the head of open source strategy for Google Cloud Platform. Novotny is a self-confessed geek. She has a long history of bridging the gap between the business world and the tech world. Before coming to Google, where she also heads the Kubernetes community, she was head of developer relations at NGNIX and program chair for the O’Reilly Open Source Convention (OSCon).

Read more at ZDNet

Linux netstat Command Tutorial for Beginners (8 Examples)

If you are new to Linux command line, and are interested in learning networking stuff, there are many command line utilities that you should be aware of. One such tool is netstat. In this article, we will discuss this command using some easy to understand examples.

But before we do that, it’s worth mentioning that all these examples have been tested on an Ubuntu 16.04 LTS machine.

Linux netstat command

The netstat command lets you print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. Following is its syntax:

netstat [OPTIONS]

Read more at HowtoForge

4MLinux: More Than Just Another Lightweight Distro

I don’t want to get up on yet another “Here’s another lightweight Linux distribution to revive your aging hardware” soapbox. So many distributions make that promise, and most of them do an outstanding job of fulfilling their mission statement. Also, many of those distributions are fairly similar: They offer a small footprint, work with 32-bit systems, and install a minimal amount of software dedicated to the task of helping you get your work done as best a lightweight operating system can do.

But then there’s 4MLinux. This particular take on the lightweight Linux distribution is a different beast altogether. First and foremost, 4MLinux doesn’t include a package manager. That’s right, the only way you can install packages on this distribution is to do so from source (unless you install the limited number of packages from within the Extensions menu (more on that in a bit). That, of course, can lead to a dependency nightmare. But if you really give it some thought, that could be a serious plus, especially if you’re looking for a distribution that could be considered an ideal desktop for end users with specific use cases. If those users only need to work with a web browser, 4MLinux allows that while preventing users from installing other applications.

What’s in a name?

The name 4MLinux comes from a strong focus on the following “Ms”:

  • Maintenance — 4M can be used as a system rescue Live CD.

  • Multimedia — 4M offers full support for a large number of image, audio and video formats.

  • Miniserver — 4M includes DNS, FTP, HTTP, MySQL, NFS, Proxy, SMTP, SSH, and Telnet servers.

  • Mystery — 4M includes a collection of classic Linux games.

It is the inclusion of servers that makes 4MLinux stand out above the lightweight competition. On top of that, the distribution goes out of its way to make the managing of these servers pretty simple (more on that in a bit).

Let’s install 4MLinux and see take a look at what it has to offer.

Installation

The installation of 4MLinux is a bit more complicated than many other distributions in its class. When you boot the live CD/USB, you must first create a partition it can be installed on. To do that, click the start button > Maintenance > Partitions > GParted. I installed 4MLinux as a VirtualBox VM. In order to do that, I had to first create a partition table on the virtual drive. Do this by clicking Device > Create Partitions Table (Figure 1).

Figure 1: Creating a partition table on the VirtualBox virtual drive.

Once the partition table has been created, click the New button and create a partition that can house 4MLinux (Figure 2).

Figure 2: Creating a new partition for 4M Linux.

With the partition created, go to Start > 4MLinux > Installer. This will open a terminal window. When prompted, hit the Enter key on your keyboard and then select the partition to use for the installation (Figure 3).

Figure 3: Most likely, the partition you want will be sda1.

You will then need to answer two questions:

  • Is 4MLinux to be the only operating system in your PC y/n

  • Do you wish to start the installation right now y/n

After you type “y” to start the installation, 4MLinux will install (a process that takes less than 5 minutes). When you see “Done” presented, close the window and reboot the system. Upon reboot, you will be prompted (in a text-only window) to create a root password (Figure 4).

Figure 4: Creating a root password.

Creating a standard user

Naturally, you don’t want to run 4MLinux as a standard user. Of course, you won’t find a GUI tool for this, so open the terminal window and issue the command adduser USERNAME (Where USERNAME is the name of the user). After typing (and verifying) a password for the new user, you can log out and log back in as that user.

The Desktop

4MLinux employs Joe’s Window Manager (JWM). It’s actually quite a lovely little desktop, one that includes all the features you’d want for easy interaction. There’s a panel, a start menu, launchers, desktop icons, a dock, a system tray, a mouse menu (Figure 5), and, for good measure, Conky (the lightweight, themeable system monitor).

Figure 5: The 4MLinux desktop includes a handy mouse menu that is accessible from anywhere on the desktop.

Applications

Out of the box, you won’t find much in the way of productivity tools. And even though there isn’t a package manager, you can install a few tools, by way of the Start > Extensions menu. Click on that menu and you’ll see entries like LibreOffice, AbiWord, GIMP, Gnumeric (Figure 6), Thunderbird, Firefox, Opera, Skype, Dropbox, FileZilla, VLC, Audacious, VirtualBox, Wine, Java, and more.

Figure 6: Installing the available apps in 4MLinux.

Click on one of those entries and a terminal window will open, asking if you want to continue. Type y and hit Enter. The package will be downloaded and installed. Once installed, the package is started from the same Extensions menu entry used for installation.

Miniserver

Let’s talk about that Miniserver menu entry. If you open that menu, you’ll find entries for StartAll, StopAll, Settings, Tests, and MiscTools. If you click the StartAll entry, all of the included servers will start. Once they’ve started, click on Miniserver > Settings > LAMP. This will open up the default web browser (Chromium) to a page allowing you to select from LAMP Admin, Webmin, or Help. Out of the box, Webmin is not ready to be used. Before you can log into that powerful tool, you must first open up a terminal window and issue the command webmin. This will download and install Webmin on the machine. You’ll have to answer a few questions (Figure 7) and create a password for the Webmin admin user.

Figure 7: Installing Webmin on 4MLinux.

Once you’ve installed Webmin, you can click Start > Miniserver > Settings > LAMP and, when presented with the available links, click the Webmin entry. You’ll be required to log in with the user admin and the password you created during the Webmin installation. You can now administer your LAMP server (and quite a bit more) from within an all-too familiar web GUI.

Is 4MLinux for You?

4MLinux is a very intriguing distribution that’s really hard to classify. It offers the best of a few worlds and misses out on the best of others (such as a traditional package manager). It’s one of those distributions that might never wind up your go-to, but it is certainly one you need to experience first hand. And, who knows, you might find this unique flavor of Linux just right for you.

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

Raspberry Pi 3 B+ Tops Hacker Board Survey

The Raspberry Pi 3 Model B+ won our 2018 reader survey as the most popular community-backed, Linux/Android hacker board under $200. The survey, run in partnership with LinuxGizmos.com, asked readers to select their favorite boards from among 116 community-backed SBCs that run Linux or Android and sell for under $200. All 116 SBCs are summarized in LinuxGizmos’ recently updated hacker board catalog and feature comparison spreadsheet. (Downloadable versions of the spreadsheet may be found here.)

The sample of 683 fell far short of the 1,705 survey respondents for the June 2017 survey and the 1,721 voters in 2015, but it beat out the 473 total for the 2016 survey. Considering the modest sample, the survey may not be highly representative of market share, but it’s still indicative of enthusiasm.

To rank the boards, we used Borda Count scoring, in which we tripled the number of first choices, then doubled the number of second place selections, and added the two results to the unadjusted third-choice amount. The top 10 boards are shown in the chart below:

The Raspberry Pi 3 Model B+, which builds upon the RPi 3 Model B design with a faster Broadcom SoC, faster WiFi and Ethernet, and optional PoE, earned a Borda score of 811. This was about twice the score of the second place (414) UDOO X86, which is one of the most powerful of the handful of x86 based hacker boards.

There was a big drop to the next three boards, including the Odroid-XU4 (278), the Raspberry Pi 3 Model B (277), which was last year’s runaway winner, and the tiny Raspberry Pi Zero W/WH (255). The remainder of the top 10 list includes the venerable sixth place BeagleBone Black (126) and the Raspberry Pi like Asus Tinker Board (112) and Odroid-C2 (95). The Raspberry Pi Zero (85) came in 9th and the BeagleBone Black Wireless (67) was 10th.

If you prefer a top 10 list based on first choice only, the top 7 rankings would stay the same, but the Odroid-C2, RPi Zero, and BB Black Wireless would drop lower. This would make way for the UP Squared, Odroid-N1, RockPro64, Orange Pi Zero H2+/Zero Plus 2 H3/Zero Plus 2 H5, and the Rock64, all of which had higher first-pick scores.

Although the small size of the sample makes it difficult to read too much into the rankings, two trends seem clear: First, SBCs with Raspberry Pi like dimensions and 40-pin expansion connectors continue to do well. Second, it’s tough for a new board to break into the top ranks, at least among LinuxGizmos readers. Seven of the top 10 Borda-ranked boards were also in last year’s top 10, and the RPi 3 B+ was the only top 10 board that was not available a year ago.

A few newcomers did, however, break into our 11-20 ranked group, including the RockPro64, Orange Pi Zero H2+, and DragonBoard 820c. The top 10 list also includes a board that will never see the light of day. We included the Odroid-N1 with the expectation that it would ship on time in June, but Hardkernel’s Odroid project just announced that the Rockchip RK3399 based SBC has been cancelled in favor or an Odroid-N2 model with an unnamed new SoC within 5-6 months.

Reader buying priorities and goals

In addition to asking survey participants to list their favorite boards, we asked about buying criteria and intended applications. The year-to-year consistency we’re seeing in the answers suggests that a 683 sample may be more significant than we thought. In ranking buying criteria, for example, the rankings were very similar. High-quality open source software again led the list as the top priority, while networking/wireless I/O swapped with community ecosystem for second and third places.

When asked about intended applications, home automation was again on top, but the previous second-ranked education category dropped several levels. Home multimedia and special function servers advanced to second and third place, and data acquisition and control also jumped considerably, suggesting a growing role for hacker boards in industrial settings.

In a separate question about more general usage, the maker/hobbyist segment once again led the way, but by a smaller margin. The other three categories increased, with the research and commercial categories seeing the largest gains.

Fifteen randomly selected survey participants will receive a free hacker board in the coming weeks. Many thanks to all the participants who voted, as well as the vendors who donated boards.

Join us at Open Source Summit + Embedded Linux Conference Europe in Edinburgh, UK on October 22-24, 2018, for 100+ sessions on Linux, Cloud, Containers, AI, Community, and more.

Open Source Developers Improve Networking, Storage and More in Kubernetes Update

The open source Kubernetes container orchestration project this week shipped its second release of the year, with improvements to networking, storage and more.

Kubernetes, under direction of The Linux Foundation, focuses on automating deployment, scaling and management of containerized applications.

Kubernetes 1.11, announced yesterday (June 27), includes several new features, with project backers especially highlighting two features that have graduated to general availability: IPVS-based In-Cluster Load Balancing and CoreDNS as a cluster DNS add-on option. The release team said these result in increased scalability and flexibility.

“IPVS (IP Virtual Server) provides high-performance in-kernel load balancing, with a simpler programming interface than iptables,” the team said in a blog post.

Read more at ADT mag

Linux Apps on Chrome OS Coming to 18 More Chromebooks

Eighteen more Chromebooks are getting support for Linux apps on Chrome OS, with laptops based in Intel’s Apollo Lake architecture now able to run the applications, via XDA Developers.

That list includes computers from Lenovo (Thinkpad 11e Chromebook), Acer (Chromebook Spin 11 and Chromebook 15), Asus (Chromebook Flip), and Dell (Dell Chromebook 11) — check the full list at XDA’s site to see if your machine is included.

Previously, Linux apps worked on the Google Pixelbook and Samsung Chromebook Plus, but support for the Apollo Lake machines should open it up to a much wider range of users — and more importantly, to a much wider range of laptop price points.

Read more at The Verge

What is SDN? How Software-Defined Networking Changed Everything

The internet began as a system for applying addresses to servers. Now it’s a means for giving names to services, and distributing those services across the planet. SDN gave rise to a new way of implementing computing on the broadest scale of infrastructure, and has become, for better or worse, the whole point of networking.

The phrase software-defined networking (SDN) was coined when it was necessary to distinguish the concept from the hardware-based variety. Since that time, “SDN” has come to mean the type of dynamic configuration that takes place whenever software-based services in a data center network are made accessible through an Internet Protocol (IP) address. More to the point, SDN is networking now….

Much of the logic for SDN is moved inside the servers’ central processor, as just another user function. Some of it is moved inside simple switch and router appliances, where software is comprised of open-source operating systems and open-source controllers. Yet all of these phenomena are the side-effects of SDN, not the purpose. These changes happen because the real purpose of SDN is to move networking logic to a place where it can be more directly controlled and managed, and even more importantly, changed to suit the dynamics of variable workloads.

THE BASIS OF SDN

Here are SDN’s principal architectural tenets:

The flow of user data is separated from the flow of control instructions. In a physical network, data packets that belong to an application take the same route as internal instructions the network components need to coordinate their actions. As SDN engineers put it, the control plane is separated from the data plane. 

Read more at ZDNet

Hyperledger’s Brian Behlendorf Named as Top Blockchain Influencer by New York Times

Brian Behlendorf, Executive Director of the Linux Foundation’s Hyperledger project, has been named one of the top 10 influential voices in the blockchain world, in a New York Times commentary titled “The People Leading the Blockchain Revolution.” Blockchain technologywhich encompasses smart contracts, distributed ledgers, and more—is already transforming contracts, payment processing, asset protection, and supply chain management.

In the article, Behlendorf is credited with driving the evolution and widespread adoption of numerous essential blockchain platforms and tools.

“Mr. Behlendorf has helped bring in other big names who are helping to make Hyperledger the focus of much of the corporate and governmental interest in blockchains today,” the Times reports.

Read more at The Linux Foundation

Van Jones & Linus Torvalds to Keynote at Open Source Summit North America

We’ve announced additional keynotes at Open Source Summit North America, including:

  • Van Jones, President & Founder of the nonprofit, Dream CorpsCNN ContributorBest-Selling Author; Human Rights, Education and Clean Energy Advocate
  • Austen Collins, Founder & CEOServerless Inc.
  • Linus Torvalds, creator of Linux and Git, in conversation with Dirk Hohndel, VP & Chief Open Source Officer, VMware

View the Full Schedule >>

The event also features the Open Collaboration Conference where ecosystem leaders learn to navigate open source transformation with sessions covering compliance, community leadership and open source program office management in the new TODO track. The Diversity Empowerment Summit is also featured, which highlights the ways in which the community can benefit from expanding diversity and inclusion practices.

Register now to save $150 through July 21.

Register Now >>

Read more at The Linux Foundation

Stack vs Heap. What’s the Difference and Why Should I Care?

I’m four months into the curriculum at Holberton School and we’ve solved multiple problems using the malloc, realloc, calloc and free functions in the C programming language. What better way to build a solid foundation of how memory gets allocated then to write a technical post on the stack versus the heap?

This article explains in depth:

What are the five segments of memory?

What is the stack?

What is the heap?

How does understanding the two make you a better software engineer?

What are the five segments of memory?

When we write applications, files, or any logic that is typed in an editor and executed on the computer, the computer has to allocate memory for the program to run. The memory that is assigned to a program or application in a computer can be divided into five parts. The amount of memory that get’s assigned to an application depends on the computer’s architecture and will vary across most devices, but the variable that remains constant is the five parts of an application’s memory which are the heap, stack, initialized data segment, uninitialized data segment, and the text segment.

 
1*8b9-Z3FV6X9SP9We8gSC3Q.jpeg

The initialized data segmentconsists of all the global and static variables that are initialized when a file gets compiled. The uninitialized data segment consists of all global and static variables that are initialized to zero or do not have explicit initialization in source code.

At Holberton, most of the time we are not concerned about the uninitialized data segment because when we compile our programs with gcc, we use the flags, -Wall -Wextra -pedantic -Werror and we use an internal stylistic checker called betty which treats warning as errors when uninitialized variables are present. Having unused variables in our programs gets flagged and is not a best practice. The text segment, also known as the code segment, contains the machine instructions which make up your program. The text segment is often read-only and prevents a program from accidentally modifying its instructions.

What is the stack?

The stack is a segment of memory where data like your local variables and function calls get added and/or removed in a last-in-first-out (LIFO) manner. When you compile a program, the compiler enters through the main function and a stack frame is created on the stack. A frame, also known as an activation record is the collection of all data on the stack associated with one subprogram call. The main function and all the local variables are stored in an initial frame.

 
1*kaVuG-f-BalIfFuUNIKAPQ.jpeg

Program vs Stack usage

In the picture above, we have one stack frame on the stack that holds the main function, along with the local a, b and sum variables. After using the printf() function the frame we created along with the local variables are only accessible in memory for the duration of the frame are no longer accessible after returning the 0 value from the function.

What happens with the stack when we call multiple functions? To illustrate the stack in it’s LIFO manner, let’s solve a problem using recursion. When we call multiple functions in our application, we use multiple stack frames in a last-in-first-out approach meaning that the last stack frame we’ve created on the stack is the first stack that will be released after the function is done executing its logic. Let’s go over an example of printing out the name “Holberton” recursively and show how our code affects the stack memory segment.

 
1*fZ1fDQAm5vDjc5TOCHH2mg.jpeg

Yes, I have a whiteboard on the back of my door at my house.

When we compile our code using gcc _putchar.c 0-puts_recursion.c 0-main.c , the compiler enters our program through int main(void) and creates a frame with the function int main(void) and _puts_recursion("Holberton") living on that frame as illustrated on the image above. When the compiler runs into the _puts_recursion() function, it calls that function and creates another stack frame on top of the previous stack frame where int main(void) lives. We are now in our second stack frame in our program and have entered in the _puts_recursion(char *s)function where *s is equal to 'H' and is only accessible in that stack frame. Because 'H' does not equal '' , we will continue with our function calls and execute the _putchar('H') function and enter into the same function _puts_recursion(++s). The argument ++s moves the memory address of the *s one byte because the size of a char is 1 byte on our machine, and now _puts_recursion is calling the function as _puts_recrusion('o') . Each time the _puts_recursion function is called, a new stack frame is put on the stack until we hit the terminating condition which is if (*s == '').

Every time a new stack frame is created, the stack pointer moves with it until it reaches the terminating condition. A stack pointer is a small register that stores the address of the last program request in a frame. When we hit the terminating condition, we execute our logic, then start to unwind the stack or pop off stack frames in the last-in-first-out manner until we reach out return(0) logic in the int main(void) function in our first stack frame.

If you don’t have a terminating case for the recursive example above, the stack will continue to grow in size adding additional stack frames on-top of each other, moving the stack pointer upward on each call, against the heap, which will be explained in the next section. In a recursive function , if there is no valid terminating condition, the stack will grow until you’ve completed consumed all the memory that’s been allocated for your program by the operating system. When the stack pointer exceeds the stack bound, you have a condition called stack overflow. Bad things happen when you have a stack overflow.

Let’s first refer back to the other four segments of your application’s memory which were the uninitialized and initialized data segments, text segment and stack segment. These four segments have a constant memory size during compilation. The memory size for these four segments is predetermined by your operating system before compiling your programs. When software engineers write programs that consume large amounts of memory from a machine, they have to consider where and how much memory is being consumed in their application.

The max stack size is constant and predetermined before a program is compiled. At Holberton, we use a Linux Ubuntu/Trusty64 distributions. To find information about the stack size and other neat limits, type the command below into your terminal.

ulimit -a

Where ulimit is a function that gets and sets user limits and the -a flag lists all the current limits.

 
1*Pj0uHasm_IcsBiXIaw5qRQ.jpeg

Stack size is 8.192MB of memory.

If the stack is limited in size and a program needs more memory for it to execute, where can a software engineer pull memory from for his/her application? This is where the heap comes into play.

What is the heap?

The heap is the segment of memory that is not set to a constant size before compilation and can be controlled dynamically by the programmer. Think of the heap as a “free pool” of memory you can use when running your application. The size of the heap for an application is determined by the physical constraints of your RAM (Random access memory) and is generally much larger in size than the stack.

We use memory from the heap when we don’t know how much space a data structure will take up in our program, when we need to allocate more memory than what’s available on the stack, or when we need to create variables that last the duration of our application. We can do that in the C programming language by using mallocrealloccalloc and/or free. Check out the example below.

 
1*1aNsjN93vpK6Nk4qn2mZtw.jpeg

Allocating 4000 bytes of memory to our program, then releasing it.

We allocate memory from the heap using the malloc() function. The argument we want to include in malloc is the amount of memory we want to allocate to our application, in bytes. Malloc returns a void pointer that is type casted into an integer pointer that now points to the first address in memory for our 4000 byte long memory. We can now store information in those memory addresses and do as we please to that information for the duration of our program or for the duration of our function because we have a pointer that references the first memory address from the newly allocated heap memory.

If you aren’t intentionally creating variables that last the duration of your application from the heap, you always want to release the memory back to the machine using the free() function. If you don’t release the memory using the free() function, you have memory that will persist throughout your program. If we do not release the memory from our program before terminating the application, our application has memory leaks. If your application has enough memory leaks, it can consume more memory than is physically available and can cause programs to crash. This is why we use a program called valgrindValgrind is easy to use and checks for memory leaks.

 
1*zj8eF7EIaMZcThlk9TcPmA.jpeg

Valgrind being used. 4,000 bytes allocated. 0 bytes leaks

Another thing to consider while using the heap, the pointer variables created on the heap are accessible by any function, anywhere in your program, as long as the memory is still persistent and hasn’t been free.

How does understanding the stack and heap make you a better software engineer?

If you understand the advantages and disadvantages of using the stack vs the heap for your application, then it gives you a strategic advantage for creating scalable programs. You, the programmer, have to decide when to use memory from the stack vs heap based on each problem you are trying to solve.

If you have a variable like an array or struct that needs to be stored in a large block memory, needs to persist throughout the lifetime of your application and could change in size throughout the duration of your program, then you should allocate it from the heap.

If you need to create helper functions with variables that only persist within the lifetime of the function, then you should allocate memory from the stack. Memory from the stack is easier to keep track of because the memory is only locally available in the function call which does not persist after the function is completed and is managed by the CPU.

 
1*mVBw2A1Ybu1pedo_7IFs_w.jpeg

Photo credit: Gribble Lab

Questions, comments or concerns, feel free to comment below, follow me or find me on Twitter @ NTTL_LTTN.

References:

My Code School. (February 23rd, 2013). Pointers and dynamic memory — stack vs heap. . Retrieved from https://www.youtube.com/watch?v=_8-ht2AKyH4

Paul Gribble (2012). C Programming Boot Camp — 7. Memory: Stack vs Heap. [Blog post]. Retrieved from https://www.gribblelab.org/CBootCamp/7_Memory_Stack_vs_Heap.html#orgheadline1

GeeksforGeeks. Memory Layout of C Programs. [Blog post]. Retrieved from https://www.geeksforgeeks.org/memory-layout-of-c-program/

Sandra Henry-Stocker. (November 18th, 2012). NETWORK WORLD — Setting limits with ulimit. [Blog post]. Retrieved from https://www.networkworld.com/article/2693414/operating-systems/setting-limits-with-ulimit.html

Valgrind Developers (2000–2017). Valgrind. Retrieved from http://valgrind.org/

Die.net Linux Documentation. Retrieved from https://linux.die.net/