The Linux kernel can run a wide variety of software across many hardware platforms. A computer can act as a server, which means it primarily handles data on other’s behalf, or can act as a desktop, which means a user will be interacting with it directly. The machine can run software or it can be used as a development machine in the process of creating software. You can even run multiple roles as there is no distinction to Linux about the role of the machine; it’s merely a matter of configuring which applications run.
One advantage of this is that you can simulate almost all aspects of a production environment, from development, to testing, to verification on scaled down hardware, which saves costs and time. As someone learning Linux, you can run the same server applications on your desktop or inexpensive virtual server that are run on a large Internet Service Provider. Of course, you will not be able to handle the volume a large provider would, as they will have much more expensive hardware. But you can simulate almost any configuration without needing powerful hardware or server licensing.
Linux software generally falls into one of three categories:
- Server software – software that has no direct interaction with the monitor and keyboard of the machine it runs on. Its purpose is to serve information to other computers, called clients. Sometimes server software may not talk to other computers but will just sit there and "crunch" data.
- Desktop software – a web browser, text editor, music player, or other software that you interact with. In many cases, such as a web browser, the software is talking to a server on the other end and interpreting the data for you. Here, the desktop software is the client.
- Tools – a loose category of software that exists to make it easier to manage your system. You might have a tool that helps you configure your display, or something that provides a Linux shell, or even more sophisticated tools that convert source code to something that the computer can execute
Additionally, we will consider mobile applications, mostly for the benefit of the LPI exam. A mobile application is a lot like a desktop application but it runs on a phone or tablet instead of a desktop computer.
Any task you want to do in Linux can likely be accommodated by any number of applications. There are many web browsers, many web servers, and many text editors (the benefits of each are the subject of many UNIX holy wars). This is no different than the closed source world. However, a benefit of open source is that if someone that doesn’t like the way their web server works, they can start building their own. One thing you will learn as you progress with Linux is how to evaluate software. Sometimes you’ll go with the leader of the pack, sometimes you’ll want to look over the bleeding edge.
1 Server Applications
Linux excels at running server applications because of its reliability and efficiency. When considering server software, the most important question is “what service am I running?” If you want to serve web pages, you will need web server software, not a mail server!
One of the early uses of Linux was for web servers. A web server hosts content for web pages, which are viewed by a web browser using the Hypertext Transfer Protocol (HTTP) or its encrypted flavor, HTTPS. The web page itself can be static which means that when the web browser requests the page the web server just sends the file as it appears on disk. The server can also serve dynamic content, meaning that the request is sent by the web server to an application, which generates the content. WordPress is one popular example. Users can develop content through their browser in the WordPress application and the software turns it into a fully functional website. Each time you do online shopping, you are looking at a dynamic site.
Apache is the dominant web server in use today. Apache was originally a standalone project but the group has since formed the Apache Software Foundation and maintains over a hundred open source software projects.
Another web server is nginx, which is based out of Russia. It focuses on performance by making use of more modern UNIX kernels and only does a subset of what Apache can do. Over 65% of websites are powered by either nginx or Apache.
Email has always been a popular use for Linux servers. When discussing email servers it is always helpful to look at the 3 different roles required to get email between people:
- Mail Transfer Agent (MTA) – figures out which server needs to receive the email and uses the Simple Mail Transfer Protocol (SMTP) to move the email to that server. It is not unusual for an email to take several “hops” to get to its final destination, since an organization might have several MTAs.
- Mail Delivery Agent (MDA, also called the Local Delivery Agent) – takes care of storing the email in the user’s mailbox. Usually invoked from the final MTA in the chain.
- POP/IMAP server – The Post Office Protocol and Internet Message Access Protocol are two communication protocols that let an email client running on your computer talk to a remote server to pick up the email.
Sometimes a piece of software will implement multiple components. In the closed source world, Microsoft Exchange implements all the components, so there is no option to make individual selections. In the open source world there are many options. Some POP/IMAP servers implement their own mail database format for performance, so will also include the MDA if the custom database is desired. People using standard file formats (such as all the emails in one text file) can choose any MDA.
The most well known MTA is sendmail. Postfix is another popular one and aims to be simpler and more secure than sendmail.
If you’re using standard file formats for storing emails, your MTA can also deliver mail. Alternatively, you can use something like procmail, which lets you define custom filters to process mail and filter it.
Dovecot is a popular POP/IMAP server owing to its ease of use and low maintenance. Cyrus IMAP is another option.
For file sharing, Samba is the clear winner. Samba allows a Linux machine to look like a Windows machine so that it can share files and participate in a Windows domain. Samba implements the server components, such as making files available for sharing and certain Windows server roles, and also the client end so that a Linux machine may consume a Windows file share.
If you have Apple machines on your network, the Netatalk project lets your Linux machine behave as an Apple file server.
The native file sharing protocol for UNIX is called the Network File System (NFS). NFS is usually part of the kernel which means that a remote file system can be mounted just like a regular disk, making file access transparent to other applications.
As your computer network gets larger, you will need to implement some kind of directory. The oldest directory is called the Domain Name System and is used to convert a name like http://www.linux.com to an IP address like 192.168.100.100, which is a unique identifier of that computer on the Internet. DNS also holds such global information like the address of the MTA for a given domain name. An organization may want to run their own DNS server to host their public facing names, and also to serve as an internal directory of services. The Internet Software Consortium maintains the most popular DNS server, simply called bind after the name of the process that runs the service.
The DNS is largely focused on computer names and IP addresses and is not easily searchable. Other directories have sprung up to store other information such as user accounts and security roles. The Lightweight Directory Access Protocol (LDAP) is the most common directory which also powers Microsoft’s Active Directory. In LDAP, an object is stored in a tree, and the position of that object on the tree can be used to derive information about the object in addition to what’s stored with the object itself. For example, a Linux administrator may be stored in a branch of the tree called “IT department”, which is under a branch called “Operations”. Thus one can find all the technical staff by searching under the IT department branch. OpenLDAP is the dominant player here.
One final piece of network infrastructure is called the Dynamic Host Configuration Protocol (DHCP). When a computer boots up, it needs an IP address for the local network so it can be uniquely identified. DHCP’s job is to listen for requests and to assign a free address from the DHCP pool. The Internet Software Consortium also maintains the ISC DHCP server, which is the most common player here.
A database stores information and also allows for easy retrieval and querying. The most popular databases here are MySQL and PostgreSQL. You might enter raw sales figures into the database and then use a language called Structured Query Language (SQL) to aggregate sales by product and date in order to produce a report.
2 Desktop Applications
The Linux ecosystem has a wide variety of desktop applications. You can find games, productivity applications, creative tools, and more. This section is a mere survey of what’s out there, focusing on what the LPI deems most important.
Before looking at individual applications, it is helpful to look at the desktop environment. A Linux desktop runs a system called X Window, also known as X11. The Linux X11 server is X.org, which provides a way for software to operate in a graphical mode and accept input from a keyboard and a mouse. Windows and icons are handled by another piece of software called the window manager or desktop environment. A window manager is a simpler version of desktop environment as it only provides the code to draw menus and manage the application windows on the screen. A desktop environment layers in features like login windows, sessions, a file manager, and other utilities. In summary, a text-only Linux workstation becomes a graphical desktop with the addition of X-Windows and either a desktop environment or a window manager.
Window managers include Compiz, FVWM, and Enlightenment, though there are many more. Desktop environments are primarily KDE and GNOME, both of which have their own window managers. Both KDE and GNOME are mature projects with an incredible amount of utilities built against them, and the choice is often a matter of personal preference.
The basic productivity applications, such as a word processor, spreadsheet, and presentation package are very important. Collectively they’re known as an office suite, largely due to Microsoft Office who is the dominant player in the market.
OpenOffice (sometimes called OpenOffice.org) and LibreOffice offer a full office suite, including a drawing tool that strives for compatibility with Microsoft Office both in terms of features and file formats. These two projects are also a great example of how politics influence open source.
In 1999 Sun Microsystems acquired a relatively obscure German company that was making an office suite for Linux called StarOffice. Soon after that, Sun rebranded it as OpenOffice and released it under an open source license. To further complicate things, StarOffice remained a proprietary product that drew from OpenOffice. In 2010 Sun was acquired by Oracle, who later turned the project over to the Apache Foundation.
Oracle has had a poor history of supporting open source projects that it acquires, so shortly after the acquisition by Oracle the project was forked to become LibreOffice. At that point there became two groups of people developing the same piece of software. Most of the momentum went to the LibreOffice project which is why it is included by default in many Linux distributions.
For browsing the web, the two main contenders are Firefox and Google Chrome. Both are open source web browsers that are fast, feature rich, and have excellent support for web developers. These two packages are a good example of how diversity is good for open source – improvements to one spur the other team to try and best the other. As a result, the Internet has two excellent browsers that push the limits of what can be done on the web and work across a variety of platforms.
The Mozilla project has also come out with Thunderbird, a full featured desktop email client. Thunderbird connects to a POP or IMAP server, displays email locally, and sends email through an external SMTP server.
Other notable email clients are Evolution and KMail which are the GNOME and KDE project’s email clients. Standardization through POP and IMAP and local email formats means that it’s easy to switch between email clients without losing data. Web based email is also another option.
For the creative types, there is Blender, GIMP, and Audacity which handle 3D movie creation, 2D image manipulation, and audio editing respectively. They have had various degrees of success in professional markets. Blender is used for everything from independent films to Hollywood movies, for example.
3 Console Tools
The history of the development of UNIX shows considerable overlap between the skills of software development and systems administration. The tools that let you manage the system have features of computer languages such as loops, and some computer languages are used extensively in automating systems administration tasks. Thus, one should consider these skills complementary.
At the basic level, you interact with a Linux system through a shell no matter if you are connecting to the system remotely or from an attached keyboard. The shell’s job is to accept commands, such as file manipulations and starting applications, and to pass those to the Linux kernel for execution. Here, we show a typical interaction with the Linux shell:
sysadmin@localhost:~$ ls -l /tmp/*.gz-rw-r--r-- 1 sean root 246841 Mar 5 2013 /tmp/fdboot.img.gzsysadmin@localhost:~$ rm /tmp/fdboot.img.gz
The user is given a prompt, which typically ends in a dollar sign
$
to indicate an unprivileged account. Anything before the prompt, in this case sysadmin@localhost:~
, is a configurable prompt that provides extra information to the user. In the figure above, sysadmin
is the name of the current user, localhost
is the name of the server, and ~
is the current directory (in UNIX, the tilde symbol is a short form for the user’s home directory). We will look at Linux commands in more detail in further chapters, but to finish the explanation, the first command lists files with the ls
command, receives some information about the file, and then removes that file with the rm
command.
The Linux shell provides a rich language for iterating over files and customizing the environment, all without leaving the shell. For example, it is possible to write a single command line that finds files with contents matching a certain pattern, extracts useful information from the file, then copies the new information to a new file.
Linux offers a variety of shells to choose from, mostly differing in how and what can be customized, and the syntax of the built-in scripting language. The two main families are the Bourne shell and the C shell. The Bourne shell was named after the creator and the C shell was named because the syntax borrows heavily from the C language. As both these shells were invented in the 1970’s there are more modern versions, the Bourne Again Shell (Bash) and the tcsh (tee-cee-shell). Bash is the default shell on most systems, though you can almost be certain that tcsh is available if that is your preference.
Other people took their favorite features from Bash and tcsh and have made other shells, such as the Korn shell (ksh) and zsh. The choice of shells is mostly a personal one. If you can become comfortable with Bash then you can operate effectively on most Linux systems. After that you can branch out and try new shells to see if they help your productivity.
Even more dividing than the selection of shells is the choice of text editors. A text editor is used at the console to edit configuration files. The two main camps are vi (or the more modern vim) and emacs. Both are remarkably powerful tools to edit text files, they differ in the format of the commands and how you write plugins for them. Plugins could be anything from syntax highlighting of software projects to integrated calendars.
Both vim and emacs are complex and have a steep learning curve. This is not helpful if all you need is simple editing of a small text file. Therefore pico and nano are available on most systems (the latter being a derivative of the former) and provide very basic text editing.
Even if you choose not to use vi you should strive to gain some basic familiarity because the basic vi is on every Linux system. If you are restoring a broken Linux system by running in the distribution’s recovery mode you are certain to have vi available.
If you have a Linux system you will need to add, remove, and update software. At one point this meant downloading the source code, setting it up, building it, and copying files on each system. Thankfully, distributions created packages which are compressed copies of the application. A package manager takes care of keeping track of which files belong to which package and even downloading updates from a remote server called a repository. On Debian systems the tools include dpkg, apt-get, and apt-cache. On Red Hat derived systems, you use rpm and yum. We will look more at packages later.
4 Development Tools
It should come as no surprise that as software built on contributions from programmers, Linux has excellent support for software development. The shells are built to be programmable and there are powerful editors included on every system. There are also many development tools available, and many modern languages treat Linux as a first class citizen.
Computer languages provide a way for a programmer to enter instructions in a more human readable format, and for those instructions to eventually become translated into something the computer understands. Languages fall into one of two camps: interpreted or compiled. An interpreted language translates the written code into computer code as the program runs, and a compiled language is translated all at once.
Linux itself was written in a compiled language called C. C’s main benefit is that the language itself maps closely to the generated machine code so that a skilled programmer can write code that is small and efficient. When computer memory was measured in the Kilobytes, this was very important. Even with large memory sizes today, C is still helpful for writing code that must run fast, such as an operating system.
C has been extended over the years. There is C++, which adds object support to C (a different style of programming), and Objective C that took another direction and is in heavy use in Apple products.
The Java language takes a different spin on the compiled approach. Instead of compiling to machine code, Java first imagines a hypothetical CPU called the Java Virtual Machine (JVM) and compiles all the code to that. Each host computer then runs JVM software to translate the JVM instructions (called bytecode) into native instructions.
The extra translation with Java might make you think it would be slow. However, the JVM is fairly simple so it can be implemented quickly and reliably on anything from a powerful computer to a low power device that connects to a television. A compiled Java file can also be run on any computer implementing the JVM!
Another benefit of compiling to an intermediate target is that the JVM can provide services to the application that normally wouldn’t be available on a CPU. Allocating memory to a program is a complex problem, but that’s built into the JVM. This also means that JVM makers can focus their improvements on the JVM as a whole, so any progress they make is instantly available to applications.
Interpreted languages, on the other hand, are translated to machine code as they execute. The extra computer power spent doing this can often be recouped by the increased productivity the programmer gains by not having to stop working to compile. Interpreted languages also tend to offer more features than compiled languages, meaning that often less code is needed. The language interpreter itself is usually written in another language such as C, and sometimes even Java! This means that an interpreted language is being run on the JVM, which is translated at runtime into actual machine code.
Perl is an interpreted language. Perl was originally developed to perform text manipulation. Over the years, it gained favor with systems administrators and still continues to be improved and used in everything from automation to building web applications.
PHP is a language that was originally built to create dynamic web pages. A PHP file is read by a web server such as Apache. Special tags in the file indicate that parts of the code should be interpreted as instructions. The web server pulls all the different parts of the file together and sends it to the web browser. PHP’s main advantages are that it is easy to learn and available on almost any system. Because of this, many popular projects are built on PHP. Notable examples include WordPress (blogging), cacti (for monitoring), and even parts of Facebook.
Ruby is another language that was influenced by Perl and Shell, along with many other languages. It makes complex programming tasks relatively easy, and with the inclusion of the Ruby on Rails framework, is a popular choice for building complex web applications. Ruby is also the language that powers many of the leading automation tools like Chef and Puppet, which make managing a large number of Linux systems much easier.
Python is another scripting language that is in common use. Much like Ruby it makes complex tasks easier and has a framework called Django that makes building web applications very easy. Python has excellent statistical processing abilities and is a favorite in academia.
A language is just a tool that makes it easier to tell the computer what you want it to do. A library bundles common tasks into a distinct package that can be used by the developer. ImageMagick is one such library that lets programmers manipulate images in code. ImageMagick also ships with some command line tools that enable you to process images from a shell and take advantage of the scripting capabilities there.
OpenSSL is a cryptographic library that is used in everything from web servers to the command line. It provides a standard interface so that you can add cryptography into your Perl script, for example.
At a much lower level is the C library. This provides a basic set of functions for reading and writing to files and displays, which is used by applications and other languages alike.
(Modul 2.1)
0 comments