Linux教程

[转]Linux Programming Made Easy – A Complete Guide With Resources For Beginners

本文主要是介绍[转]Linux Programming Made Easy – A Complete Guide With Resources For Beginners,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Linux Programming Made Easy – A Complete Guide With Resources For Beginners

原文:https://digital.com/best-website-builders/linux/

-------------

Linux is an operating system, platform, ecosystem, and culture. While the continued dominance of Windows and Mac OS for desktop computing causes the uninitiated consumer to assume that Linux is a sort of fringe option for extreme geeks and those who don’t want to pay for an operating system, the truth of the matter is that Linux is the most used and most important operating system on the planet. It powers the web, it powers our infrastructure, it powers the largest supercomputers in the world.

Developing for Linux can be a bit of a challenge, but it can also be extremely rewarding. This short guide will provide you with an introduction to the information and resources you need to get started with Linux programming. It covers four areas of Linux development: contributing to the kernel, building new modules, developing applications for Linux, and Shell scripting.

Linux kernel development

The Linux kernel is, perhaps, the most ambitious software development project on the planet. New stable releases come out approximately every three months, and each release involves thousands of developers working in dozens of countries.

Getting involved with kernel development is, paradoxically, both easier than it seems like it should be, and also ridiculously difficult. It is easier than it seems like it should be, because there is no hiring process, no interview, no bureaucracy. Anyone who knows what they are doing is welcome to develop for the core, and submit patches. On the other hand, it is also extremely difficult because the kernel is extremely complicated. Moreover, the kernel development community, while quite welcoming in some ways, does not tolerate amateur shenanigans very well. While it helps to have thick skin, nothing really substitutes for actually knowing what you are doing. Developing the core is pretty serious business, involving pretty serious computer science. If you are just getting started with operating system development, this is not really the place to start.

What You Need to Know

Development Skills

Programming of the Linux kernel is done in C. Not C++, not Objective-C, not C#. So the first thing that you need to do is learn the C programming language extremely well.

You also need to have a deep understanding of operating system theory, particularly as it relates to the Linux system. More on that in the next section.

  • The C Programming Language: the definitive guide to the language. Also available as a free PDF.
  • Operating System Concepts: a thorough introduction to the theory and practice of operating system development.

Understanding Linux

Naturally, you need to understand Linux both as a user and as a developer. This includes having a fairly deep understanding of how the Linux kernel is structured, and how the various sub projects fit together.

  • The Linux Programming Interface
  • Linux Kernel Newbies

Process and Culture

Finally, you need to understand how the Linux development process actually works. This includes getting a feel for the community as a whole, for its culture, and how the various members of the development community relate to each other. Also, it means understanding distributed version control, and the development release cycle.

  • How to Participate in the Linux Community: required reading. Start here.
  • Three Ways for Beginners to Contribute to the Linux Kernel: a short, friendly guide to getting involved.
  • Official Things:
    • The Linux Kernel Archives
    • The Linux Kernel Mailing List
    • The Kernel Bug Tracker
  • Being a Moron on linux-kernel: a guide on how not to behave on the Linux Kernel (or any other) mailing list. (Our recommendation: lurk for at least six-months before posting anything.)

Developing Kernel Modules

Before jumping into core development on the Linux kernel, a good way to increase your knowledge and expertise with Linux programming is to work on a kernel module. These are independently developed pieces of software that work with the kernel in order to function as a complete operating system. Kernel modules include things like device drivers for various hardware peripheries, as well as file managers and other low level operating system features.

The barriers to entry for working on a kernel module are, generally speaking, much lower than they are for working on the Linux kernel. There are hundreds of modules, developed by many different teams and individuals, so there is not one set of gatekeepers setting the tone for development. Moreover, the stakes are a bit lower with module development.

What You Need to Know

Kernel modules, like the kernel itself, are usually written in C. (There is some fringe debate about developing kernel modules in C++, and there are some off-the-wall ways of accomplishing this, but it is certainly not the normal way nor is it recommended.)

Obviously, if you are writing a device driver for a piece of hardware, you will need to know quite a bit about the type of hardware, and the firmware embedded on it. You also need a decent understanding of the Linux-based kernel, and the way that it interacts with kernel modules. Finally, if you are contributing to an existing kernel module, you will need to learn about their procedures and development cycle.

  • The Linux Kernel Module Programming Guide: an extremely thorough guide.
  • How to Write Your Own Linux Kernel Module with a Simple Example: a nice walk-through tutorial.

Also see the list of resources above in the Kernel Development section.

Developing Applications For the Linux Operating System

Once we get up out of the weeds of operating system development, and start talking about developing actual applications for the Linux operating system, the job gets a little easier and we have a lot more options about how to proceed. Compilers and interpreters for just about every programming language are available for the Linux platform, often more than one for a particular language.

What You Need to Know

If you are used to developing for Windows or Mac OS, the biggest shock when developing for Linux is probably the wide variety of Linux environments. There are dozens of Linux distros, and every Linux user has the ability to change quite a lot about how their particular environment works. This means, among other things, that you have to pay attention to dependency management a lot more than you might otherwise need to.

Another difference, particularly as compared to a Windows system is that many Linux users prefer to compile their applications from source code. This happens on Mac OS as well but with less frequency. In the Linux world, a large number of users will always prefer to compile applications from source, rather than using an installer package. This might affect how you think about development and distribution of your software.

Most Linux-centric development takes place in C, C++, Perl, or Python. Learning those languages well, and diving into the resources mentioned above (Kernel and Modules) and below (scripting) will help a lot.

  • C Programming in Linux: a thorough introduction and tutorial about programming Linux applications in the C language.
  • Linux Developer Training: paid courses on Linux development, from the Linux Foundation.

Scripting in Linux

Perhaps the “lowest-level” of programming in Linux is shell scripting. However, this is no less “programming” than anything else. Shell scripting in Linux is a great way to automate routine tasks and accomplish more work in less time. Additionally, digging into advanced shell scripting will give you a deeper knowledge and understanding of the Linux operating system. Shell scripting is really what separates novice Linux consumers from advanced Linux users.

What You Need to Know

While there are other options, the most common scripting language is Bash. Even if you plan to move on to more advanced scripting languages, getting a handle on Bash will start you off on the right foot for all types of operating system scripting. Most people who really get into scripting as a way to boost productivity, use either Python or Perl for most of their work. Once you have hit a wall with what you can easily accomplish in Bash, you will probably want to move onto one of those languages.

Bash Resources

  • Bash Guide for Beginners
  • Advanced Bash-Scripting Guide
  • Linux Shell Scripting Tutorial

Python Resources

  • Learn Python the Hard Way: one of the most popular introductions to Python development.
  • Automate the Boring Stuff with Python: Practical Programming for Total Beginners: a great introduction to scripting (as opposed to “development”) in Python. Also available for free online as a video course.

Perl Resources

  • Beginner’s Introduction to Perl
  • How to write shell scripts in Perl
  • UNIX, Shell Scripting and Perl Introduction

General Linux Resources

The Linux Foundation

Linux.org: a central forum for all things Linux.

The Linux Documentation Project: a giant library of Linux guides on all of the subjects above, plus a bunch of other things. This is one of the most important places to go for in-depth Linux information.

Summary

That was a wild ride! From Linux kernel programming all the way down to shell scripting. There are endless ways to program the Linux operating system. With this guide, you should be well on your way.

这篇关于[转]Linux Programming Made Easy – A Complete Guide With Resources For Beginners的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!