Display Your Linux System Information

Moving to a new operating system (whether it's Windows, the Mac or a Linux OS that's new to you) it's often difficult to find what you are looking for, at first. Take finding a list of your system hardware for example. In Windows, if you want a graphical display of the specs for your computer, you right-click on the My Computer icon and select Properties. I imagine that's not very intuitive if you have only ever used a Mac. Linux, too, has graphical tools to display information about your computer's hardware. With a KDE distribution, there is KInfoCenterunder the System menu. Under Gnome, there is a utility called SysInfo that does a similar thing. SysInfo is not installed by default in some distributions, like Ubuntu, but it is available in the package repositories. Just use your package manager to install it.

These graphical methods present a nice browsable list of information, but with a terminal and a few commands, you can really dig under the hood of your Linux computer's hardware. The remainder of this discussion describes how to use the command line to reveal some information stored in text files on your hard drive and, for the big finish, how to get all of your system information--all at once--by typing a single line of text into the terminal!

Under the hood, Linux is Linux. The various distributions of Linux have different applications and utilities packaged with the OS by default, different package managers, different window managers/desktop environments, different artwork, etc. Some actually implement the system structure in different ways (like installing applications in one system directory vs. another) but when it comes right down to it, they are pretty much all the same. The user experience can be very different with each distribution, however, because of the different "packaging." And that can be confusing to a new user. But underneath the outer layer is still the Linux kernel. The command line is where it all comes together, and that is where you can get your system specs most completely.

Display your system info using cat
Here are some ideas and resources regarding how to display some of the statistics for your computer''s hardware and software using the command line. The list below contains some commands you can type into the terminal (or copy and paste if you prefer) that show some of the system information that is stored in text files on your system. You may not be that familiar with the command line, so let us start with a definition of some of these commands:

cat: takes the text contents of a file or files and displays it in the terminal window

grep: searches for a specific passage of text within a larger body of text

| (the vertical bar): tells the command line to take the output of the command to the left of the bar, and use it as input for the command to the right of the bar.

Useful commands: (Note that these should work regardless of your Linux distribution or window manager.)
CPU info:

cat /proc/cpuinfo
cat /proc/cpuinfo | grep 'model name'
Memory info:
cat /proc/meminfo
cat /proc/meminfo | grep MemTotal
cat /proc/meminfo | grep MemFree
Storage info:
cat /proc/partitions

You'll find more commands like this in these two references from FOSSWire:
Command Cheat Sheet 
Ubuntu Cheat Sheet 

The "list hardware" command
Now... we've saved the best one for last. The command, lshw, is the "list hardware" command. You can type it at the command line without any switches or options, but the text file it generates runs on forever, and is a little difficult to follow in the terminal. It needs to run as root, hence the "sudo" in front of it. The command listed below runs lshw with the -html option to create an html file--usually in your home directory. Open it in a browser and you have a nice "web page" with all of your hardware specs.

sudo lshw -html>myhardware.html

When I ran it, this command even detected the mini-SD card on the BlackBerry phone I have charging on a USB port!

[ Read More ]

Connecting Your Linux Browser To Computer America's Chat

Since I have begun my regular appearances on the Computer America Radio show, I frequently run across Linux users who have trouble connecting to the Java-enabled chat room provided by addonChat. This article outlines what you need to get your Linux computer (using the Firefox browser or equivalent) to connect to the site's addonChat chat room.

Why is there a problem?

The addonChat software is apparently a little picky about the version of Java your browser uses. The version of Java installed automatically by many Linux distributions is not the commercial version provided by Sun Microsystems, but is rather a free open source version. In an attempt to keep their distributions "pure" and untainted by commercial and proprietary software, many Linux distributions install only software that has no licensing restrictions. Many of these distributions, like Ubuntu, have that "restricted" software available in third party or community-maintained repositories.

What you need to make Java chat work with Linux

The addonChat chat software seems to work best if your Firefox browser is using the non-free Sun version of Java. It works on Windows because that's what is installed by default with that operating system. You can install this version of Java on a Linux computer, using your package manager. In Ubuntu, Kubuntu and other official Ubuntu variants, you will need to first enable the "Multiverse" repository, then search for and install the following packages:

  • java-common
  • sun-java5-bin
  • sun-java5-jre
  • sun-java5-plugin
  • sun-java6-bin
  • sun-java6-jre
  • sun-java6-plugin
Many other distributions will also offer these packages in their official or community software sources.

Proprietary software is not bad 

If you are using an Ubuntu-based distribution of Linux, you can easily install these packages -- all at once -- by installing the single package named "ubuntu-restricted-extras." This package installs the Sun Java packages along with other commonly used restricted packages.

The term "restricted" does not mean unreliable or illegal. From an open source perspective, restricted software is simply software that is commercial, proprietary, or otherwise encumbered by licensing restrictions (like DRM or copyright) that limit its distribution. Bear in mind that users of Windows install software every day. Whether that software is purchased, shareware or freeware, it is (more often than not) what the open source community would call "restricted software."

Installing Sun Java (Ubuntu example)

Ubuntu provides the Synaptic Package Manager and Kubuntu provides the Adept Package Manager for installing new software packages. Synaptic is available from the SystemAdministration menu. Adept is available from Kubuntu's System selection in the K-Menu.

  1. After launching Adept or Synaptic, enable the Universe and Multiverse repositories. (How to: UbuntuKubuntu)
  2. Now you will be able to search for the package "ubuntu-restricted-extras".
  3. Right-click the package that you want to install and choose Mark for Installation. (Request Install for Kubuntu.)
    Install the ubuntu-restricted-extras package
  4. Click the Apply or Apply Changes icon in the toolbar and your installation begins.
Other help for addonChat
For help on how to use the features of addonChat, whether on Computer America's site or another site that uses the service, you can get to the help documentation at http://help.addonchat.com.

[ Read More ]

Get to know GCC 4

In the last few years, the GNU Compiler Collection (GCC) has undergone a major transition from GCC version 3 to version 4. With GCC 4 comes a new optimization framework (and new intermediate code representation), new target and language support, and a variety of new attributes and options. Get to know the major new features and their benefits.

GCC is the cornerstone of development in both the open source and closed source worlds. It's the enabler of architectures and operating systems. When a new processor appears, its success depends on a version of GCC that will support it (a back end that can generate code for it). GCC is also the enabler of Linux®. Linux as an operating system is widely successful because it is run on so many different architectures. Once again, a port of GCC to the target environment enables Linux to be ported and run on it. Without trying to put too fine a point on it, GCC paves the way for Linux and embedded development.

But GCC can't just sit still. New processor architectures continue to appear, and new research finds better ways to optimize and generate code. So GCC moves forward and has now matured into its fourth major release. This article explores the fundamental changes in GCC version 4 to show you why—if you haven't switched yet—the time has come to use the compiler standard.

Short history

GCC originally stood for GNU C Compiler when it was first released by Richard Stallman in 1987. (A historical timeline of GCC is shown in Figure 1.) Richard started the project in 1984 with the desire to build a free C compiler that could be used, modified, and evolved. GCC originally ran on early Sun and DEC VAX systems.

As an open compiler (that is, the source was freely available), others began to provide fixes and—more importantly—updates for new languages and target architectures. Not long after, its acronym was changed to mean GNU Compiler Collection, as it supported numerous languages targeted to the most popular (and esoteric) architectures.

Figure 1. A modern history of GCC releases 
Modern history of GCC releases 

Today, GCC is the most popular compiler toolchain available. The same source base can be used to build compilers for Ada, Fortran, the Java™ language, variants of C (C++ and Objective-C) and covers the largest number of target processor architectures of any compiler (30 supported processor families). The source base is also completely portable and runs on more than 60 platforms. The compilers are highly tunable, with a large number of options for tweaking the generated code. GCC, in short, is the Swiss Army knife of compilers and redefines the meaning of flexibility. It is also the most complex open source system that exists: Today, GCC is made up of almost 1.5 million lines of source code.

Wow! With all of that, you'd think I was truly enamored with GCC. Let's just say that when I'm developing software with GCC and my wife walks into the room, I feel a little uncomfortable.

Before you start

Compilers are constructed in a pipeline architecture made up of several stages that communicate different forms of data (see Figure 2). The front end of a compiler is language specific and includes a parser for the given language that results in parsed trees and the intermediate representation (the Register Transfer Language, or RTL). The back end is then responsible for using this language-independent representation and product instructions for the particular target architecture. To do this, the optimizer uses the RTL to create fast or more compact code (or both, when possible). The optimized RTL is then fed to the code generator, which produces target code.


Figure 2. Simplified view of the compiler stages 
Simplified view of the compiler stages 

Core changes for GCC 4

GCC 4 brings many changes to the standard compiler suite, the biggest of which is around support for optimizations with the introduction of the tree Static Single Assignment (SSA) form. But in general, the compiler is faster in some optimization modes and provides many new enhancements, including new target support. GCC 4 is also much more thorough when it comes to warnings and errors (in fact, certain warnings may now show up as errors with GCC 4). One drawback to GCC 4 is that it is not binary-compatible with objects built with the GCC 3 compilers (which means that source must be recompiled with GCC 4)—unfortunate, but it's the price to be paid to move forward.

Let's look at some of the key advancements introduced with the new GCC 4.

The 4.0 release series

The 4.0 release (4.0.4 being the last in the series) is the first step into GCC 4. As such, it was not recommended for production development until a stabilization process could be completed. This release included a large number of changes—two in particular being the introduction of a new optimization framework (Tree SSA) and support for autovectorization.

Prior to GCC 4, the intermediate representation used was called Register Transfer Language (RTL). RTL is a low-level representation very close to assembly language (inspired by LISP S-expressions). The problem with RTL is that the optimizations it enables are those close to the target. Optimizations that require higher-level information about the program may not be possible, because their expression is lost in RTL. Tree SSA is designed to be both language independent and target independent while supporting improved analysis and richer optimizations.

Tree SSA introduces two new intermediate representations. The first is called GENERIC, which is a generic tree representation that's formed from the language front-end trees. The GENERIC trees are converted into GIMPLE form and a subsequent control flow graph to support SSA-based optimizations. Finally, the SSA trees are converted into RTL, which the back end uses for target code generation. An overly simplified description, but the result is a new intermediate form better suited for high- and low-level optimizations. (See Resources for more details on this process.)

As the changes really represent a new framework, it's possible to define new optimizations. Several new optimizations have been implemented to date, but more work is obviously ahead to ensure that GCC generates the most compact and efficient code possible.

Another interesting change for GCC 4 is the addition of a loop vectorizer (based on the Tree SSA framework). Autovectorization is a feature that allows the compiler to identify scalar processing loops within code that can benefit from vector instructions available in the target processor. The result is tighter and more efficient target code. Another loop-based optimization is Swing Modulo Scheduling (SMS), which is used to construct instruction pipelines with the goal of minimizing cycle counts by exploiting instruction-level parallelism. More information on each of these new approaches is available in Resources.

Finally, the 4.0 series also introduced (in addition to many C and C++ changes) a new Fortran front end that supports Fortran 90 and 95 (rather than the older Fortran 77, which was supported in GCC 3). New Ada 2005 features can also be found as well as support for Ada features on many more target architectures.

The 4.1 release series

With the new optimization framework in place, the 4.1 release series introduced a larger number of optimizations, such as improved profiling support and more accurate branch probability estimation. Two of the more useful optimizations are better inline support and the ability to exploit the instruction cache locality. When functions are to be inlined, the compiler no longer inlines functions that are not executed frequently. Instead, hot call sites are more likely to be inlined to keep the code size small while still getting inline function benefits. GCC can also help to partition functions into hot and cold sections. Keeping hot functions together (that is, those functions that are used more often) results in better instruction cache use compared to polluting the cache with cold functions.

The front end saw a number of updates, including support for Objective-C++. There were also a very large number of updates for the Java core library (libgc). The back end saw the introduction of support for the IBM® System z™ 9-109 processor, including 128-bit Institute of Electrical and Electronics Engineers (IEEE) floating point numbers and atomic memory access built in. If that weren't enough, the back end can now emit code to protect against stack-smashing attacks (that is, buffer overflow detection and reordering to protect against pointer corruption). Some built-in functions have also been updated to protect against buffer overruns with a minimal amount of overhead.

The 4.2 release series

The 4.2 release series continued with new optimizations and enhancements that covered both languages and processor architectures. The back end was updated to include support for Sun's UltraSPARC T1 processor (codenamed Niagara) as well as Broadcom's SB-1A MIPS core.

The front end also saw changes in version 4.2 with the overhauling of C++ visibility handling and support for Fortran 2003 streaming input/output (I/O) extensions. But one of the most interesting changes in the 4.2 release was the addition of OpenMP for the CC++, and Fortran compilers. OpenMP is a multi-threading implementation that allows the compiler to generate code for task and data parallelism.

Using one aspect of OpenMP, code is annotated with areas in which parallelism should occur using preprocessor directives. The code is converted into a multi-threaded program for the duration of block, then joined back together as each thread within the block finishes.

Figure 3 provides a look at how this process works in practice. OpenMP provides not only a set of pragmas (that is, preprocessor directives) but also functions for CC++, and Fortran. In Figure 3, you see a simple program that directs elements of code into multiple threads (parallelizing the for block). The effect is shown graphically in Figure 3: A traditional program would execute the loop sequentially, whereas the OpenMP implementation creates threads to parallelize the for block. You can learn more about OpenMP in Resources.


Figure 3. Simple example of OpenMP support 
Simple example of OpenMP support 

The 4.3 release series

The current release series in GCC 4 is 4.3. This release series shows an acceleration of features and supported architectures (as well as unsupported architectures, as many obsolete architectures and ports have been removed). New language support was added for Fortran 2003 as well as a host of general optimizer improvements.

New processors supported in this release include several in the Coldfire processor family, the IBM System z9 EC/BC processor, the Cell broadband engine architecture's Synergistic Processor Unit (SPU), support for SmartMIPS, and numerous others. You'll also find compiler and library support for Thumb2 (compressed ARM instructions) and for the ARMv7 architecture as well as tuning support for Core2 processors and the Geode processor family.

In the front end of the compiler, the internal representation for GIMPLE was redefined, meaning that the compiler consumes less memory.

Beyond the 4.3 release

Work has already begun on the 4.4 release series, and its moving toward a general release. In version 4.4, you'll find numerous bug fixes and more general optimizer improvements. Version 3.0 of the OpenMP specification has also been integrated for CC++, and Fortran.

The compiler will also now allow you to define an optimization level at the function level (instead of at the file level, which was the previous default). This functionality is provided by theoptimize attribute, which also allows you to specify the individual options for the optimizer.

Finally, processor support was added for the Picochip, which is a 16-bit multi-core processor. What's interesting about the Picochip is that each core can be programmed independently, with communication provided in a mesh.

What's ahead?

The future is obviously bright for GCC. The toolchain continues to evolve—both architecturally and incrementally—to support the latest in processor architectures. You'll also find that the language landscape is well covered by GCC. Under development is support for a number of different languages, such as Mercury, GHDL (a GCC front end for VHDL), and the Unified Parallel Clanguage (UPC).

In addition to GCC's bright future, its continued improvement means benefits for all types of software (from Linux and Berkeley Software Distribution [BSD] to Apache and everything in between). Software compiled with GCC 4 will be generally more compact and faster, meaning software industry goodness all around.

By M. Tim Jones, Consultant Engineer, Emulex Corp.

[ Read More ]

Advantages of Linux

Like most IT managers, you face a choice when it comes to operating systems. Not long ago, you might have turned to Windows, Solaris or UNIX, but now Linux has your undivided attention. Why is Linux—an open source operating system—seeing such rapid adoption and growth? More importantly, why should you consider it for your own growing business? Compared to other platforms, Linux offers:

  • Maximum flexibility
  • Lower costs
  • Tight security
  • Powerful performance
  • Ongoing innovation

In organizations large and small, Linux is becoming the clear choice for enterprise computing.

Maximum Flexibility

Flexibility is a key element of every IT manager's decision-making process. You need options and choices so your growing businesscan remain agile in times of rapid change. Linux gives you many choices that other operating systems cannot provide. With Linux you can:

  • Choose a commercial distribution or download a free one
  • Choose your Linux vendor (if you opt for a commercial distribution)
  • Choose your hardware vendor(s)
  • Purchase support from a vendor or access free support via the Internet
  • Modify source code to more closely suit your needs

Linux also plays well with other systems, which gives you added flexibility. You can deploy high-performance Linux servers with your existing systems. It's easy: you just run Linux on the back end and switch to low-cost commodity hardware. It's also completely flexible: you can continue using familiar desktops (so there's no learning curve for your users), and you can save money on both hardware and server licensing.

Lower Costs

Compared to proprietary software, Linux saves you money—lots of it. You can either download Linux free of charge from the Internet or purchase a supported Linux distribution from a vendor for a low subscription price. This price typically includes maintenance, meaning that you get patches, security updates and new releases of Linux as part of your subscription fee.

When you choose Linux, you do not have to pay exorbitant fees for a service like Microsoft Software Assurance, which promises its customers maintenance and new releases of Windows or other Microsoft software (that may not ship for years). In cost comparisons with Solaris and Windows operating systems (link to the competitive papers), Linux is the obvious winner. You can also defray application costs by choosing from thousands of open source applications that run on Linux.

For Linux support, you can contact your current Linux vendor, engage a third-party support provider, or search the Web for the specific patches and updates you need.

Tight Security

Linux is inherently more secure than Windows because of its modular design. This means that attackers cannot gain access to the operating system via user permissions or other application "back doors." Linux also has the support of the entire open source community. Any potential security problems are resolved swiftly and definitively.

Powerful Performance

When Linux is compared to other x86 and x86-64 based operating systems (such as Solaris on x86 and Windows) on industry standard benchmarks such as TPC-C, TPC-H, SPECweb2005, and SPeCjbb2005, it consistently comes out on top. In fact, many hardware vendors use Linux, when seeking leading benchmark results—and they often choose SUSE® Linux Enterprise Server from Novell.

Ongoing Innovation

Some of the largest and most reputable firms in the IT industry and the most talented individual software engineers contribute to Linux—that is the nature of open source. Innovation in the source code happens quickly, keeping pace with advancing technology more effectively than UNIX or Windows. In fact, the time between major releases of commercial Linux distributions is about 18 months—much shorter than that of other operating systems.

A Clear Choice

Why Linux? It's the clear choice for today's businesses because it provides:

  • The best innovation of any commercial operating system
  • Unparalleled flexibility
  • Performance that is comparable to or better than that of UNIX
  • Freedom from vendor lock-in
  • Lower total cost of ownership via high-performance industry-standard hardware
  • Top levels of security
  • Enterprise-class scalability on more architectures than any other commercial operating system—x86, x86-64, PowerPC, Itanium 2 and z9 mainframes
  • Compatibility with thousands of ISV applications

It's time to harness the flexibility, low cost and high performance of Linux for your organization.

[ Read More ]

What is Linux?

What Is Linux?

Linux is a computer operating system, like Microsoft Windows® or the Apple Mac OS (the Linux "desktop" or main screen, in fact, looks much like a combination of the two). Linux is most widely known among corporate computer users because of its quality, reliability, and price. Linux has matured to the point where it is now the preferred platform for most of the world's more robust and critical computer systems. Because of the robust Linux programmer community, there are several “flavors” of Linux (known as “distributions”), each specialized in slightly different way.

Who Created Linux?

In 1991, Linus Torvalds, a student at the University of Helsinki in Finland, started to write a computer operating system. By releasing early versions of the software under a “public” license, Torvalds provided an environment for many other programmers to work together to improve his software, which became known as Linux. It was this commitment to freely available software code, in combination with similarly free programming tools written by Richard Stallman from MIT, that allowed Linux to rapidly become the main alternative to proprietary operating systems.

What is Free and/or Open Source Software?

Software that is developed openly by a community of programmers may look like a chaotic process close-up, but produces extremely stable results long-term--comparable to the processes of democracy and open-market economies. Linux is just one example of thousands of computer programs that have been “copy-lefted,” a licensing process that immediately puts the program's code into the public domain while at the same time guaranteeing it will stay publicly available. (Sometimes called “share and share alike”). The GNU General Public License, originally written by Richard Stallman, is the most popular of this type of license. The different movements which are generally referred to as “Free and Open Source Software” are motivated by both altruism and pragmatism; by a belief that the ability to work together to create and build upon computer code benefits both the programmer (who can produce better software by not having to start from scratch) and the ultimate users of the software (who get better software). Recent studies have shown open-source software to have many fewer coding errors than proprietary software because of the process of peer review that takes place in the development process. The most widely known example of an Open Source software program is the Apache web server software, which runs over 70% of the world's websites. Which Distribution of Linux should I use? Unfortunately, this isn't as simple as explaining what a distribution is. We can't really tell you which distribution you should be using, for a couple of reasons; it really all depends on your personal preferences, and what you want to get done. Some distros, like Red Hat Enterprise Linux and SUSE Linux Enterprise Server are designed primarily for companies that use Linux on servers. Some distros, like Fedora Core, Ubuntu, and openSUSE have different profiles that are suitable for use on the desktop or on the server. If you ask 20 Linux users which distro you should use, you're likely to get several different answers -- and they're all right, at least for those users. The nice thing is that most Linux distributions are free, and you can download each one and test them to see if they fit your needs.

Can I run my Windows programs under Linux?

If you're coming from a Windows background, and most people are, you might have some Windows programs that you really want to keep using even when you're using Linux. Windows programs will not run natively on Linux, but you can find a few solutions to run Windows apps under Linux or within a Linux session if you really need to do so. Wine is one option for running Windows apps under Linux. Wine is an open source implementation of the Windows API for Linux and Unix operating systems. It's a compatibility layer for Windows apps, so that they can run unmodified on top of Linux. Another option is CodeWeavers CrossOver, which is based on Wine, but not entirely open source. CodeWeavers includes features not in Wine to make it easier to set up and run Windows programs under Linux. Virtualization is another option for running your Windows applications under Linux. Virtualization software like VMware Server and VMware Workstation, Parallels, and Qemu will allow you to run a full instance of Windows under Linux -- so you can run almost any Windows program unmodified on top of Linux, within the Windows environment. (Some applications that require 3D support may not run under virtualization because virtual machines typically do not provide 3D graphics.)

[ Read More ]